(state, robot, memory)
| 1 | function countSteps(state, robot, memory) { |
| 2 | for (let steps = 0;; steps++) { |
| 3 | if (state.parcels.length == 0) return steps; |
| 4 | let action = robot(state, memory); |
| 5 | state = state.move(action.direction); |
| 6 | memory = action.memory; |
| 7 | } |
| 8 | } |
| 9 | |
| 10 | function compareRobots(robot1, memory1, robot2, memory2) { |
| 11 | let total1 = 0, total2 = 0; |