[{"data":1,"prerenderedAt":19},["ShallowReactive",2],{"game-trail-blazer":3},{"id":4,"title":5,"description":6,"difficulty":7,"board":8,"instructions":14,"boardHint":15,"stateTypeName":16,"stateTypeLib":17,"starterCode":18},"trail-blazer","Trail Blazer","Sweep a 6x6 grid leaving a trail behind you - cross it and you're done. Can you cover the whole board?","hard",{"grid":9,"start":11,"obstacles":13},{"width":10,"height":10},6,{"x":12,"y":12},0,[],"Write a function solve(state) that returns \"up\", \"down\", \"left\" or \"right\".\n\nEvery cell you visit joins your trail. Moving off the grid or back onto any\ncell in your own trail ends the run immediately.\n\nstate = {\n  x, y,                    \u002F\u002F current head position\n  grid: { width, height },\n  trail: [{ x, y }, ...],  \u002F\u002F every cell visited so far, in order (trail[0] is the start)\n  stepsTaken\n}\n\nGoal: visit every cell exactly once (a Hamiltonian path) without ever crossing\nyour own trail. (0, 0) is the top-left corner.","Sweep the blue head across the grid, leaving a trail (cyan) - crossing it ends the run.","TrailBlazerState","interface Position {\n  x: number;\n  y: number;\n}\n\ninterface TrailBlazerState {\n  \u002F** Your head's current column. *\u002F\n  x: number;\n  \u002F** Your head's current row. *\u002F\n  y: number;\n  \u002F** The size of the board. *\u002F\n  grid: { width: number; height: number };\n  \u002F** Every cell you've visited so far, in order (trail[0] is the start). *\u002F\n  trail: Position[];\n  \u002F** How many moves you've made so far. *\u002F\n  stepsTaken: number;\n}\n\ntype Move = \"up\" | \"down\" | \"left\" | \"right\";\n","\u002F**\n * @param {TrailBlazerState} state\n * @returns {Move}\n *\u002F\nfunction solve(state) {\n  \u002F\u002F Serpentine sweep: go right across even rows, left across odd rows, and\n  \u002F\u002F drop down a row when you hit the wall. It always covers the whole board -\n  \u002F\u002F try a different traversal (e.g. a spiral) and see if it still works.\n  const goingRight = state.y % 2 === 0;\n\n  if (goingRight && state.x \u003C state.grid.width - 1) return \"right\";\n  if (!goingRight && state.x > 0) return \"left\";\n  return \"down\";\n}\n",1789826988392]