you need to make a counter like this:
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 1
how to implement this beautifully?
I haven’t figured out how to implement this.
you need to make a counter like this:
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 1
how to implement this beautifully?
I haven’t figured out how to implement this.
2
Answers
while(true)
incrementing it.Number.toString(2)
to format the counter to the binary form where2
is a number of bits per a character.String.padStart(3, '0')
to make strings 3 character long.break
the cycle" "
to add spaces between numbers.Binary addition is simple:
Homework: rewrite without builtins, using only fors and ifs.