aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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()