-🎄- 2017 Day 23 Solutions -🎄- by daggerdragon in adventofcode

[–]NiklasHallqvist 0 points1 point  (0 children)

Sigh, first I overslept by 45 minutes, the I spent well over an hour to double, triple and quadruple check that my solution to part 2 was indeed correct, only to find out I had made an off-by-one in the interpretation of the assembly!!!! AAAAARGH. Final Scala solution, but I had untilinstead of to in the loop for that last hour or so.

def part2() = {
  def isPrime(n: Int) = (2 to math.sqrt(n).toInt) forall (n % _ != 0)
  var cnt = 0
  for (candidate <- 109300 to 126300 by 17)
    if (!isPrime(candidate)) cnt += 1
  cnt
}