Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

added 1540 characters in body
Source Link
gastropner
  • 4.5k
  • 1
  • 17
  • 20

Piet, 90 codels

enter image description here

Try it online!

In pseudo-code:

The characters are pushed onto stack. To save space, their ASCII values minus 100 are stored. When the string is built, a loop pops, adds 100 to, and prints each character to STDOUT.

 ; Place sentinel 0 on stack
 push 1
 not
 ; Place 21 (y) on stack
 push 7
 push 3
 mul
 ; Place 16 (t) on stack
 push 4
 dup
 mul
 ; Place 1, 10, 5, 10 (e, n, i, n) on stack
 push 1
 push 10
 push 5
 push 10
 ; Check if top of stack is non-zero
 ; Place a 1 if it is, a 0 otherwise
 dup
 not
 not
 
write_loop:
 ; Turn DP (Direction Pointer) as many steps
 ; clock-wise as value on top of stack
 ; If we had a zero on stack, we continue into
 ; the yellow area and get trapped, ending execution
 pointer
 
 ; If not, we continue
 ; Add 100 to top of stack
 push 5
 push 4
 push 5
 mul
 mul
 add
 
 ; Pop and print character
 outc
 
 ; Turn DP one step to the right
 push 1
 pointer
 
 dup
 not
 not
 
 ; Check if top of stack is non-zero
 ; Place a 1 if it is, a 0 otherwise
 dup
 not
 not
 
 ; We're now back at beginning of the writing loop, sort of like a jmp write_loop

Piet, 90 codels

enter image description here

Try it online!

In pseudo-code:

The characters are pushed onto stack. To save space, their ASCII values minus 100 are stored. When the string is built, a loop pops, adds 100 to, and prints each character to STDOUT.

 ; Place sentinel 0 on stack
 push 1
 not
 ; Place 21 (y) on stack
 push 7
 push 3
 mul
 ; Place 16 (t) on stack
 push 4
 dup
 mul
 ; Place 1, 10, 5, 10 (e, n, i, n) on stack
 push 1
 push 10
 push 5
 push 10
 ; Check if top of stack is non-zero
 ; Place a 1 if it is, a 0 otherwise
 dup
 not
 not
 
write_loop:
 ; Turn DP (Direction Pointer) as many steps
 ; clock-wise as value on top of stack
 ; If we had a zero on stack, we continue into
 ; the yellow area and get trapped, ending execution
 pointer
 
 ; If not, we continue
 ; Add 100 to top of stack
 push 5
 push 4
 push 5
 mul
 mul
 add
 
 ; Pop and print character
 outc
 
 ; Turn DP one step to the right
 push 1
 pointer
 
 dup
 not
 not
 
 ; Check if top of stack is non-zero
 ; Place a 1 if it is, a 0 otherwise
 dup
 not
 not
 
 ; We're now back at beginning of the writing loop, sort of like a jmp write_loop
Source Link
gastropner
  • 4.5k
  • 1
  • 17
  • 20

AltStyle によって変換されたページ (->オリジナル) /