diff options
| author | Orfeas <38209077+0xfea5@users.noreply.github.com> | 2024-06-08 13:50:47 +0300 |
|---|---|---|
| committer | Orfeas <38209077+0xfea5@users.noreply.github.com> | 2024-06-08 13:50:47 +0300 |
| commit | 7be570c4a6e86fb7060f0bc06910ca57003dfe90 (patch) | |
| tree | a998f976596cb902cd8988d74f756b72660bc29c /day1/solution.nim | |
| parent | Day 21 (part1) (diff) | |
| download | aoc22-7be570c4a6e86fb7060f0bc06910ca57003dfe90.tar.gz aoc22-7be570c4a6e86fb7060f0bc06910ca57003dfe90.zip | |
Diffstat (limited to 'day1/solution.nim')
| -rw-r--r-- | day1/solution.nim | 20 |
1 files changed, 0 insertions, 20 deletions
diff --git a/day1/solution.nim b/day1/solution.nim deleted file mode 100644 index b17411a..0000000 --- a/day1/solution.nim +++ /dev/null | |||
| @@ -1,20 +0,0 @@ | |||
| 1 | import std/strutils | ||
| 2 | import std/algorithm | ||
| 3 | |||
| 4 | let content = readFile("./input.txt").splitLines() | ||
| 5 | |||
| 6 | var | ||
| 7 | sum = 0 | ||
| 8 | sums = newSeq[int]() | ||
| 9 | |||
| 10 | for line in content: | ||
| 11 | if line.isEmptyOrWhitespace(): | ||
| 12 | sums.add(sum) | ||
| 13 | sum = 0 | ||
| 14 | continue | ||
| 15 | sum += parseInt(line) | ||
| 16 | |||
| 17 | sort(sums, system.cmp[int], Descending) | ||
| 18 | |||
| 19 | echo sums[0] | ||
| 20 | echo sums[0]+sums[1]+sums[2] | ||
