
1978. Tomohiro Nishikado builds Space Invaders on hardware that can barely redraw the screen, and every invader costs it a slice of the frame. Shoot a few and there is less left to draw, so the survivors march faster, and the very last one tears across the screen. Nobody planned that. He shipped the limitation as the difficulty curve, and the whole arcade genre copied it on purpose. The formation reverses when its outermost column hits the wall, so the game has to know where that column is.
Objective
Return the leftmost column of the formation that still holds a live invader.
Steps
$ leftmost_column({1,1,1, 1,1,1}, 3, 2)
0
$ leftmost_column({0,1,1, 0,1,1}, 3, 2)
1
$ leftmost_column({0,0,0, 0,0,0}, 3, 2)
-1
Expected files
Allowed functions
None. Write every helper yourself.
Loading solutions...