Skip to content

Instantly share code, notes, and snippets.

@laacz

laacz/01b.swift Secret

Created December 11, 2020 19:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save laacz/e8096d890b9107a76a9e1ab88083ad51 to your computer and use it in GitHub Desktop.
Save laacz/e8096d890b9107a76a9e1ab88083ad51 to your computer and use it in GitHub Desktop.
AoC, task 1, part 2. Swift version. Slow as fuck.
import Foundation
let path = Bundle.main.path(forResource: "01.txt", ofType: nil)!
let str = try String(contentsOfFile: path, encoding: String.Encoding.utf8)
let lines = str.split(whereSeparator: \.isNewline).map({Int($0)})
for a in lines {
for b in lines {
for c in lines {
if (a! + b! + c! == 2020) {
print(a! * b! * c!)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment