Closed andersk closed 7 years ago
It's not intentional, but I'm not sure it's a problem. What is the "most straightforward solution"?
(Feel free to delete spoilers.)
Keep a pointer to the current memory location, a counter that runs 0, 1, 2, 3, ..., and an alternating parity bit. On each tick, compare both the counter and its negative with the value at the current location; if either are equal, store the parity bit at the current location, then reset the counter and the parity bit and move the pointer to the next location.
If the values in memory are, say, 3, 0, -4, 1, then the counter needs to run 0, 1, 2, 3, 0, 0, 1, 2, 3, 4, 0, 1 for a total of 4 + 1 + 5 + 2 ticks.
Obviously there are many possible solutions, but none of them can get around the fact that it certainly takes a nonzero amount of time to process a 0 in memory. No solution can skip over an arbitrary number of 0s in constant time.
True! You can run quite a lot faster than your solution, but I do like your solution, so I'll double the time limit for the puzzle in f726c361. (Will be in the next release, on Monday.)
Thanks for reporting!
I’m running 1.1.1.1-gffa46c9a, and the tick limit for test 001 (3, 2, -1, 10, -9, 21, -30) is still 74 ticks; the above solution needs 83. It looks like you only increased the limit for tests after 001.
Ah, oops, good catch! Fixed again in 240ccc96, for the next next release.
The tick limit on the puzzle "Odds" seems to be computed as the sum of the absolute values of the numbers, but the number of ticks required by the most straightforward solution is the sum of one more than the absolute values of the numbers. Is that intentional?