How many functions can be made with the following sets?

Lets say we have a function $$f:X\rightarrow Y$$ where $$X=\{a,b,c,d\}$$ and $$Y=\{x,y\}$$. Can we assign each $$x\in{X}$$ to $$y\in{Y}$$ in $$4^2$$ different possible ways? that is, create $$16$$ possible functions? below is my answer. Is there an easier or quicker method to do this or is my answer sufficient for this type of question?

$$f:X\rightarrow Y\quad f(a)=x , f(b)=x, f(c)=x ,f(d)=x;$$ $$f:X\rightarrow Y\quad f(a)=x , f(b)=x, f(c)=x ,f(d)=y;$$ $$f:X\rightarrow Y\quad f(a)=x , f(b)=x, f(c)=y ,f(d)=y;$$ $$f:X\rightarrow Y\quad f(a)=x , f(b)=y, f(c)=y ,f(d)=y;$$ $$f:X\rightarrow Y\quad f(a)=y , f(b)=y, f(c)=y ,f(d)=y;$$ $$f:X\rightarrow Y\quad f(a)=y , f(b)=y, f(c)=y ,f(d)=x;$$ $$f:X\rightarrow Y\quad f(a)=y , f(b)=y, f(c)=x ,f(d)=x;$$ $$f:X\rightarrow Y\quad f(a)=y , f(b)=x, f(c)=x ,f(d)=x;$$ $$f:X\rightarrow Y\quad f(a)=x , f(b)=x, f(c)=y ,f(d)=x;$$ $$f:X\rightarrow Y\quad f(a)=x , f(b)=y, f(c)=y ,f(d)=x;$$ $$f:X\rightarrow Y\quad f(a)=y , f(b)=x, f(c)=y ,f(d)=x;$$ $$f:X\rightarrow Y\quad f(a)=x , f(b)=y, f(c)=x ,f(d)=y;$$ $$f:X\rightarrow Y\quad f(a)=y , f(b)=x, f(c)=x ,f(d)=y;$$ $$f:X\rightarrow Y\quad f(a)=y , f(b)=x, f(c)=y ,f(d)=y;$$ $$f:X\rightarrow Y\quad f(a)=y , f(b)=y, f(c)=x ,f(d)=y;$$ $$f:X\rightarrow Y\quad f(a)=x , f(b)=y, f(c)=x ,f(d)=x;$$

• See this – John Douma Jan 17 at 21:32

For each element in X, there are two elements in $$Y$$ that they can be mapped to an element in $$Y$$: $$a$$ can be mapped to $$x$$ or $$y$$; same thing for $$b, c, d$$. In all we have: $$2\cdot 2 \cdot 2\cdot 2 = 2^4 = 16$$ ways to do that.
But you've explicitly written the list of all possible function assignments from $$X\to Y$$, which helps you understand this.
In general, given a set $$X$$ with $$n$$ elements, and a set $$Y$$ with $$m$$ elements, then the number of functions $$f: X\to Y$$ is equal to $$|Y|^{|X|} = m^n$$.
You actually got the right answer for the wrong reason: you want $$\mid Y^X\mid=\mid Y\mid^{\mid X\mid}=2^4=16$$.