File tree Expand file tree Collapse file tree 4 files changed +27
-0
lines changed
resources/AdventOfCode2015
test/scala/AdventOfCode2015 Expand file tree Collapse file tree 4 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -229,3 +229,4 @@ The minimal SBT project provides:
229
229
| 17 | [ No Such Thing as Too Much] ( https://adventofcode.com/2015/day/17 ) | [ Source] ( src/main/scala/AdventOfCode2015/Day17.scala ) |
230
230
| 18 | [ Like a GIF For Your Yard] ( https://adventofcode.com/2015/day/18 ) | [ Source] ( src/main/scala/AdventOfCode2015/Day18.scala ) |
231
231
| 19 | [ Medicine for Rudolph] ( https://adventofcode.com/2015/day/19 ) | [ Source] ( src/main/scala/AdventOfCode2015/Day19.scala ) |
232
+ | 20 | [ Infinite Elves and Infinite Houses] ( https://adventofcode.com/2015/day/20 ) | [ Source] ( src/main/scala/AdventOfCode2015/Day20.scala ) |
Original file line number Diff line number Diff line change
1
+ 29000000
Original file line number Diff line number Diff line change
1
+ package AdventOfCode2015
2
+
3
+ object Day20 :
4
+ def part1 (target : Int ): Int =
5
+ val limit = target / 10
6
+ val houses = Array .fill(limit + 1 )(10 )
7
+ for x <- 2 to limit; y <- x to limit by x do houses(y) += 10 * x
8
+ houses.indexWhere(_ >= target)
9
+
10
+ def part2 (target : Int ): Int =
11
+ val limit = target / 10
12
+ val houses = Array .fill(limit + 1 )(10 )
13
+ for x <- 2 to limit; y <- (x to limit by x).take(50 ) do houses(y) += 11 * x
14
+ houses.indexWhere(_ >= target)
15
+
16
+ def main (args : Array [String ]): Unit =
17
+ val data = io.Source .fromResource(" AdventOfCode2015/Day20.txt" ).mkString.trim.toInt
18
+ println(part1(data))
19
+ println(part2(data))
Original file line number Diff line number Diff line change
1
+ package AdventOfCode2015
2
+
3
+ import org .scalatest .funsuite .AnyFunSuite
4
+
5
+ class Day20Suite extends AnyFunSuite
6
+ // No unit tests possible
You can’t perform that action at this time.
0 commit comments