Need help explaining simple code

basically the problem is if you flip a coin 10 times, there are 1024 possible outcomes. well the problem is asking to list all possible outcomes using vba code. i looked online and i found a solution to this problem which is:

Sub H_and_T()
Dim valz, y(), n&, v&
Dim a&, b&, c&, d&
valz = Array("H", "T")
n = 2: v = 10
ReDim y(1 To n ^ v, 1 To v)
For a = 1 To v
For b = 1 To n ^ v Step n ^ a
For c = b To b + n ^ (a - 1) - 1
For d = 1 To n
y(c + n ^ (a - 1) * (d - 1), v - a + 1) = valz(d - 1)
Next d, c, b, a
Range("A1").Resize(n ^ v, v) = y
End Sub

this code lists all 1024 possible outcomes but my problem is that i need to explain exactly step by step on how i got to this. I dont know anything about VBA coding this is just an extra credit problem for my math class. Basically i need an explanation of how to get this code so that a baby can understand it and be able to do it. Please explain how and why each step was done. thank you