GridOS 1 quest 4, basic

In quest 4, nails will be hammered on the head.

I examine each nail, and when I encounter the head, I hammer it. This is also a 1 head program. For part 2 I have to find the shortest nails and hammer the rest down to that length. I use 3 heads and some meta data along the edges.

I examine each line from left to right to find the length. Then I examine all the lines from top to bottom. This way I can change state to “1st head found” and “now I just have to delete the rest” easily. This program could easily be optimized. Instead of writing my own @ at the beginning of each line, I could use the #’s already there. And I note which lines doesn’t have to change, so I could actually skip them quickly.

For part 3, the 2 shortest nails are unchanged and the rest are hammered down to the length of the almost shortest.

All my code .

Skriv en kommentar