Prove or disprove: $f:\mathcal{A}^\mathbb{N} \rightarrow \mathcal{B}$ is continuous $\iff$ $f$ depends on finite numbers of coordinates Problem: Prove or disprove that for a finite set $\mathcal{A}$ and $\mathcal{B}$ both equipped with discrete topology, the function $f:\mathcal{A}^\mathbb{N} \rightarrow \mathcal{B}$ is continuous if and only if $f$ depends on finite number of coordinates on $\mathcal{A}^\mathbb{N}$.
(Note: $f$ depends on finite number of coordinates on $\mathcal{A}^{\mathbb{N}}$ if and only if there exist $n\in \mathbb{N}$ and a function $g:\mathcal{A}^n \rightarrow \mathcal{B}$ such that for any $(x_i)_{i\in\mathbb{N}} \in \mathcal{A}^\mathbb{N}$, $f((x_i)_{i\in\mathbb{N}})=g(x_1x_2...x_n)$.)
I can prove that if $f$ depends on finite number of coordinates, then $f$ must be continuous. However, for another direction, intuitively I believe that it must be true as well, but I cannot prove it. Here is my attempt:
Attempt: To avoid triviality, assume that $|\mathcal{A}|>1$, $|\mathcal{B}|>1$ and $|f(\mathcal{A}^\mathbb{N})|>1$. For any $n \in \mathbb{N}$ and any $a_i \in \mathcal{A}$, define the cylinder set
$$C[a_1a_2...a_n]=\{(x_i)_{i\in\mathbb{N}} \in \mathcal{A}^\mathbb{N} \mid x_1x_2...x_n=a_1a_2...a_n\}.$$
Let's call $n$ as the length of the cylinder set. Based on some reading, the collection of all cylinder sets is the basis of discrete product topology on $\mathcal{A}^\mathbb{N}$.
Let $b \in f(\mathcal{A}^\mathbb{N})$. Since $f$ is continuous, $f^{-1}(\{b\})$ is open. By definition of basis, $f^{-1}(\{b\})$ is the union of some collection of cylinder sets. By property of cylinder sets, if two cylinder sets intersect, then one of them is a subset of another. Therefore, we can assume that $f^{-1}(\{b\})$ is the union of some collection of pairwise disjoint cylinder sets.
My next idea us to show that the collection of cylinder sets above is finite. If this is true, then we set $\ell$ to be the longest length of cylinder sets in the collection. Therefore, for any $(x_i)_{i\in\mathbb{N}} \in \mathcal{A}^\mathbb{N}$, it is sufficient to check for $x_1x_2...x_{\ell}$ to determine whether $f((x_i)_{i\in\mathbb{N}})=b$. We can do this for any $b \in f(\mathcal{A}^\mathbb{N})$.
However, I am stuck at proving that $f^{-1}(\{b\})$ is the finite union of some collection of pairwise disjoint cylinder sets.
Question: May anyone help me to continue my proof? Or is there any other way of proving this? Or is this statement wrong?
 A: It's trivial that if $f$ depends on finitely many coordinates, then $f$ is continuous, in this setting: $\mathcal{A}^n$ is discrete (as $n$ is finite and $\mathcal{A}$ is discrete) so $g$ is always continuous as a function on a discrete space and by definition $f=  g \circ \pi_n$, where $\pi_n: \mathcal{A}^\mathbb{N} \to \mathcal{A}^n$ is the projection onto the first $n$ coordinates (continuous by the definition of the product topology) so $f$ is also continuous as a composition of continuous maps.
The other direction is also quite simple: $f^{-1}[\{b\}]$ is a compact (and open) subset of $\mathcal{A}^\mathbb{N}$ and so a finite union of basic open sets (i.e. cilinder sets):
$$f^{-1}[\{b\}]= \bigcup \{ C[F], F \in \mathcal{F}_b\}$$ 
where $C[F]$ is a cilinder set based on a finite tuple $F$ from some finite power $\mathcal{A}^{n(F)}$, and we collect all needed $F$ for the fibre in some finite set of tuples $\mathcal{F}_b$.
Then $N=\max\{n(F): F \in \cup_{b \in B} \mathcal{F}_b\}$ is a well-defined (finite) integer and then you can go and show that (fixing some $a_0 \in \mathcal{A}$) that $g(x_1,\ldots,x_N) = f(x_1,x_2,\ldots,x_N, a_0,a_0,\ldots)$ is well-defined (i.e. does not depend on how we fill in the final coordinates) and witnesses the fact that $f$ depends on the first $N$ coordinates.
A: I have some ideas but I don’t know if they are  correct. 
A first little remark can be that your problem can be formulated also for the case in which $\mathcal{B}$ is an infinite set with the discrete topology because $\mathcal{A}$ is finite, so it is compact, then by Tychonoff theorem you have that $\mathcal{A}^\mathbb{N}$ is a compact space. But 
$\mathcal{A}^\mathbb{N}=f^{-1}(\mathcal{B})=\bigcup_{b\in \mathcal{B}}f^{-1}(b)$
So $\{f^{-1}(b): b\in \mathcal{B}\}$ is a open cover of $\mathcal{A}^\mathbb{N}$ that is compact so there exists $b_1,\dots ,b_n$ such that 
$\mathcal{A}^\mathbb{N}=f^{-1}(b_1)\cup \dots \cup f^{-1}(b_n)=f^{-1}(b_1,\dots ,b_n)$
So 
$f(\mathcal{A}^\mathbb{N})=\{b_{i_1},\dots , b_{i_m} \}$ where $ i_1,\dots i_m\in \{1,\dots n\} \}$
If $\mathcal{A}^\mathbb{N}=f^{-1}(b)$ for some $b\in \mathcal{B}$ then you can define $g:\mathcal{A}\to \mathcal{b}$ and for all $(x_i)_{i\in \mathbb{N}}$ you have that $f((x_i)_i)=b=g(x_1)$ so we can suppose that $f^{-1}(b)$ are proper subsets of $\mathcal{A}^\mathbb{N}$
Now we can remark that  $f^{-1}(b)$ is  also a closed set of the product topology on $\mathcal{A}^\mathbb{N}$ that is compact so also $f^{-1}(b)$  it is compact so there exists a finite number of proper basic open subsets such that 
$\mathcal{A}^\mathbb{N}=\bigsqcup_{b\in \mathcal{B}}(\bigcup_{k=1}^{n_b} \pi^{-1}_{i_1,b}(A_{i_1,b})\cap \dots \cap \pi^{-1}_{i_{n_b},b}(A_{i_{n_b},b}))$
where  $f^{-1}(b)= \bigcup_{k=1}^{n_b} \pi^{-1}_{i_1,b}(A_{i_1,b})\cap \dots \cap \pi^{-1}_{i_{n_b},b}(A_{i_{n_b},b})) $ 
Now you can define 
$n:= max\{(i_k,b): k\in \{1,\dots n_b\}, b\in \mathcal{B}\}$
and your map will be 
$g: \mathcal{A}^n\to \mathcal{b}$ such that for all $(x_1,\dots x_n)$ if 
$(x_1,\dots ,x_n, x_1,\dots ,x_1,\dots )\in f^{-1}(b)$ then 
$g(x_1,\dots, x_n):=b$
