So you would end up with some sort of oblong grid with sides base-2, but it would give you a trivial method to exhaustively sample the space

]]>Then you have a squared grid with sides of a base-2, which can be divided into segments as many times down as you wish until you have just individual points.

]]>So as an increment to Marks N+x incremental solution… I would suggest that

1) elf picks a locker at random

2) if the locker is full on try i, then move along floor(n/i) lockers and try that.

3) loop back to the beginning if moving along n/i is past the end of the line of lockers

4) move along 1, if n/i < 1 (so eventually checking all N lockers

Again, if you modify the puzzle to get rid of ‘the annoying stupid bits’ it will get easier!

]]>