AoC/2020/day1/main.swift

22 lines
459 B
Swift
Raw Permalink Normal View History

2020-12-11 22:25:14 +01:00
import Foundation
let input = Scanner(string: loadData(day: 1)).integers()
2020-12-11 22:25:14 +01:00
for i in 0..<input.count {
for j in i..<input.count {
for k in j..<input.count {
let a = input[i]
let b = input[j]
let c = input[k]
if k == j && a + b == 2020 {
print("1st", a * b)
}
if a + b + c == 2020 {
print("2nd", a * b * c)
}
}
}
}