Day01
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package be.vandewalleh.aoc.days
|
||||
|
||||
import be.vandewalleh.aoc.utils.Resources
|
||||
|
||||
object Day01 {
|
||||
|
||||
fun part1(list: List<Int>): Int? {
|
||||
list.forEach { a ->
|
||||
list.forEach { b ->
|
||||
if (a + b == 2020) return a * b
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
fun part2(list: List<Int>): Int? {
|
||||
list.forEach { a ->
|
||||
list.forEach { b ->
|
||||
list.forEach { c ->
|
||||
if (a + b + c == 2020) return a * b * c
|
||||
}
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun main() {
|
||||
val input = Resources.ints("day01.txt").toList()
|
||||
println(Day01.part1(input))
|
||||
println(Day01.part2(input))
|
||||
}
|
||||
Reference in New Issue
Block a user