Boundary Question in $\mathbb{R}^{2}$ (Manifolds)

Given a subset $A$ of $\mathbb{R}^{n}$, a point $x \in \mathbb{R}^{n}$ is said to be in the boundary of A if and only if for every open rectangle $B\subseteq\mathbb{R}^{n}$ with $x\in B$, $B$ contains both a point of $A$ and a point of $\mathbb{R}^{n}\setminus A$.

My question is from Spivak's Calculus on Manifolds: Construct a set $A \subseteq [0,1]\times [0,1]$ such that $A$ contains at most one point on each horizontal and vertical line but has boundary equal to $[0,1]\times[0,1]$.


Since $\mathbb Q^2$ and the set of primes are both countably infinite we can write $$\mathbb Q^2 = \{ (x_p,y_p) : p \text{ prime} \}$$ where $p \mapsto (x_p,y_p)$ is a bijection. Now let $$A := \{(x_p + \sqrt{p}/2^p, y_p + \sqrt{p}/2^{p}) : p \text { prime} \} \cap [0,1]^2.$$ To show that $A$ contains at most one point on every vertical or horizontal line it suffices to show that the maps $p \mapsto x_p + \sqrt{p}/2^p$ and $p \mapsto y_p + \sqrt{p}/2^p$ are injective. Suppose $x_p + \sqrt{p}/2^p = x_q + \sqrt{q}/2^q$ for primes $p$ and $q$. Then $\sqrt{p}$ and $\sqrt{q}$ are linearly dependent over $\mathbb Q$ which is only possible if $p = q$.

Since $A$ contains at most one point on every vertical or horizontal line we already know that every open set in $[0,1]^2$ contains some points outside of $A$. Therefore, it remains to show that $A$ is dense in $[0,1]^2$ (or, equivalently, in $(0,1)^2$). If $(x,y)$ is any point in $(0,1)^2$ then, since $\mathbb Q^2 \cap (0,1)^2$ is dense in $(0,1)^2$, there is a subsequence $(p_k)$ of the primes s.t. $(x_{p_k},y_{p_k})$ is a sequence in $(0,1)^2$ which approaches $(x,y)$. But then also $(x_{p_k} + \sqrt{p_k}/2^{p_k},y_{p_k} + \sqrt{p_k}/2^{p_k}) \to (x,y)$ as $k \to \infty$. For large $k$ this is a sequence in $A$, thus $A$ is dense in $(0,1)^2$.