I'm self-studying baby Rudin and trying to prove each theorem without looking at how the book does it. So far it has helped me grasp the material better. Here is the proof I came up with to show that compact subsets of metric spaces are closed.
Proof. Let $K$ be a compact subset of a metric space $X$. Let $x$ be a limit point of $K$ (that is, every ball about $x$ contains a point $y\neq x$ with $y\in K$). Suppose for the sake of contradiciton that $x\not\in K$.
Define a set $$ U=\bigcup_{y\in K}B(y;d(x,y)/2), $$ so that $U$ is an open cover for $K$. Note that $x\not\in U$. (For if $x\in U$ then $d(x,y)<d(x,y)/2$ for some $y\in K$, which is impossible.)
By compactness, take a finite subcover $$ V=\bigcup_{j=1}^nB(y_j;d(x,y_j)/2) $$ for $K$, and let $r=\min_id(x,y_i)/2$. Now we show $B(x;r)$ is disjoint from $V$. Indeed, if $z\in B(x;r)\cap V$, then $d(z,x)<r$ and $z\in B(y_j;d(x,y_j)/2)$ for some $y_j$. The first condition implies $d(z,x)<d(x,y_j)/2$. The second condition implies $d(z,y_j)<d(x,y_j)/2$. The triangle inequality gives $$ d(x,y_j)\leq d(z,x)+d(z,y_j)<d(x,y_j)/2+d(x,y_j)/2=d(x,y_j), $$ which is impossible. Hence $B(x;r)$ and $V$ are disjoint, so we have just constructed a ball about $x$ containing no points of $V$, and by extension no points of $K$. Then $x$ is not a limit point of $K$, contrary to its definition.
I'm aware that Rudin gives a much shorter proof that shows the complement $K^c$ is open. I'm just wondering if my proof is also valid, and if it can be made more concise. I know that proofs by contradiction aren't always preferred, but it's the first one that came to mind.
Here is another way, suppose $x_k \to x$ with $x_k \in K$. Since $K$ is compact there is a subsequence that converges to some $x^*\in K$. Since any subsequence of a convergent sequence converges to the same point we see that $x = x^* \in K$ and so $K$ is closed.