Add files via upload
This commit is contained in:
parent
0f16deb1a9
commit
268e1edcdb
File diff suppressed because it is too large
Load Diff
@ -198,7 +198,7 @@
|
||||
" comment = (f'' if self.got == unknown else\n",
|
||||
" f' ok' if self.ok else \n",
|
||||
" f' WRONG; expected answer is {self.solution}')\n",
|
||||
" return f'Puzzle {self.puzzle:4.1f}: {secs} seconds, answer {self.got:<15}{comment}'\n",
|
||||
" return f'Puzzle {self.puzzle:4.1f}: {secs} seconds, answer {self.got:<17}{comment}'\n",
|
||||
"\n",
|
||||
"def summary(answers):\n",
|
||||
" \"\"\"Print a report that summarizes the answers.\"\"\"\n",
|
||||
@ -554,7 +554,8 @@
|
||||
" def neighbors(self, point) -> List[Point]:\n",
|
||||
" \"\"\"Points on the grid that neighbor `point`.\"\"\"\n",
|
||||
" return [add2(point, Δ) for Δ in self.directions \n",
|
||||
" if add2(point, Δ) in self or self.default not in (KeyError, None)]\n",
|
||||
" if (add2(point, Δ) in self) \n",
|
||||
" or (self.default not in (KeyError, None))]\n",
|
||||
" \n",
|
||||
" def neighbor_contents(self, point) -> Iterable:\n",
|
||||
" \"\"\"The contents of the neighboring points.\"\"\"\n",
|
||||
@ -664,8 +665,7 @@
|
||||
"class GridProblem(SearchProblem):\n",
|
||||
" \"\"\"Problem for searching a grid from a start to a goal location.\n",
|
||||
" A state is just an (x, y) location in the grid.\"\"\"\n",
|
||||
" def actions(self, loc): return self.grid.neighbors(loc)\n",
|
||||
" def result(self, loc1, loc2): return loc2\n",
|
||||
" def actions(self, pos): return [p for p in self.grid.neighbors(pos) if self.grid[pos] != '#']\n",
|
||||
" def h(self, node): return taxi_distance(node.state, self.goal) \n",
|
||||
"\n",
|
||||
"class Node:\n",
|
||||
|
Loading…
Reference in New Issue
Block a user