Skip to main content
3 of 17
Add 2 codel program
Spencer
  • 1.7k
  • 1
  • 10
  • 8

Piet

Factoid

Piet is a programming language where the source code consists of images. Program flow starts with the top-left pixel and moves around the image between pixels and pixel groups until it terminates.

For legibility, Piet programs are commonly displayed in an enlarged version. In such a case the term codel is used to describe a group of same-coloured pixels that correspond to an individual pixel in the source image.

For this challenge, since Piet does not use characters, one codel per vote will be used for sample programs.

1 Codel

1 Codel

This is a valid program, it does nothing and terminates. The control flow starts in the top-left (only) pixel and has no way out, which ends the program.

The pixel can in this case be any colour for the exact same effect.

2 Codels

2 Codels

This will continually read characters from stdin and keep a running total of their unicode values (though nothing is done with this total and it is not displayed).

The input is the command moving left-to-right and then the add is right-to-left. On the first "add" command, nothing will happen since there is only one value on the stack, and the specification says that commands without enough values available are ignored.

This program is a loop that will never end, as most piet programs will be at extremely small sizes, since it takes at least a few codels to properly "trap" the program flow and end it.

Spencer
  • 1.7k
  • 1
  • 10
  • 8