From 84ef9a5343b8eb70a2d05f5b71f6267124d952d4 Mon Sep 17 00:00:00 2001 From: Luke Hubmayer-Werner Date: Fri, 2 Dec 2022 14:52:28 +1030 Subject: [PATCH] Economize parens in Nim as a joke --- 2022/day1.nim | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/2022/day1.nim b/2022/day1.nim index 2dc5a51..e09eb49 100644 --- a/2022/day1.nim +++ b/2022/day1.nim @@ -4,14 +4,14 @@ import sugar from algorithm import sorted let inputString = strip readFile "day1-input" -let elfStrings = inputString.split("\n\n") -let elfRations = collect(newSeq): - for elf in elfStrings: collect(newSeq): - for c in elf.split(): parseInt(c) -let elfCalories = collect(newSeq): +let elfStrings = split(inputString, "\n\n") +let elfRations = collect newSeq: + for elf in elfStrings: collect newSeq: + for c in split elf: parseInt c +let elfCalories = collect newSeq: for rations in elfRations: rations.foldl(a + b) # Part 1 echo max elfCalories # Part 2 -echo elfCalories.sorted()[^3 .. ^1].foldl(a + b) +echo elfCalories.sorted[^3 .. ^1].foldl(a + b)