@@ -3714,8 +3714,8 @@ mutable, but we can use a `frezenset` (the immutable variant of a `set`).
3714
3714
maxscore = defaultdict(int )
3715
3715
3716
3716
for solution in solutions(distance, rates, good, 26 ):
3717
- k = frozenset (choice )
3718
- s = score(rates, choice )
3717
+ k = frozenset (solution )
3718
+ s = score(rates, solution )
3719
3719
3720
3720
if s > maxscore[k]:
3721
3721
maxscore[k] = s
@@ -4314,8 +4314,8 @@ def best_case_scenario(initial_amount, robots, t):
4314
4314
We can now use it to perform three optimizations of the same kind any time we
4315
4315
visit a new state:
4316
4316
4317
- 1 . If the amount of geodes achievable in the best-case scenario number is lower
4318
- than the current ` best ` we have, we can discard the state and any of its
4317
+ 1 . If the amount of geodes achievable in the best-case scenario is lower than
4318
+ the current ` best ` we have, we can discard the state and any of its
4319
4319
successors.
4320
4320
2 . If the amount of obsidian achievable in the best-case scenario is lower than
4321
4321
the amount needed to build a geode robot, we know we'll never be able to
@@ -4428,7 +4428,7 @@ def search(blueprint):
4428
4428
q.append((... , []))
4429
4429
4430
4430
# If we can also "wait" without building, pass along the list of robots
4431
- # we couldhave built, but decided to not build instead.
4431
+ # we could whave built, but decided to not build instead.
4432
4432
if (robs and obs < max_obs_needed) or (rclay and clay < max_clay_needed) or ore < max_ore_needed:
4433
4433
q.append((... , can_build))
4434
4434
@@ -4752,7 +4752,9 @@ use [`isinstance()`][py-builtin-isinstance] to check whether `T[node]` is a
4752
4752
it could also be passed as parameter.
4753
4753
4754
4754
``` python
4755
- def calc (value , list ):
4755
+ def calc (node ):
4756
+ value = T[node]
4757
+ if not isinstance (node, list ):
4756
4758
# This is a value node, just return the value.
4757
4759
return value
4758
4760
@@ -4945,7 +4947,7 @@ rvalue = calc(r)
4945
4947
if lvalue is None :
4946
4948
answer = find_value(l, rvalue)
4947
4949
else :
4948
- answer = find_value(r, rvalue )
4950
+ answer = find_value(r, lvalue )
4949
4951
```
4950
4952
4951
4953
Since ` root ` is ` L == R ` , we could also re-write it as ` L - R ` , knowing that the
@@ -5058,7 +5060,7 @@ for i in range(HEIGHT):
5058
5060
Additionally, we will need an easy way to detect whether we are going out of
5059
5061
bounds (and therefore need to wrap around). To avoid a bunch of annoying
5060
5062
bound-checking ` if ` statements, we can simply add two rows of empty cells at the
5061
- top and at the bottom of the grid, as weel as two columns of empty cells on the
5063
+ top and at the bottom of the grid, as well as two columns of empty cells on the
5062
5064
left and the right. This also makes the actual grid start at ` grid[1][x] ` (where
5063
5065
` x ` is the column of the leftmost free cell in the top row) instead of
5064
5066
` grid[0][x] ` , which is nice since the coordinate system used in the problem
0 commit comments