GridOS 1 quest 4, less steps

For part 1 I stumbled upon a solution by Favo02, that runs very fast. I read this solution and then recreated it on my own. Basically, instead of hammering the nails, hammer the log. Brilliant.

For part 2 and 3, it was back to generated code. In both cases, it took days to get the program to run. Cases 1-72, with 9 nails or less, were easy to write. But cases 73-100… Instead of just traveling right, the heads have to jiggle a little to cover both top and bottom of each column. I grew to really hate case 73.

I’m sure both of those programs could be optimized. Cleanup in part 3 is a bit messy.

Unlike quest 2, the programs didn’t have to list every possible combination in every single case. The combinations just couldn’t overlap. So e.g., looking for the 1st head of a nail, I could look for |!! and =|! and ==! in the case of 3 nails. (! is a wild card.) This made the programs shorter.

READ0		===_______	READ0	**********	RRRRRRRRRR
READ0 |!!_______ READ1 ********** RRRRRRRRRR
READ0 =|!_______ READ1 ********** RRRRRRRRRR
READ0 ==|_______ READ1 ********** RRRRRRRRRR

For some reason, I found it very hard to jiggle the heads. Up, over to mark the next column, then down. I spent such a long time fixing mistakes, and occasionally running into programs taking 10.000 steps in a single direction or running out of steps altogether.

All my code .

Skriv en kommentar