aboutsummaryrefslogtreecommitdiff
path: root/2020/one.nim
blob: f49890778aaa58463b78c2c18adf15114728bf4e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# Day One: Report Repair
import os, strutils

let input: string = paramStr(1)
var done: bool = false

for one in lines(input):
  for two in lines(input):
    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 and done:
        echo parseInt(one) * parseInt(two) * parseInt(three)
        quit()