SAPI, 297 291 byte
MoOMoOMoOMoOMoOMoOMoOMoOMoOMoOmoOMoOmoOmoOoommOoMoOMOOmoOMMMmoOMMMmoOOOOMoOmOoMOOMOomoOmoO
MOOMOomOoMOomoOmoomOoMMMOOOMoOmoOMMMmOomOomoomoOmoOMOOMOomOomOomOoMOomoOmoOmoOmoomOomOomOo
mOomOoMMMmoOMMMMOOMOomoOOOMmOomOoMoOmoOmoomOomOoMoomoOmoOmoOMOOMOoMOomoOMoOmOomoomoOMMMOOO
mOoMMMMMMmOoMMMMOomoo
Cobalah online!
Kode mencetak setiap angka pada barisnya sendiri, dan memisahkan iterasi dengan baris baru tambahan. Ini juga mencetak iterasi pertama dengan sendirinya, diikuti oleh baris baru. Jadi input 5 akan memberikan output yang terlihat seperti 5 2 2
kecuali dengan baris baru, bukan spasi. Contoh output untuk 50
diberikan di bawah ini.
Pohon penjelasan:
MoOMoOMoOMoOMoOMoOMoOMoOMoOMoOmoOMoOmoOmoOoom ;Store 10 in [0], 1 in [1], and integer input in [3]
mOoMoO ;Store 1 in [2]
MOO ;Loop while [2] is non-zero
moOMMMmoOMMMmoOOOOMoOmOo ; Copy [3] to [4], clear contents of [5], and store 1 in [5]
MOO ; Loop while [4] is non-zero
MOomoOmoO ; Decrement 4 and move to 6
MOO ; Loop while [6] is non-zero
MOomOoMOomoO ; Decrement [5] and [6]
moo ; End loop once [6] is empty
mOoMMMOOOMoOmoOMMMmOomOo ; Copy [5] to [6], and reset [5] to 1, then move back to [4]
moo ; End loop now that [4] is empty. [6] now contains the parity of [3]
moOmoO ; Navigate to [6]
MOO ; Loop while [6] is non-empty
MOomOomOomOoMOomoOmoOmoO ; Decrememnt [3] and [6]
moo ; End loop now that [6] is empty. [3] now contains the largest even number less than the previous iteration.
mOomOomOomOomOoMMMmoOMMM ; Copy [1] to [2]
MOO ; Loop while [2] is non-empty
MOomoOOOMmOomOoMoOmoO ; Decrement [2], increment [1], and print the number in [3].
moo ; End loop now that [2] is empty
mOomOoMoo ; Print a new line
moOmoOmoO ; Navigate to [3]
MOO ; Loop while [3] is non-empty
MOoMOomoOMoOmOo ; Decrement [3] twice and increment [4] once
moo ; [4] now contains half of [3]
moOMMMOOOmOoMMM ; Copy [4] to [3] and clear [4]
MMMmOoMMMMOo ; Copy [3] to [2] and decrement once
moo ;End loop now that [2] is empty
Output sampel untuk input 50:
50
24
24
12
12
12
12
6
6
6
6
6
6
6
6
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2