Let $f : \{1,2,3\}\rightarrow\{1,2,3\}$ be a function. Then the number of functions $g : \{1,2,3\}\rightarrow \{1,2,3\}$ such that $f(x) = g(x)$ for at least one $x$ belonging to $\{1,2,3\}$ is what?
My reasoning was that total number of functions $f$ will be $3^3$ and for each of these functions I can have $g$ take exactly the same values as $f$ does so the answer would be $27$ but this answer is not correct, can someone please provide the solution.
In general, the number of functions $\{1,...,n\} \to \{1,...,m\}$ is $m^n$.
Hence the number of functions in this case is $3^3$.
Remember $f$ is one specific function.
It is easier to count the number of $g$s that do not equal $f$ anywhere.
In particular, the range of such a $g$ must have size $2$ not $3$, hence the number of such functions is $2^3$.
Hence the number of the other $g$s, which is what you are looking for, is $3^3-2^3$.
Elaboration: What I mean is that $g(k)$ takes the values $\{1,2,3\} \setminus \{f(k)\}$, and for all $k$ we have $| \{1,2,3\} \setminus \{f(k)\} | = 2$.