aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorj-james2020-12-01 06:11:08 +0000
committerj-james2020-12-01 06:11:08 +0000
commit65e2321cbcec387dc881fddc5721cf6fe27f5e55 (patch)
tree7be6a5ae8356834c29591079c2d8df041312aacf
parent2ea995e6188c782afbd5eb85e4e5b51c9cdbaad8 (diff)
Day One: Produce clean output
-rw-r--r--2020/one.nim7
1 files changed, 5 insertions, 2 deletions
diff --git a/2020/one.nim b/2020/one.nim
index f136ed3..adc7e86 100644
--- a/2020/one.nim
+++ b/2020/one.nim
@@ -1,11 +1,14 @@
import os, strutils
let input = paramStr(1)
+var done: bool = false
for one in lines(input):
for two in lines(input):
- if parseInt(one) + parseInt(two) == 2020:
+ if parseInt(one) + parseInt(two) == 2020 and not done:
echo parseInt(one) * parseInt(two)
+ done = true
for three in lines(input):
- if parseInt(one) + parseInt(two) + parseInt(three) == 2020:
+ if parseInt(one) + parseInt(two) + parseInt(three) == 2020 and done:
echo parseInt(one) * parseInt(two) * parseInt(three)
+ quit()