Algorithms · JavaScript

Code Arena

Turn-based puzzles. Write one function, turn(state), that reads the game state and returns your move. It runs every turn against three test cases, and you watch the replay.

0/ 18
easyFind the maximum, every turn

Ridge Breaker

A cargo drone is coming down over a ridge of eight mountains and it cannot climb. Every turn it drops one level.

You control its mining laser. Each turn you blast one mountain flat. If any mountain is still as high as the drone after your shot, it hits it.

Input: state
heights
array of 8 numbers, left to right. 0 means already flat.
altitude
the drone's altitude this turn, in the same units.
ReturnThe index (0 to 7) of the mountain to blast.
ridge.js
0·31·92·13·64·45·86·27·5altitude 10
0/0

console.log output and your moves appear here, turn by turn.