more flat files

This commit is contained in:
Rupus Reinefjord 2022-12-04 12:41:58 +01:00
parent 46a919fb8d
commit 65b4fbf539
5 changed files with 0 additions and 0 deletions

18
2022/day01.nim Normal file
View file

@ -0,0 +1,18 @@
import std/[algorithm, math, os, strutils, sugar]
let lst = stdin.readAll().strip()
let elves = lst.split("\n\n")
var totals = collect:
for elf in elves:
let elfInts = collect:
for cal in elf.split("\n"):
parseInt(cal)
sum(elfInts)
totals.sort(order = Descending)
if paramStr(1) == "1":
echo totals[0]
elif paramStr(1) == "2":
echo sum(totals[0..2])