diff options
| author | Orfeas Chatzipanagiotis <csd4366@csd.uoc.gr> | 2022-12-08 05:45:14 +0200 |
|---|---|---|
| committer | Orfeas Chatzipanagiotis <csd4366@csd.uoc.gr> | 2022-12-09 11:57:39 +0200 |
| commit | 52123945a7bf2d627f3000add96d30f46c6f48b8 (patch) | |
| tree | bdf168e85a030b96fd610d11293039f4f1907bc3 /day2/solution.nim | |
| parent | Day 2 (diff) | |
| download | aoc22-52123945a7bf2d627f3000add96d30f46c6f48b8.tar.gz aoc22-52123945a7bf2d627f3000add96d30f46c6f48b8.zip | |
Day 3,4
Diffstat (limited to 'day2/solution.nim')
| -rw-r--r-- | day2/solution.nim | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/day2/solution.nim b/day2/solution.nim index 8bbd95b..8a794d3 100644 --- a/day2/solution.nim +++ b/day2/solution.nim | |||
| @@ -1,12 +1,10 @@ | |||
| 1 | import std/strutils | 1 | import std/strutils |
| 2 | import std/sequtils | 2 | import std/sequtils |
| 3 | import std/tables | ||
| 4 | 3 | ||
| 5 | let content = readFile("./input.txt").split("\n") | 4 | let content = readFile("./input.txt").strip().split("\n") |
| 6 | let rounds = map( | 5 | let rounds = map( |
| 7 | # Filter out empty lines | 6 | content, |
| 8 | filter(content, proc(line: string): bool = not line.isEmptyOrWhitespace()), | 7 | # Split line into pair of characters |
| 9 | # Split line into pair of strings | ||
| 10 | proc(round: string): tuple[other: char, self: char] = | 8 | proc(round: string): tuple[other: char, self: char] = |
| 11 | var splitted = round.split(" ") | 9 | var splitted = round.split(" ") |
| 12 | (splitted[0][0], splitted[1][0])) | 10 | (splitted[0][0], splitted[1][0])) |
