This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package aoc2021 | |
import scala.annotation.tailrec | |
object Day05: | |
case class Point(x: Int, y: Int) | |
case class Line(start: Point, end: Point): | |
private def iter(start: Int, end: Int, count: Int): Seq[Int] = | |
if (start == end) Seq.fill(count)(start) | |
else Range.inclusive(start, end, if (start < end) 1 else -1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package aoc2021 | |
import scala.annotation.tailrec | |
import scala.collection.immutable.BitSet | |
object Day03: | |
type InputType = Seq[String] | |
@main def runDay03: Unit = | |
val testData = time("testReady", () => ready(testInput)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package aoc2021 | |
import scala.annotation.tailrec | |
object Day02: | |
case class Move(direction: String, step: Int) | |
type InputType = IndexedSeq[Move] | |
@main def runDay02: Unit = | |
val testData = time("testReady", () => ready(testInput)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package aoc2021 | |
import scala.annotation.tailrec | |
object Day01: | |
type InputType = List[Int] | |
@main def runDay01: Unit = | |
val testData = time("testReady", () => ready(testInput)) | |
time("testPart1", () => part1(testData)) // should be 7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package aoc2020 | |
import scala.annotation.tailrec | |
object Day25: | |
type InputType = List[Long] | |
@main def runDay25: Unit = | |
val testData = time("testReady", () => ready(testInput)) | |
time("testPart1", () => part1(testData)) // should be 14897079 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package aoc2020 | |
object Day24: | |
type InputType = Tiles | |
type Tiles = Set[Tile] | |
case class Tile(x: Int, y: Int): | |
def neighbors(): Seq[Tile] = | |
Seq( | |
Tile(this.x - 1, this.y - 1), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package aoc2020 | |
import scala.annotation.tailrec | |
object Day23: | |
type InputType = Seq[Long] | |
type Label = Long | |
class Cup(val label: Label): | |
var next = this |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package aoc2020 | |
import scala.annotation.tailrec | |
object Day23: | |
type InputType = String | |
@main def runDay23: Unit = | |
val testData = time("testReady", () => ready(testInput)) | |
time("testPart1", () => part1(testData)) // should be 67384529 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package aoc2020 | |
import scala.annotation.tailrec | |
object Day22: | |
type InputType = (CardDeck, CardDeck) | |
type CardDeck = Seq[Int] | |
@main def runDay22: Unit = | |
val testData = time("testReady", () => ready(testInput)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package aoc2020 | |
object Day21: | |
case class Food(ingredients: Seq[String], allergents: Seq[String]) | |
object Food: | |
def of(line: String): Food = | |
line match | |
case s"${ins} (contains ${als})" => Food.of(ins, als) | |
def of(ins: String, als: String): Food = |