#### npiet's gallery of piet programs - enjoy your visit

Click the pictures for a bigger version.
(please note: some of the png pictures seem to have a gamma value, so the colors maybe not correct).

The original Hello World! (from piet's page) big bigger Hello world!
(36 trace steps)
Prints the Fibonacci Numbers below 1000. The large blue area (31 codels) is squared and used as upper limit. The 10 red codels (10 is ascii code for newline) in the upper middle are traversed one time left-to-right and in the loop then right-to-left (the second traversal is in the loop printing the values followed by a linefeed). The unused codels are filled with yellow.
A simple loop Counts from 10 to 1 in a loop. The decision is done in the lower line from right to left: The decremented loop value is duplicated, a 0 is pushed on the stack (push of a one followed by a not) and the test-result of a greater is the argument for the pointer: If it is 0 the loop is exited and if it is 1 the loop is reentered.

Note: this is an updated example to v1.2 with proper white codel crossing.

And here a straight forward hello world example This is done by a series of push and outchar commands.
The trace output shows the straight way with the black line from the upper-left codel to the right.
Not genious, but an easy way to output strings in piet.
Prime Number Tester

(This one is really a smile worth ;-)

The program starts with a in(number) and the read number is in a loop divided by the number-1 until 1 is reached. This is really the slowest way to do the prime test, but what the heck. The result of the test is printed as a Y if prime, or N if not.
The program really spents some of its time preparing and doing rolls of the stack, but thats the way if you can access only the top of the stack.
The big red color block represents the N result char and is the exit if the number is not prime. The block is traversed within the test loop too, but without a command to be executed.
The Y case is evaluated running into the green and dark-red color blocks at the right border (the Y is calculated there).
The white blocks traved through are used to seperate some of the evaluation steps and make it easier to code - i mean: easier to read.

Note: updated to be fine with v1.2 white codel crossing.

go back

Sun Jan 24 23:47:02 CET 2010