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 Day20: | |
type InputType = IndexedSeq[Tile] | |
class Image(val pixels: IndexedSeq[IndexedSeq[Boolean]]): | |
def this(image: String) = | |
this( | |
image.linesIterator | |
.filter(!_.trim.isEmpty) |
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 Day19: | |
case class InputType(val rules: Map[String, Any], val patterns: Seq[String]) | |
object Rule | |
class Rules | |
@main def runDay19: 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 Day16: | |
class InputType(val myTicket: Seq[Int], val nearbyTickets: Vector[Vector[Int]]): | |
val validNumbers = new Array[Boolean](1000) | |
def this(validNumberString: String, myTicketString: String, nearbyTicketString: String) = { | |
this( | |
IndexedSeq.empty, | |
nearbyTicketString | |
.split(':')(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 Day15: | |
type InputType = Seq[Int] | |
@main def runDay15: Unit = | |
val testData = time("testReady", () => ready(testInput)) | |
time("tesPart1", () => part1(testData)) // would be 436 |
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.math.pow | |
object Day14: | |
type InputType = String | |
@main def day14: Unit = | |
val testData = time("testReady", () => ready(testInput)) | |
time("testPart1", () => part1(testData)) |
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 org.junit.{Assert, Test} | |
object Day13: | |
type InputType = (Int, List[String]) | |
def ready(input: String): InputType = | |
val in = input | |
.linesIterator |
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 Day12: | |
import Direction._ | |
import Action._ | |
enum Direction: | |
case North, East, West, South | |
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 Day12: | |
object Direction extends Enumeration: | |
val North: Value = Value("N") | |
val East: Value = Value("E") | |
val West: Value = Value("W") | |
val South: Value = Value("S") | |
implicit class Executor(dir: Value): |
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 Day11: | |
enum SeatStatus: | |
case Empty, Floor, Occupied | |
import SeatStatus._ | |
object SeatStatus: |
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 Day11: | |
object SeatStatus extends Enumeration: | |
val Empty: SeatStatus.Value = Value('L') | |
val Floor: SeatStatus.Value = Value('.') | |
val Occupied: SeatStatus.Value = Value('#') | |
import SeatStatus._ |