Skip to content

Commit cbffd90

Browse files
committed
Fix various typos in all walkthroughs
1 parent dbc4447 commit cbffd90

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

2020/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -3382,7 +3382,7 @@ def is_valid(ticket):
33823382
```
33833383
33843384
Sweet. Now we just need to filter out invalid tickets and only work with valid
3385-
ones. Perfect use case for the [`filter()`][py-builtin-filter] buil-in. Then,
3385+
ones. Perfect use case for the [`filter()`][py-builtin-filter] built-in. Then,
33863386
for each valid ticket, for each field we want to check if any of the ticket
33873387
values violate that particular field's validity requirements. If so, we'll
33883388
remove the index of that value as a possible index for the field.
@@ -3713,7 +3713,7 @@ dimensions.
37133713
Oh no! The code we wrote works with 3 dimensions, do we need to rewrite
37143714
everything? Well, not quite, the only function that would need to be updated is
37153715
`neighbors()`, since it takes exactly 3 arguments. We can make a small change to
3716-
generalize it to work with any dimension.
3716+
generalize it to work with any number of dimensions.
37173717
37183718
To generate neighbor coordinates, we would need to take an additional parameter
37193719
`w` for the fourth dimension, but since we want this to be general, taking a

2021/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5010,7 +5010,7 @@ different points to keep track of... a little bit too many to fit in memory
50105010
As usual, there are different ways to solve today's problem:
50115011

50125012
1. The most optimal solution in terms of time complexity is probably using
5013-
[segment trees][wiki-segment-tree], however it also the most complex one to
5013+
[segment trees][wiki-segment-tree], however it's also the most complex one to
50145014
actually implement. There are other solutions that work just fine given the
50155015
number of commands in our input isn't that large.
50165016

2022/README.md

+10-8
Original file line numberDiff line numberDiff line change
@@ -3714,8 +3714,8 @@ mutable, but we can use a `frezenset` (the immutable variant of a `set`).
37143714
maxscore = defaultdict(int)
37153715

37163716
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)
37193719

37203720
if s > maxscore[k]:
37213721
maxscore[k] = s
@@ -4314,8 +4314,8 @@ def best_case_scenario(initial_amount, robots, t):
43144314
We can now use it to perform three optimizations of the same kind any time we
43154315
visit a new state:
43164316

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
43194319
successors.
43204320
2. If the amount of obsidian achievable in the best-case scenario is lower than
43214321
the amount needed to build a geode robot, we know we'll never be able to
@@ -4428,7 +4428,7 @@ def search(blueprint):
44284428
q.append((..., []))
44294429

44304430
# 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.
44324432
if (robs and obs < max_obs_needed) or (rclay and clay < max_clay_needed) or ore < max_ore_needed:
44334433
q.append((..., can_build))
44344434

@@ -4752,7 +4752,9 @@ use [`isinstance()`][py-builtin-isinstance] to check whether `T[node]` is a
47524752
it could also be passed as parameter.
47534753

47544754
```python
4755-
def calc(value, list):
4755+
def calc(node):
4756+
value = T[node]
4757+
if not isinstance(node, list):
47564758
# This is a value node, just return the value.
47574759
return value
47584760

@@ -4945,7 +4947,7 @@ rvalue = calc(r)
49454947
if lvalue is None:
49464948
answer = find_value(l, rvalue)
49474949
else:
4948-
answer = find_value(r, rvalue)
4950+
answer = find_value(r, lvalue)
49494951
```
49504952

49514953
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):
50585060
Additionally, we will need an easy way to detect whether we are going out of
50595061
bounds (and therefore need to wrap around). To avoid a bunch of annoying
50605062
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
50625064
left and the right. This also makes the actual grid start at `grid[1][x]` (where
50635065
`x` is the column of the leftmost free cell in the top row) instead of
50645066
`grid[0][x]`, which is nice since the coordinate system used in the problem

2023/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ for line in fin:
7171

7272
We can simplify this with the help of the [`filter()`][py-builtin-filter]
7373
built-in function: just filter out any character that satisfies `str.isdigit()`.
74-
To only extrac the first such character from the iterator returned by `filter()`
75-
we can simply use [`next()`][py-builtin-next].
74+
To only extract the first such character from the iterator returned by
75+
`filter()` we can simply use [`next()`][py-builtin-next].
7676

7777
```python
7878
for line in fin:
@@ -179,7 +179,7 @@ for line in fin:
179179
total2 += next(filter(None, map(check_digit, (line[i:] for i in range(len(line) -1, -1, -1)))))
180180
```
181181

182-
First two starts of the year done. Welcome to Advent of Code 2024!
182+
First two stars of the year done. Welcome to Advent of Code 2023!
183183

184184

185185
Day 2 - Cube Conundrum
@@ -714,7 +714,7 @@ answer2 = sum(products)
714714
Or more concisely:
715715

716716
```python
717-
answer2 = map(prod, filter(lambda x: len(x) == 2, gears.values())))
717+
answer2 = sum(map(prod, filter(lambda x: len(x) == 2, gears.values()))))
718718
print('Part 2:', answer2)
719719
```
720720

0 commit comments

Comments
 (0)