Skip to content

Commit 86d4a6b

Browse files
authored
Proof read day03.md (#543)
1 parent 2604fcd commit 86d4a6b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

docs/2023/puzzles/day03.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The solution models the input as a grid of numbers and symbols.
1515
- `case class Coord(x: Int, y: Int)` to represent one coordinate on the grid
1616
- `case class Symbol(sym: String, pos: Coord)` to represent one symbol and its location
1717
- `case class PartNumber(value: Int, start: Coord, end: Coord)` to represent one number and its starting/ending location
18-
2. Parse the input to create a dense collection of symbols and numbers
18+
2. Parse the input to create a sparse collection of symbols and numbers
1919
3. Separate the symbols from the numbers
2020
4. Then summarise the whole grid as follows:
2121
- in `part1`, find all `numbers` adjacent to a `symbol`, and sum the total of the resulting `number` values,
@@ -38,7 +38,7 @@ case class Coord(x: Int, y: Int):
3838
else true
3939
```
4040

41-
We also want to easily distinguish a `Symbol` from a `Number`, and to know wether a `Symbol` is adjacent to a `Number`:
41+
We also want to easily distinguish a `Symbol` from a `Number`, and to know whether a `Symbol` is adjacent to a `Number`:
4242

4343
```scala
4444
case class PartNumber(value: Int, start: Coord, end: Coord)
@@ -68,7 +68,7 @@ def findPartsAndSymbols(source: String) =
6868
case s => Symbol(s.matched, Coord(s.start, i))
6969
```
7070

71-
The `object IsInt` with the `.unapply` method is called an extractor. It allows to define patterns to match on. Here it will give me a number if it can parse it from a string
71+
The `object IsInt` with the `.unapply` method is called an extractor. It allows to define patterns to match on. Here it will give me a number if it can parse it from a string.
7272

7373
The `findPartsAndSymbols` does the parsing and returns a collection of `PartNumber` and `Symbol`. What we want to match on is either a number or a symbol (which is anything except the `.` and a `digit`). The regex match gives us some information (such as starting / ending position of the matched string) which we use to create the `PartNumber` and `Symbol` instances.
7474

0 commit comments

Comments
 (0)