This question is heavy on terminology. But let me see what I can come up with.
The first obvious question to ask is, what does A look like? Given that A is the intersection of a countable family of open sets, we should start with open sets.
Open sets are made up of an arbitrary number of open intervals, possibly including those of the form (a,∞) or (-∞,a). In particular, these intervals may be separated by a single point, for example: (0,1) ##\cup## (1,2) or by infinitely many points: (0,1) ##\cup## (2,3).
Taking intersections, consider these examples:
#1. (0, 2), (1/2, 2), (3/4, 2), (7/8, 2), ...
#2. (0, 2), (0, 3/2), (0, 5/4), (0, 9/8), ...
#3. (0, 2), (1/2, 3/2), (3/4, 5/4), (7/8, 9/8), ...
The intersection of #1 is [1, 2), the intersection of #2 is (0, 1], the intersection of #3 is [1], just the point x = 1. We could also have closed intervals of the form [a, b]. We see that A consists of open intervals, half open intervals and closed intervals. Call these the components of A.
A pertinent question is, how are these components separated from each other? Let's investigate this. In the interval (a,b], call a an open boundary point and b a closed boundary point. Then closed intervals have only closed boundary points, etc. Any closed boundary point must be adjacent, on at least one side, to an open ball disjoint from A, this is evident from the examples above. Any gap between components of A that contains only a single point is surrounded by open boundary points of A. So we can now speak of components and gaps knowing that if a gap is a single point, the boundary points are open.
Call any gap that not just a single point a wide gap. Define the width of a wide gap as the difference between the boundaries of the gap. That is, suppose we have the gap "α)...[β", then the gap width = β-α. Henceforth, let α, β signify the left and right boundaries of a wide gap.
I define here the following rules. M means middle, L means left and R means right:
Rule M(a,b): For a ≤ x ≤ b, let f(x) = 1 if x is rational, and f(x) = 0 if x is irrational.
Rule L(a,b): For a < x < b, let f(x) = x-a if x is rational, and f(x) = 0 if x is irrational.
Rule R(a,b): For a < x < b, let f(x) = b-x if x is rational, and f(x) = 0 if x is irrational.
Define the function f by this schema:
#1. For every x ##\in## A, let f(x) = 0.
#2. For every single-point gap x between components of A, let f(x) = 1.
#3. For each wide gap:
#3.1. If α and β are open, apply M(α, β).
#3.2. If α is closed and β is open, choose an α < α' < β such that α' < α + 1. Apply rules L(α, α') and M(α', β).
#3.3. If α is open and β is closed, choose an α < β' < β such that β' + 1 > β. Apply rules M(α, β') and R(β', β).
#3.4. If α is closed and β is closed, choose α < α' < β' < β such that α' < α + 1 and β' + 1 > β. Apply the rules L(α, α'), M(α', β'), R(β', β).
Notice:
#A: The function f so defined is continuous on all points of A that are not boundary points.
#B: The function f is discontinuous at the points covered by #2.
#C: The function f is discontinuous at all points covered by rule M (by an ε-δ argument). Corollary: This together with #B implies that f is discontinuous at all open boundary points.
#D.1: At points covered by rule L(a, b), f is discontinuous at points a < x ≤ b.
#D.2: At points covered by rule R(a,b), f is discontinuous at points a ≤ x < b. Corollary: #D.1, #D.2 and #C's corollary together imply that f is discontinuous at all points not in A.
Two cases remain, closed boundary points on the left or right of a gap.
#1. When L(α,β) was applied, for any ε let 0 < x-α < min(ε,β), then |f(x) - f(α)| = |f(x)| ≤ x-α ≤ ε. That is, the limit from the right at α = 0 = f(α).
#2. By a similar argument, when R(α, β) was applied, the limit from the left at β = 0 = f(β).
#3. By #1 and #2, any discrete point of A has equal limits from the left and right. Therefore f is continuous at all such points.
#4. If α in #1 is not a discrete point, it is the right boundary of an open (sorry, closed) or half-open interval in A on which f vanishes. Therefore the limit from the left = 0 and f is continuous at α.
#5. Similarly for β in #2, the limit from the right = 0 and f is continuous at β.
All points on the real line have been covered and f so defined satisfies the claim.
PS. I knew from reading Spivak of the existence of a function continuous at a single point. I built this proof using that idea together with a characterization of what A would look like, using terminology I knew like open ball and boundary.