[Piet](http://www.dangermouse.net/esoteric/piet.html) = **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][1] 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][2] 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. **3 Codels** ![3 Codels][3] This is a basic echo-type program, it will read a character at a time from stdin and print it to stdout. Again this is an infinite loop. When travelling back left-to-right it attempts to perform subtract and add commands, but the stack is empty so these become no-ops. **4 Codels** ![4 Codels][4] Prints out 2 to stdout indefinitely. Not a particularly interesting program functionally, but now that we finally have a composite number of codels we can show off slightly more advanced flow than left-to-right. The program goes around clockwise pushing 1 onto the stack twice, adding them together, then outputting the result. **5 Codels** ![5 Codels][5] Repeatedly reads a character at a time from stdin and tracks the sum of their unicode values. This is essentially the same functionality as the 2-codel version, but this challenge is about showcasing the language, and one of the cool things about piet is how you can have different-looking pictures that do the same thing. Here we see the white codel for the first time, which allows program flow to slide across it without executing instructions. The magenta and blue codels do all the work here, the 2 red ones just push the number 1 onto the stack and pop it back off. **6 Codels** ![6 Codels][6] Again, repeating earlier functionality with a different look. This is another echo program that reads a character at a time from stdin to stdout. Here we see our first black codel. Program flow cannot enter a black codel, so from the light magenta codel in the top-right the program will bounce back left. The blue and green codels are purely decorative, the program will never enter them. **7 Codels** ![7 Codels][7] Yet another echo program with a different look. Here we see our first codel blocks larger than size 1. In piet, any contiguous block of codels of the same colour is treated as a single block. The size of the block does not matter except when executing the "push" instruction, so this program is treated exactly like a 3-codel version with these same colours. **8 Codels** ![8 Codels][8] Reads a number from stdin and outputs the square to stdout, repeatedly. Control flow is a basic clockwise pattern, and it uses a white codel as well as a superfluous pop and push operation on either side of it to pad out the space and get the flow back to the beginning. **9 Codels** ![9 Codels][9] Adds 1 + 2 = 3, and then terminates. Now that we have a program with greater than 2 codels in both dimensions, we can finally set up a region that will trap the program and end it instead of looping forever. The bottom light yellow bar causes the program to end since there is no way for it to flow out. ---------- The 1- and 2-high programs are quickly becoming ugly and uninteresting so from this point on I'm going to focus on numbers that allow at least a few codels in each direction. **12 Codels** ![12 Codels][10] Finally a program that does something that could be argued as useful (though it's still a bit of a stretch). Reads 2 numbers from stdin sequentially and then outputs their sum, and does this repeatedly. This could have been done in 8 codels, but since we have the extra space we can make something that's a little bit inspired by an old no-signal TV display. **15 Codels** ![15 Codels][11] Reads a number from stdin and outputs its' square. This uses a couple of tricks to get a bit of a symmetrical look to a program that actually does something. The leftmost red bar is a different colour on the bottom pixel than the rest, taking advantage of the fact that (for me at least) these 2 shades of red look very similar. The darker red pixel, along with the medium green pixels on the top and bottom of the middle column, are decorative and the program will never reach them. [1]: https://i.sstatic.net/eB4XY.png [2]: https://i.sstatic.net/lRG1h.png [3]: https://i.sstatic.net/rFVzV.png [4]: https://i.sstatic.net/m3XR2.png [5]: https://i.sstatic.net/nYWRF.png [6]: https://i.sstatic.net/e8y5T.png [7]: https://i.sstatic.net/EnEqR.png [8]: https://i.sstatic.net/V9FYs.png [9]: https://i.sstatic.net/yKnUm.png [10]: https://i.sstatic.net/uGZR7.png [11]: https://i.sstatic.net/OjV6N.png