MCPcopy Create free account
hub / github.com/marijnh/Eloquent-JavaScript / countSteps

Function countSteps

code/solutions/07_1_measuring_a_robot.js:1–8  ·  view source on GitHub ↗
(state, robot, memory)

Source from the content-addressed store, hash-verified

1function 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
10function compareRobots(robot1, memory1, robot2, memory2) {
11 let total1 = 0, total2 = 0;

Callers 1

compareRobotsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected