Compare commits
13 Commits
0198ead034
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1d9dc696a8 | ||
|
|
9654c59bfd | ||
|
|
65b220007e | ||
|
|
3515ad8d11 | ||
|
|
76367959ae | ||
|
|
3c6824e070 | ||
|
|
d1079b00b2 | ||
|
|
843bfcb2c3 | ||
|
|
6db15ba9af | ||
|
|
58710aca7a | ||
|
|
cdf14fdada | ||
|
|
4e20f541f9 | ||
|
|
57852ccfc1 |
@@ -4,8 +4,8 @@ language: "scala"
|
||||
dockerfile: "Dockerfile"
|
||||
code: "/code"
|
||||
workdir: "/code"
|
||||
runonce: "./mill aoc.assembly"
|
||||
cmd: "java -jar ./out/aoc/assembly.dest/out.jar %day% %input%"
|
||||
runonce: "./mill aoc.nativeImage"
|
||||
cmd: "./out/aoc/nativeImage.dest/aoc %day% %input%"
|
||||
environment:
|
||||
- AOC_BENCH=1
|
||||
daypath: "aoc/src/dev/ctsk/aoc/days/Day%dayzero%.scala"
|
||||
|
||||
12
Dockerfile
12
Dockerfile
@@ -1,9 +1,15 @@
|
||||
FROM eclipse-temurin:23-jdk-alpine
|
||||
FROM eclipse-temurin:23-jdk
|
||||
|
||||
RUN apk add curl
|
||||
RUN apt-get update && apt-get install -y curl gzip build-essential libz-dev
|
||||
RUN curl -fL "https://github.com/coursier/launchers/raw/master/cs-x86_64-pc-linux.gz" | gzip -d > cs
|
||||
RUN chmod +x cs
|
||||
RUN cp cs /usr/local/bin
|
||||
RUN ./cs setup --yes
|
||||
|
||||
COPY . /build
|
||||
|
||||
WORKDIR /build
|
||||
|
||||
RUN ./mill aoc.assembly
|
||||
RUN ./mill aoc.assembly
|
||||
|
||||
RUN ./mill aoc.nativeImage
|
||||
@@ -10,6 +10,7 @@ case class Point(x: Int, y: Int):
|
||||
def -(o: Point): Point = Point(x - o.x, y - o.y)
|
||||
def *(n: Int): Point = Point(n * x, n * y)
|
||||
def reduce: Point = { val g = gcd(x.abs, y.abs); Point(x / g, y / g) }
|
||||
def manhattan: Int = x.abs + y.abs
|
||||
|
||||
val DIRS = Seq(Direction.Up, Direction.Right, Direction.Down, Direction.Left)
|
||||
|
||||
|
||||
@@ -21,7 +21,13 @@ val solvers = Map[Int, Solver](
|
||||
16 -> Day16,
|
||||
17 -> Day17,
|
||||
18 -> Day18,
|
||||
19 -> Day19
|
||||
19 -> Day19,
|
||||
20 -> Day20,
|
||||
21 -> Day21,
|
||||
22 -> Day22,
|
||||
23 -> Day23,
|
||||
24 -> Day24,
|
||||
25 -> Day25
|
||||
)
|
||||
|
||||
def runSolver(solver: Solver, input: os.Path): Unit =
|
||||
@@ -31,16 +37,16 @@ def runSolver(solver: Solver, input: os.Path): Unit =
|
||||
println(solution.p1)
|
||||
println(solution.p2)
|
||||
case None =>
|
||||
println(f"==============================================")
|
||||
println(f"Day ${solver.day}%02d ---------------------------------------")
|
||||
println(f"Prep ${timings.prep}%38s μs")
|
||||
println(f"Part 1 ${solution.p1}%20s ${timings.p1}%15s μs")
|
||||
println(f"Part 2 ${solution.p2}%20s ${timings.p2}%15s μs")
|
||||
println(f"----------------------------------------------")
|
||||
|
||||
println(f"Total ${timings.total}%37s μs")
|
||||
|
||||
println(f"==============================================")
|
||||
println(f"=============================================================")
|
||||
println(
|
||||
f"Day ${solver.day}%02d ------------------------------------------------------"
|
||||
)
|
||||
println(f"Prep ${timings.prep}%53s μs")
|
||||
println(f"Part 1 ${solution.p1}%40s ${timings.p1}%10s μs")
|
||||
println(f"Part 2 ${solution.p2}%40s ${timings.p2}%10s μs")
|
||||
println(f"-------------------------------------------------------------")
|
||||
println(f"Total ${timings.total}%52s μs")
|
||||
println(f"=============================================================")
|
||||
|
||||
@main def main(day: String, input: String): Unit =
|
||||
val num = """(\d+)""".r
|
||||
|
||||
@@ -4,15 +4,8 @@ import scala.collection.mutable
|
||||
|
||||
object Memo:
|
||||
def Y[I, O](f: (I, I => O) => O): I => O =
|
||||
var yf: I => O = null
|
||||
yf = Memo(f(_, yf(_)))
|
||||
yf
|
||||
lazy val yf: I => O = Memo(f(_, yf(_))); yf
|
||||
|
||||
class Memo[-I, +O](f: I => O) extends (I => O):
|
||||
private[this] val memo = mutable.Map.empty[I, O]
|
||||
|
||||
def apply(i: I): O =
|
||||
if memo.contains(i) then memo(i)
|
||||
else {
|
||||
val o = f(i); memo(i) = o; o
|
||||
}
|
||||
def apply(i: I): O = { lazy val o = f(i); memo.getOrElseUpdate(i, o) }
|
||||
|
||||
@@ -3,6 +3,8 @@ package dev.ctsk.aoc.days
|
||||
import dev.ctsk.aoc.{Direction, *}
|
||||
|
||||
import scala.collection.mutable
|
||||
import scala.util.boundary
|
||||
import scala.util.boundary.break
|
||||
|
||||
object Day16 extends Solver(16):
|
||||
override def run(input_ : os.ReadablePath): (Timings, Solution) =
|
||||
@@ -14,28 +16,40 @@ object Day16 extends Solver(16):
|
||||
val end = grid.findFirst(_ == 'E').get
|
||||
|
||||
case class State(distance: Int, pose: Pose)
|
||||
implicit def ord: Ordering[State] = Ordering.by(-1 * _.distance)
|
||||
|
||||
Direction.Up.ordinal
|
||||
|
||||
def search(start: Pose): (Map[Pose, Int], Map[Pose, List[Pose]]) =
|
||||
val distance = mutable.Map(start -> 0)
|
||||
val ancestor = mutable.Map.empty[Pose, List[Pose]]
|
||||
val heap = mutable.PriorityQueue(State(0, start))
|
||||
var near = mutable.Stack(State(0, start))
|
||||
var far = mutable.Stack.empty[State]
|
||||
|
||||
inline def relax(u: Pose, v: Pose, vDist: Int): Unit =
|
||||
inline def relax(u: Pose, v: Pose, vDist: Int, isFar: Boolean): Unit =
|
||||
val oldDist = distance.getOrElse(v, 1_000_000)
|
||||
if vDist == oldDist then ancestor(v) +:= u
|
||||
if vDist < oldDist then
|
||||
ancestor(v) = List(u)
|
||||
distance(v) = vDist
|
||||
heap.enqueue(State(vDist, v))
|
||||
if isFar
|
||||
then far.push(State(vDist, v))
|
||||
else near.push(State(vDist, v))
|
||||
|
||||
while heap.nonEmpty do
|
||||
val State(uDist, u) = heap.dequeue()
|
||||
if uDist == distance(u) then
|
||||
if !grid(u.step.pos).contains('#') then relax(u, u.step, uDist + 1)
|
||||
for (v <- Seq(u.turnLeft, u.turnRight)) do relax(u, v, uDist + 1000)
|
||||
boundary:
|
||||
while near.nonEmpty do
|
||||
var atEnd = false;
|
||||
while near.nonEmpty do
|
||||
val State(uDist, u) = near.pop()
|
||||
atEnd |= u.pos == end
|
||||
if uDist == distance(u) then
|
||||
if !grid(u.step.pos).contains('#') then
|
||||
relax(u, u.step, uDist + 1, false)
|
||||
for (v <- Seq(u.turnLeft, u.turnRight)) do
|
||||
relax(u, v, uDist + 1000, true)
|
||||
|
||||
if atEnd then break()
|
||||
|
||||
val tmp = near
|
||||
near = far
|
||||
far = tmp
|
||||
|
||||
(distance.toMap, ancestor.toMap)
|
||||
|
||||
@@ -43,7 +57,7 @@ object Day16 extends Solver(16):
|
||||
search(Pose(start, Direction.Right))
|
||||
}
|
||||
|
||||
val endPose = DIRS.map(Pose(end, _)).minBy(distance(_))
|
||||
val endPose = DIRS.map(Pose(end, _)).minBy(distance.getOrElse(_, 1_000_000))
|
||||
|
||||
val p1 = distance(endPose)
|
||||
|
||||
@@ -51,7 +65,6 @@ object Day16 extends Solver(16):
|
||||
val all = mutable.Set(endPose)
|
||||
var cur = Set(endPose)
|
||||
|
||||
println(start)
|
||||
while cur.nonEmpty do
|
||||
cur = cur.filter(_ != Pose(start, Direction.Right)).flatMap(ancestor(_))
|
||||
all.addAll(cur)
|
||||
|
||||
@@ -2,38 +2,23 @@ package dev.ctsk.aoc.days
|
||||
|
||||
import dev.ctsk.aoc.*
|
||||
|
||||
import scala.util.boundary
|
||||
import scala.util.boundary.break
|
||||
|
||||
object Day19 extends Solver(19):
|
||||
|
||||
def pre(input: os.ReadablePath): (Trie, Seq[String]) =
|
||||
val Array(rules_, words_) = os.read(input).split("\n\n")
|
||||
val trie = Trie()
|
||||
for rule <- rules_.split(", ") do trie.insert(rule)
|
||||
(trie, words_.linesIterator.toSeq)
|
||||
|
||||
def part1(trie: Trie, words: Seq[String]): Int =
|
||||
def valid(word: String, inj: String => Boolean): Boolean =
|
||||
if word.isEmpty then return true
|
||||
boundary:
|
||||
for p <- trie.prefixes(word) do
|
||||
if inj(word.slice(p, word.length)) then break(true)
|
||||
false
|
||||
|
||||
words.count(Memo.Y(valid))
|
||||
|
||||
def part2(trie: Trie, words: Seq[String]): Long =
|
||||
def valid(word: String, inj: String => Long): Long =
|
||||
if word.isEmpty then return 1L
|
||||
trie.prefixes(word).map(p => inj(word.slice(p, word.length))).sum
|
||||
|
||||
words.map(Memo.Y(valid)).sum
|
||||
private def arrangements(trie: Trie, word: String): Long =
|
||||
def rec(offset: Int, inj: Int => Long): Long =
|
||||
if offset == word.length then return 1L
|
||||
trie.prefixes(word, offset).map(inj).sum
|
||||
Memo.Y(rec)(0)
|
||||
|
||||
override def run(input: os.ReadablePath): (Timings, Solution) =
|
||||
val (pre_time, (trie, words)) = timed { pre(input) }
|
||||
val (p1_time, p1) = timed { part1(trie, words) }
|
||||
val (p2_time, p2) = timed { part2(trie, words) }
|
||||
val (p1_time, p1) = timed { words.count(arrangements(trie, _) > 0) }
|
||||
val (p2_time, p2) = timed { words.map(arrangements(trie, _)).sum }
|
||||
|
||||
(
|
||||
Timings(pre_time, p1_time, p2_time),
|
||||
|
||||
41
aoc/src/dev/ctsk/aoc/days/Day20.scala
Normal file
41
aoc/src/dev/ctsk/aoc/days/Day20.scala
Normal file
@@ -0,0 +1,41 @@
|
||||
package dev.ctsk.aoc.days
|
||||
|
||||
import dev.ctsk.aoc.*
|
||||
|
||||
import collection.parallel.CollectionConverters.*
|
||||
|
||||
object Day20 extends Solver(20):
|
||||
override def run(input: os.ReadablePath): (Timings, Solution) =
|
||||
val grid = Grid(os.read.lines(input).map(_.toArray).toArray)
|
||||
val start = grid.findFirst(_ == 'S').get
|
||||
val end = grid.findFirst(_ == 'E').get
|
||||
|
||||
val trace = Iterator
|
||||
.unfold((end, end))((cur, prev) =>
|
||||
val n = DIRS.map(_(cur)).filter(_ != prev).find(!grid(_).contains('#'))
|
||||
n.map(nxt => (cur, (nxt, cur)))
|
||||
)
|
||||
.concat(Seq(start))
|
||||
.toArray
|
||||
|
||||
def cheats(radius: Int): Int =
|
||||
trace.indices.par
|
||||
.map(toDist =>
|
||||
(toDist + 100 until trace.length)
|
||||
.count(fromDist =>
|
||||
val from = trace(toDist)
|
||||
val to = trace(fromDist)
|
||||
val dist = (from - to).manhattan
|
||||
|
||||
dist <= radius && (fromDist - toDist >= 100 + dist)
|
||||
)
|
||||
)
|
||||
.sum
|
||||
|
||||
val p1 = timed { cheats(2) }
|
||||
val p2 = timed { cheats(20) }
|
||||
|
||||
(
|
||||
Timings(0, p1._1, p2._1),
|
||||
Solution(Int.box(p1._2), Int.box(p2._2))
|
||||
)
|
||||
48
aoc/src/dev/ctsk/aoc/days/Day21.scala
Normal file
48
aoc/src/dev/ctsk/aoc/days/Day21.scala
Normal file
@@ -0,0 +1,48 @@
|
||||
package dev.ctsk.aoc.days
|
||||
|
||||
import dev.ctsk.aoc.*
|
||||
|
||||
object Day21 extends Solver(21):
|
||||
private val keyPad = Grid(Array("789", "456", "123", " 0A").map(_.toArray))
|
||||
private val buttonPad = Grid(Array(" ^A", "<v>").map(_.toArray))
|
||||
|
||||
private val paths = Memo(paths_)
|
||||
private def paths_(args: (Char, Char, Grid[Char])): Array[Array[Char]] =
|
||||
val (from, to, grid) = args
|
||||
val Point(fx, fy) = grid.findFirst(_ == from).get
|
||||
val Point(tx, ty) = grid.findFirst(_ == to).get
|
||||
val ops = Seq((fx, tx, 'v'), (tx, fx, '^'), (fy, ty, '>'), (ty, fy, '<'))
|
||||
val seq = ops.flatMap((a, b, c) => (a until b).map(_ => c))
|
||||
|
||||
def gap(path: Array[Char]): Boolean =
|
||||
path
|
||||
.scanLeft(Point(fx, fy))((acc, c) => Direction.from(c)(acc))
|
||||
.exists(grid(_).contains(' '))
|
||||
|
||||
seq.permutations.map(_.toArray).filterNot(gap).toArray
|
||||
|
||||
private def countPresses(codes: Array[String], numRobots: Int): Long =
|
||||
type State = (Char, Char, Int)
|
||||
def minCost_(state: State, f: State => Long): Long =
|
||||
val (from, to, robots) = state
|
||||
if robots == 0 then return 1
|
||||
paths(from, to, if robots == numRobots then keyPad else buttonPad)
|
||||
.map('A' +: _ :+ 'A')
|
||||
.map(path => path.sliding(2).map(w => f(w(0), w(1), robots - 1)).sum)
|
||||
.min
|
||||
val minCost = Memo.Y(minCost_)
|
||||
|
||||
def evalCode(line: String): Long =
|
||||
('A' +: line).sliding(2).map(w => minCost(w(0), w(1), numRobots)).sum
|
||||
|
||||
codes.map(code => code.init.toInt * evalCode(code)).sum
|
||||
|
||||
override def run(input: os.ReadablePath): (Timings, Solution) =
|
||||
val codes = os.read.lines(input).toArray
|
||||
val (p1_time, p1_solution) = timed { countPresses(codes, 3) }
|
||||
val (p2_time, p2_solution) = timed { countPresses(codes, 26) }
|
||||
|
||||
(
|
||||
Timings(0, p1_time, p2_time),
|
||||
Solution(Long.box(p1_solution), Long.box(p2_solution))
|
||||
)
|
||||
60
aoc/src/dev/ctsk/aoc/days/Day22.scala
Normal file
60
aoc/src/dev/ctsk/aoc/days/Day22.scala
Normal file
@@ -0,0 +1,60 @@
|
||||
package dev.ctsk.aoc.days
|
||||
|
||||
import dev.ctsk.aoc.*
|
||||
import scala.collection.mutable
|
||||
|
||||
object Day22 extends Solver(22):
|
||||
inline def hash(n: Long): Long =
|
||||
var secret = n
|
||||
secret ^= (secret << 6)
|
||||
secret &= 0xffffff
|
||||
secret ^= (secret >> 5)
|
||||
secret &= 0xffffff
|
||||
secret ^= (secret << 11)
|
||||
secret &= 0xffffff
|
||||
secret
|
||||
|
||||
def hash(n: Long, count: Int): Long =
|
||||
Iterator.iterate(n)(hash).drop(count).next()
|
||||
|
||||
def part1(initial: Seq[Long]): Long = initial.map(hash(_, 2000)).sum
|
||||
|
||||
def part2(initial: Seq[Long]): Long =
|
||||
inline def update(hash: Int, next: Int): Int =
|
||||
((hash << 5) & 0xfffff) | (next + 10)
|
||||
|
||||
val maxHash = Seq(9, 9, 9, 9).fold(0)(update)
|
||||
val bananas = Array.fill(maxHash)(0)
|
||||
val seen = mutable.BitSet(maxHash)
|
||||
|
||||
initial.foreach { value =>
|
||||
seen.clear()
|
||||
val it = Iterator.iterate(value)(hash).map(_.toInt % 10)
|
||||
var last = it.next()
|
||||
var window = 0
|
||||
|
||||
for v <- it.take(3) do
|
||||
val diff = v - last
|
||||
last = v
|
||||
window = update(window, diff)
|
||||
|
||||
for v <- it.take(2000 - 3) do
|
||||
val diff = v - last
|
||||
last = v
|
||||
window = update(window, diff)
|
||||
if !seen(window) then
|
||||
seen += window
|
||||
bananas(window) += v
|
||||
}
|
||||
|
||||
bananas.max
|
||||
|
||||
override def run(input: os.ReadablePath): (Timings, Solution) =
|
||||
val initial = os.read.lines(input).map(_.toLong)
|
||||
val (p1_time, p1_solution) = timed { part1(initial) }
|
||||
val (p2_time, p2_solution) = timed { part2(initial) }
|
||||
|
||||
(
|
||||
Timings(0, p1_time, p2_time),
|
||||
Solution(Long.box(p1_solution), Long.box(p2_solution))
|
||||
)
|
||||
59
aoc/src/dev/ctsk/aoc/days/Day23.scala
Normal file
59
aoc/src/dev/ctsk/aoc/days/Day23.scala
Normal file
@@ -0,0 +1,59 @@
|
||||
package dev.ctsk.aoc.days
|
||||
|
||||
import dev.ctsk.aoc.*
|
||||
|
||||
object Day23 extends Solver(23):
|
||||
override def run(input: os.ReadablePath): (Timings, Solution) =
|
||||
val edge = "([^-]*)-([^-]*)".r
|
||||
|
||||
def id(s: String): Int = (s(0) - 'a') * 26 + (s(1) - 'a')
|
||||
|
||||
val (pre_time, graph) = timed {
|
||||
os.read
|
||||
.lines(input)
|
||||
.flatMap { case edge(from, to) => Seq((from, to), (to, from)) }
|
||||
.groupMap(_._1)(_._2)
|
||||
.view
|
||||
.mapValues(_.toSet)
|
||||
.toMap
|
||||
}
|
||||
|
||||
val (p1_time, triangles) = timed {
|
||||
(for
|
||||
(u, uOut) <- graph
|
||||
v <- uOut
|
||||
w <- graph(v).intersect(uOut)
|
||||
if Seq(u(0), v(0), w(0)).contains('t')
|
||||
yield Set(u, v, w)).toSet.size
|
||||
}
|
||||
|
||||
type Nodes = Set[String]
|
||||
def cliques(clique: Nodes, cand_ : Nodes, excl_ : Nodes): Set[Nodes] =
|
||||
if cand_.isEmpty && excl_.isEmpty then return Set(clique)
|
||||
if cand_.isEmpty then return Set.empty
|
||||
val pivot = cand_.maxBy(graph(_).size)
|
||||
|
||||
var candidates = cand_
|
||||
var excluded = excl_
|
||||
var acc = Set.empty[Set[String]]
|
||||
|
||||
for v <- cand_ -- graph(pivot)
|
||||
do
|
||||
acc ++= cliques(clique + v, candidates & graph(v), excluded & graph(v))
|
||||
candidates = candidates - v
|
||||
excluded = excluded + v
|
||||
|
||||
acc
|
||||
|
||||
val (p2_time, password) = timed {
|
||||
cliques(Set.empty, graph.keySet, Set.empty)
|
||||
.maxBy(_.size)
|
||||
.toArray
|
||||
.sorted
|
||||
.mkString(",")
|
||||
}
|
||||
|
||||
(
|
||||
Timings(pre_time, p1_time, p2_time),
|
||||
Solution(Int.box(triangles), password)
|
||||
)
|
||||
81
aoc/src/dev/ctsk/aoc/days/Day24.scala
Normal file
81
aoc/src/dev/ctsk/aoc/days/Day24.scala
Normal file
@@ -0,0 +1,81 @@
|
||||
package dev.ctsk.aoc.days
|
||||
|
||||
import dev.ctsk.aoc.*
|
||||
|
||||
import scala.collection.mutable
|
||||
|
||||
object Day24 extends Solver(24):
|
||||
extension (s: String)
|
||||
def binLong: Long = s.foldLeft(0L)((acc, c) => (acc << 1) + c.asDigit)
|
||||
|
||||
enum Op(val f: Int => Int => Int):
|
||||
case AND extends Op(x => y => x & y)
|
||||
case OR extends Op(x => y => x | y)
|
||||
case XOR extends Op(x => y => x ^ y)
|
||||
|
||||
case class Gate(op: Op, lhs: String, rhs: String)
|
||||
object Gate:
|
||||
def of(op: Op, lhs: String, rhs: String): Gate =
|
||||
Gate(op, Seq(lhs, rhs).min, Seq(lhs, rhs).max)
|
||||
|
||||
override def run(input: os.ReadablePath): (Timings, Solution) =
|
||||
val Array(inits_, wires_) = os.read(input).split("\n\n")
|
||||
|
||||
val inits = inits_.linesIterator
|
||||
.map(_.split(": "))
|
||||
.map { case Array(id, value) => (id, value.toInt) }
|
||||
.toMap
|
||||
|
||||
val wires = wires_.linesIterator
|
||||
.map(_.split(" "))
|
||||
.map { case Array(in1, op, in2, _, out) =>
|
||||
(out, Gate.of(Op.valueOf(op), in1, in2))
|
||||
}
|
||||
.toArray
|
||||
|
||||
val outs = wires.toMap
|
||||
val ins = mutable.Map.from(wires.map(_.swap))
|
||||
|
||||
def tag(t: Char)(i: Int): String = f"$t$i%02d"
|
||||
val x = tag('x'); val y = tag('y'); val z = tag('z')
|
||||
|
||||
def resolve_(id: String, f: String => Int): Int =
|
||||
outs.get(id) match
|
||||
case Some(gate) => gate.op.f(f(gate.lhs))(f(gate.rhs))
|
||||
case _ => inits(id)
|
||||
val resolve = Memo.Y(resolve_)
|
||||
|
||||
val p1 = timed { (0 to 45).reverse.map(z).map(resolve).mkString.binLong }
|
||||
|
||||
val p2 = timed {
|
||||
val renames = mutable.Map.empty[String, String]
|
||||
def rename(a: String, b: String): Unit =
|
||||
renames(a) = b
|
||||
renames(b) = a
|
||||
def re(a: String): String = renames.getOrElse(a, a)
|
||||
def lookup(gate: Gate): Option[String] =
|
||||
ins.get(Gate.of(gate.op, re(gate.lhs), re(gate.rhs)))
|
||||
|
||||
var carry = ins(Gate.of(Op.AND, x(0), y(0)))
|
||||
for i <- 1 to 44
|
||||
do
|
||||
val x_ = x(i)
|
||||
val y_ = y(i)
|
||||
val x_y_xor = lookup(Gate.of(Op.XOR, x_, y_)).get
|
||||
val x_y_and = lookup(Gate.of(Op.AND, x_, y_)).get
|
||||
val out = lookup(Gate.of(Op.XOR, x_y_xor, carry)) match
|
||||
case Some(out) => out
|
||||
case None =>
|
||||
rename(x_y_xor, x_y_and)
|
||||
lookup(Gate.of(Op.XOR, x_y_xor, carry)).get
|
||||
if out != z(i) then rename(out, z(i))
|
||||
val pre_carry = lookup(Gate.of(Op.AND, carry, x_y_xor)).get
|
||||
carry = lookup(Gate.of(Op.OR, pre_carry, x_y_and)).get
|
||||
|
||||
renames.keys.toArray.sorted.mkString(",")
|
||||
}
|
||||
|
||||
(
|
||||
Timings(0, p1._1, p2._1),
|
||||
Solution(Long.box(p1._2), p2._2)
|
||||
)
|
||||
35
aoc/src/dev/ctsk/aoc/days/Day25.scala
Normal file
35
aoc/src/dev/ctsk/aoc/days/Day25.scala
Normal file
@@ -0,0 +1,35 @@
|
||||
package dev.ctsk.aoc.days
|
||||
|
||||
import dev.ctsk.aoc.*
|
||||
import collection.parallel.CollectionConverters.*
|
||||
|
||||
object Day25 extends Solver(25):
|
||||
override def run(input: os.ReadablePath): (Timings, Solution) =
|
||||
val (pre_time, (locks, keys)) = timed {
|
||||
os
|
||||
.read(input)
|
||||
.split("\n\n")
|
||||
.map(_.linesIterator.map(_.toArray).toArray.transpose)
|
||||
.partition(_(0)(0) == '#')
|
||||
}
|
||||
|
||||
def profile(lock: Array[Array[Char]]): (Array[Int], Int) =
|
||||
(lock.map(_.count(_ == '#')), lock.head.length)
|
||||
|
||||
def fits(size: Int, lock: Array[Int], key: Array[Int]): Boolean =
|
||||
lock.zip(key).forall((l, k) => l + k <= size)
|
||||
|
||||
def p1 = timed {
|
||||
val keyProfiles = keys.map(profile)
|
||||
locks
|
||||
.map(profile)
|
||||
.map((lock, size) =>
|
||||
keyProfiles.count((key, _) => fits(size, lock, key))
|
||||
)
|
||||
.sum
|
||||
}
|
||||
|
||||
(
|
||||
Timings(pre_time, p1._1, 0),
|
||||
Solution(Int.box(p1._2), "MERRY CHRISTMAS")
|
||||
)
|
||||
2
data/20.ans
Normal file
2
data/20.ans
Normal file
@@ -0,0 +1,2 @@
|
||||
1445
|
||||
1008040
|
||||
141
data/20.in
Normal file
141
data/20.in
Normal file
@@ -0,0 +1,141 @@
|
||||
#############################################################################################################################################
|
||||
#.........................#...###...#...#...#.............#...#...#...#.......###...#...#...###...#.....###...#...........#...#.........#...#
|
||||
#.#######################.#.#.###.#.#.#.#.#.#.###########.#.#.#.#.#.#.#.#####.###.#.#.#.#.#.###.#.#.###.###.#.#.#########.#.#.#.#######.#.#.#
|
||||
#...#...#...............#.#.#.....#.#.#...#.#.....#.......#.#.#.#...#.#.....#.#...#.#.#...#...#.#.#...#.#...#...#.........#.#...#...#...#.#.#
|
||||
###.#.#.#.#############.#.#.#######.#.#####.#####.#.#######.#.#.#####.#####.#.#.###.#.#######.#.#.###.#.#.#######.#########.#####.#.#.###.#.#
|
||||
###...#.#.#.............#.#.......#.#.....#...#...#.....#...#...#.....#...#.#.#...#...#.......#.#...#.#.#.#.......#.........#...#.#...###.#.#
|
||||
#######.#.#.#############.#######.#.#####.###.#.#######.#.#######.#####.#.#.#.###.#####.#######.###.#.#.#.#.#######.#########.#.#.#######.#.#
|
||||
#...###...#...#...#.....#.#.......#.#...#.#...#.#.....#.#...#...#.....#.#...#...#.#...#...#...#.#...#.#.#.#.#.......#...#.....#...###...#.#.#
|
||||
#.#.#########.#.#.#.###.#.#.#######.#.#.#.#.###.#.###.#.###.#.#.#####.#.#######.#.#.#.###.#.#.#.#.###.#.#.#.#.#######.#.#.###########.#.#.#.#
|
||||
#.#.#...#.....#.#.#.#...#.#.......#.#.#.#.#.#...#...#...###...#...#...#.....#...#...#.#...#.#.#.#...#.#.#.#.#.#.......#.#.....#...#...#.#.#.#
|
||||
#.#.#.#.#.#####.#.#.#.###.#######.#.#.#.#.#.#.#####.#############.#.#######.#.#######.#.###.#.#.###.#.#.#.#.#.#.#######.#####.#.#.#.###.#.#.#
|
||||
#.#.#.#.#.......#...#...#...#.....#...#.#.#.#...#...#...#...#.....#...#.....#.#...#...#.#...#.#.#...#.#.#.#...#.......#...#...#.#.#...#...#.#
|
||||
#.#.#.#.###############.###.#.#########.#.#.###.#.###.#.#.#.#.#######.#.#####.#.#.#.###.#.###.#.#.###.#.#.###########.###.#.###.#.###.#####.#
|
||||
#.#.#.#.###...#...#.....#...#.........#.#.#.###.#.###.#.#.#.#.....#...#.....#.#.#.#...#.#...#...#...#.#.#.#...........###...###.#...#.#.....#
|
||||
#.#.#.#.###.#.#.#.#.#####.###########.#.#.#.###.#.###.#.#.#.#####.#.#######.#.#.#.###.#.###.#######.#.#.#.#.###################.###.#.#.#####
|
||||
#.#...#.#...#.#.#.#.....#.......#...#.#.#.#.#...#.#...#...#...###.#...###...#...#...#.#.#...#.......#.#...#...........#...###...#...#.#.#...#
|
||||
#.#####.#.###.#.#.#####.#######.#.#.#.#.#.#.#.###.#.#########.###.###.###.#########.#.#.#.###.#######.###############.#.#.###.###.###.#.#.#.#
|
||||
#.....#...#...#.#.....#.......#.#.#...#...#...#...#...#.....#...#...#...#.......#...#.#.#...#.....#...#...............#.#...#...#.#...#.#.#.#
|
||||
#####.#####.###.#####.#######.#.#.#############.#####.#.###.###.###.###.#######.#.###.#.###.#####.#.###.###############.###.###.#.#.###.#.#.#
|
||||
#...#.#...#...#.....#.........#.#.........#.....#.....#...#...#.###...#.#...#...#...#.#.###.#.....#...#.#.........#...#.#...#...#.#.#...#.#.#
|
||||
#.#.#.#.#.###.#####.###########.#########.#.#####.#######.###.#.#####.#.#.#.#.#####.#.#.###.#.#######.#.#.#######.#.#.#.#.###.###.#.#.###.#.#
|
||||
#.#.#...#...#.......#.........#.###...###.#.....#.....#...###...#...#.#.#.#.#.....#.#.#...#.#.#...#...#...#.......#.#.#.#.###...#.#.#.....#.#
|
||||
#.#.#######.#########.#######.#.###.#.###.#####.#####.#.#########.#.#.#.#.#.#####.#.#.###.#.#.#.#.#.#######.#######.#.#.#.#####.#.#.#######.#
|
||||
#.#...#...#...#...#...###.....#.....#.....#.....#...#.#.......###.#.#.#.#.#...###.#...#...#.#.#.#.#.#.......###...#.#.#.#.#...#.#...#...#...#
|
||||
#.###.#.#.###.#.#.#.#####.#################.#####.#.#.#######.###.#.#.#.#.###.###.#####.###.#.#.#.#.#.#########.#.#.#.#.#.#.#.#.#####.#.#.###
|
||||
#...#.#.#...#...#...###...#.........#.....#.#...#.#.#.#.......#...#.#.#.#...#...#.#.....###.#...#...#.....#...#.#.#.#.#.#.#.#.#...#...#...###
|
||||
###.#.#.###.###########.###.#######.#.###.#.#.#.#.#.#.#.#######.###.#.#.###.###.#.#.#######.#############.#.#.#.#.#.#.#.#.#.#.###.#.#########
|
||||
#...#.#.#...###.......#.....#...###...#...#...#.#.#.#.#...#...#...#.#.#.#...#...#.#...#...#.#...#...#.....#.#...#.#.#.#.#.#.#...#.#.#...#...#
|
||||
#.###.#.#.#####.#####.#######.#.#######.#######.#.#.#.###.#.#.###.#.#.#.#.###.###.###.#.#.#.#.#.#.#.#.#####.#####.#.#.#.#.#.###.#.#.#.#.#.#.#
|
||||
#...#.#.#.#...#.....#.#.......#.......#.#.......#.#...#...#.#...#.#.#.#.#...#.#...#...#.#.#...#...#.#.#...#.#.....#.#...#...#...#.#...#...#.#
|
||||
###.#.#.#.#.#.#####.#.#.#############.#.#.#######.#####.###.###.#.#.#.#.###.#.#.###.###.#.#########.#.#.#.#.#.#####.#########.###.#########.#
|
||||
#...#...#.#.#...#...#.#...........#...#.#.#...#...#.....###...#.#.#.#.#...#.#.#...#.#...#...#...#...#...#...#...#...#...#.....#...#.........#
|
||||
#.#######.#.###.#.###.###########.#.###.#.#.#.#.###.#########.#.#.#.#.###.#.#.###.#.#.#####.#.#.#.#############.#.###.#.#.#####.###.#########
|
||||
#...#...#...#...#...#.#.......#...#...#.#.#.#.#.#...#...#...#.#.#.#.#...#.#.#.###.#.#...#...#.#.#.....#.........#.#...#...#...#...#.#.......#
|
||||
###.#.#.#####.#####.#.#.#####.#.#####.#.#.#.#.#.#.###.#.#.#.#.#.#.#.###.#.#.#.###.#.###.#.###.#.#####.#.#########.#.#######.#.###.#.#.#####.#
|
||||
###...#.....#.#...#.#.#.....#.#.....#.#.#.#.#...#...#.#.#.#.#.#.#.#...#.#.#.#...#.#...#.#...#.#.#...#.#...........#...###...#.###.#.#.#.....#
|
||||
###########.#.#.#.#.#.#####.#.#####.#.#.#.#.#######.#.#.#.#.#.#.#.###.#.#.#.###.#.###.#.###.#.#.#.#.#.###############.###.###.###.#.#.#.#####
|
||||
#...........#...#...#.......#.....#.#.#.#.#...#.....#.#.#.#.#.#...#...#.#.#.#...#.###.#...#.#.#...#.#.#.............#...#...#.....#...#...###
|
||||
#.###############################.#.#.#.#.###.#.#####.#.#.#.#.#####.###.#.#.#.###.###.###.#.#.#####.#.#.###########.###.###.#############.###
|
||||
#.......#.....#...#.......#.....#.#.#...#...#.#.#...#.#.#.#.#...###...#.#.#.#...#...#.#...#.#.#.....#.#...#...#...#.....###.#...........#...#
|
||||
#######.#.###.#.#.#.#####.#.###.#.#.#######.#.#.#.#.#.#.#.#.###.#####.#.#.#.###.###.#.#.###.#.#.#####.###.#.#.#.#.#########.#.#########.###.#
|
||||
#.......#.###...#...###...#.#...#...###...#...#.#.#.#.#.#.#.#...#.....#.#.#...#...#.#.#...#...#...#...###...#...#...###...#.#.........#...#.#
|
||||
#.#######.#############.###.#.#########.#.#####.#.#.#.#.#.#.#.###.#####.#.###.###.#.#.###.#######.#.###############.###.#.#.#########.###.#.#
|
||||
#.........#...#...#...#.....#...........#.....#.#.#.#.#.#.#.#.###...#...#...#.###.#.#.#...#.......#.#...............#...#...#.......#...#.#.#
|
||||
###########.#.#.#.#.#.#######################.#.#.#.#.#.#.#.#.#####.#.#####.#.###.#.#.#.###.#######.#.###############.#######.#####.###.#.#.#
|
||||
###...#.....#...#...#.....#...................#.#.#.#.#.#.#...#.....#.....#.#.#...#.#...###...#.....#...............#.#.......#.....#...#.#.#
|
||||
###.#.#.#################.#.###################.#.#.#.#.#.#####.#########.#.#.#.###.#########.#.###################.#.#.#######.#####.###.#.#
|
||||
#...#.#.#...#...#.......#...#.......#.......#...#.#.#.#.#.....#...#...#...#.#.#...#.........#.#.#...........#.....#...#.......#.....#.###...#
|
||||
#.###.#.#.#.#.#.#.#####.#####.#####.#.#####.#.###.#.#.#.#####.###.#.#.#.###.#.###.#########.#.#.#.#########.#.###.###########.#####.#.#######
|
||||
#.#...#...#...#...#...#.......#...#...#.....#.....#.#.#.#...#.#...#.#.#...#...###...#.....#.#.#.#...#.....#.#.###.....#.....#...###.#...#...#
|
||||
#.#.###############.#.#########.#.#####.###########.#.#.#.#.#.#.###.#.###.#########.#.###.#.#.#.###.#.###.#.#.#######.#.###.###.###.###.#.#.#
|
||||
#.#...###...###...#.#.#.........#.......###...#...#...#...#...#.#...#...#.....#.....#.###...#...###...#...#...#...###...###...#...#...#...#.#
|
||||
#.###.###.#.###.#.#.#.#.###################.#.#.#.#############.#.#####.#####.#.#####.#################.#######.#.###########.###.###.#####.#
|
||||
#...#.....#.....#...#.#.............###...#.#...#...#...#.......#.....#...#...#.....#...#...###.......#.........#...........#...#...#.......#
|
||||
###.#################.#############.###.#.#.#######.#.#.#.###########.###.#.#######.###.#.#.###.#####.#####################.###.###.#########
|
||||
###.................#.............#...#.#...#...#...#.#.#...#...#...#.###.#.###...#...#...#...#.....#.#.................#...###...#...#.....#
|
||||
###################.#############.###.#.#####.#.#.###.#.###.#.#.#.#.#.###.#.###.#.###.#######.#####.#.#.###############.#.#######.###.#.###.#
|
||||
#...#...............#...........#.#...#.#.....#.#.....#...#...#...#...#...#.#...#.#...#.....#.#.....#.#...#...........#...###...#.....#.#...#
|
||||
#.#.#.###############.#########.#.#.###.#.#####.#########.#############.###.#.###.#.###.###.#.#.#####.###.#.#########.#######.#.#######.#.###
|
||||
#.#.#...#...#.......#.###.......#.#.....#.....#.....#...#.....###.......#...#...#.#...#...#...#.....#...#...#.....#...#.......#.........#...#
|
||||
#.#.###.#.#.#.#####.#.###.#######.###########.#####.#.#.#####.###.#######.#####.#.###.###.#########.###.#####.###.#.###.###################.#
|
||||
#.#.....#.#.#.#...#...#...#.....#.#.....#...#.#...#...#.......#...#.....#...###.#.###.....###...###...#.....#...#...###.#...............#...#
|
||||
#.#######.#.#.#.#.#####.###.###.#.#.###.#.#.#.#.#.#############.###.###.###.###.#.###########.#.#####.#####.###.#######.#.#############.#.###
|
||||
#.....#...#...#.#.#...#...#.#...#...###...#.#...#...#...#...###.....###.....#...#.....#...#...#.#...#.....#...#...#...#.#.............#...###
|
||||
#####.#.#######.#.#.#.###.#.#.#############.#######.#.#.#.#.#################.#######.#.#.#.###.#.#.#####.###.###.#.#.#.#############.#######
|
||||
#...#.#.#.......#...#.#...#.#.............#.........#.#.#.#.....#...#####...#.......#.#.#.#...#...#.......###.#...#.#...#.............#.....#
|
||||
#.#.#.#.#.###########.#.###.#############.###########.#.#.#####.#.#.#####.#.#######.#.#.#.###.###############.#.###.#####.#############.###.#
|
||||
#.#.#...#...........#.#.....###...........#.........#.#.#.#.....#.#...#...#.#.......#...#.....#...#.........#.#.....#...#.........###...#...#
|
||||
#.#.###############.#.#########.###########.#######.#.#.#.#.#####.###.#.###.#.#################.#.#.#######.#.#######.#.#########.###.###.###
|
||||
#.#.#.............#.#.#.......#...........#.#######...#...#.....#.#...#...#...#...#.....#.....#.#.#.#...#...#.....#...#.....#...#...#.#...###
|
||||
#.#.#.###########.#.#.#.#####.###########.#.###################.#.#.#####.#####.#.#.###.#.###.#.#.#.#.#.#.#######.#.#######.#.#.###.#.#.#####
|
||||
#.#.#...........#.#.#.#.....#.#...#######...#################E#...#.#...#.....#.#.#.#...#.#...#.#...#.#.#.......#.#.......#...#...#...#.....#
|
||||
#.#.###########.#.#.#.#####.#.#.#.###########################.#####.#.#.#####.#.#.#.#.###.#.###.#####.#.#######.#.#######.#######.#########.#
|
||||
#.#.........#...#...#.......#...#..S###############.....#####.#...#...#.#.....#.#...#.#...#.....###...#.....#...#.#...#...#.....#.........#.#
|
||||
#.#########.#.#####################################.###.#####.#.#.#####.#.#####.#####.#.###########.#######.#.###.#.#.#.###.###.#########.#.#
|
||||
#.........#...#.......#.....#...#...#...#####.......#...#####.#.#.....#.#.......#...#...#.....#...#.......#...###.#.#.#.....#...###...###...#
|
||||
#########.#####.#####.#.###.#.#.#.#.#.#.#####.#######.#######.#.#####.#.#########.#.#####.###.#.#.#######.#######.#.#.#######.#####.#.#######
|
||||
###...#...#...#.#.....#.#...#.#...#...#.....#.....#...###...#.#.#...#...#.....#...#...###...#...#...#...#...#...#...#.........#.....#.......#
|
||||
###.#.#.###.#.#.#.#####.#.###.#############.#####.#.#####.#.#.#.#.#.#####.###.#.#####.#####.#######.#.#.###.#.#.###############.###########.#
|
||||
#...#...#...#.#.#...#...#.#...#...........#...#...#.......#.#...#.#.#...#...#.#...#...#...#.......#.#.#.....#.#.#...###.......#.....#.......#
|
||||
#.#######.###.#.###.#.###.#.###.#########.###.#.###########.#####.#.#.#.###.#.###.#.###.#.#######.#.#.#######.#.#.#.###.#####.#####.#.#######
|
||||
#.........###...###...###...###.........#.....#.#...........#...#.#.#.#.....#.....#...#.#.......#.#.#.........#...#.....#.....#.....#...#...#
|
||||
#######################################.#######.#.###########.#.#.#.#.###############.#.#######.#.#.#####################.#####.#######.#.#.#
|
||||
#.............###...........###.........###...#.#.......###...#.#.#.#.............#...#.......#...#.#...................#.......#.....#...#.#
|
||||
#.###########.###.#########.###.###########.#.#.#######.###.###.#.#.#############.#.#########.#####.#.#################.#########.###.#####.#
|
||||
#.......#...#...#.#...#...#.....#...###.....#...#.....#...#.#...#.#.#.....###...#.#.....#...#.....#.#.................#.....#...#...#.......#
|
||||
#######.#.#.###.#.#.#.#.#.#######.#.###.#########.###.###.#.#.###.#.#.###.###.#.#.#####.#.#.#####.#.#################.#####.#.#.###.#########
|
||||
###...#...#.#...#...#...#.........#.....#.........###...#.#.#.....#.#...#.....#.#.#...#...#.......#.....#...........#...#...#.#...#.........#
|
||||
###.#.#####.#.###########################.#############.#.#.#######.###.#######.#.#.#.#################.#.#########.###.#.###.###.#########.#
|
||||
#...#.....#.#.#...#.....#...............#.........#...#...#...#.....###.#.....#.#.#.#.........#.......#...#...#...#.....#.....###...........#
|
||||
#.#######.#.#.#.#.#.###.#.#############.#########.#.#.#######.#.#######.#.###.#.#.#.#########.#.#####.#####.#.#.#.###########################
|
||||
#.#.....#.#.#.#.#.#...#.#.............#.#.........#.#...###...#.......#...###.#.#...#...#.....#.###...#.....#...#.......###.................#
|
||||
#.#.###.#.#.#.#.#.###.#.#############.#.#.#########.###.###.#########.#######.#.#####.#.#.#####.###.###.###############.###.###############.#
|
||||
#...#...#...#...#.....#.###...#...#...#.#.#.......#...#...#.....#.....###...#.#.#...#.#.#...#...#...#...#...............#...#...#...#...#...#
|
||||
#####.#################.###.#.#.#.#.###.#.#.#####.###.###.#####.#.#######.#.#.#.#.#.#.#.###.#.###.###.###.###############.###.#.#.#.#.#.#.###
|
||||
#.....#.....#...#.....#.....#...#...###...#.#.....###...#.###...#...#...#.#.#.#.#.#.#.#.###...###...#.###.........#...###.#...#...#.#.#.#...#
|
||||
#.#####.###.#.#.#.###.#####################.#.#########.#.###.#####.#.#.#.#.#.#.#.#.#.#.###########.#.###########.#.#.###.#.#######.#.#.###.#
|
||||
#...#...###.#.#.#.#...#...................#.#.....#.....#.....#.....#.#...#.#.#.#.#.#.#.....#.....#.#.#.........#.#.#.....#.......#...#...#.#
|
||||
###.#.#####.#.#.#.#.###.#################.#.#####.#.###########.#####.#####.#.#.#.#.#.#####.#.###.#.#.#.#######.#.#.#############.#######.#.#
|
||||
###...#.....#.#.#.#...#.#.................#.....#.#...........#.#...#...#...#.#.#.#...#.....#...#.#...#.......#...#.#.............#...###.#.#
|
||||
#######.#####.#.#.###.#.#.#####################.#.###########.#.#.#.###.#.###.#.#.#####.#######.#.###########.#####.#.#############.#.###.#.#
|
||||
#.......#...#.#...#...#.#.#.....#.......#...#...#...#...#.....#.#.#...#.#...#.#.#.....#...#...#.#.#...........#...#.#.........#.....#...#.#.#
|
||||
#.#######.#.#.#####.###.#.#.###.#.#####.#.#.#.#####.#.#.#.#####.#.###.#.###.#.#.#####.###.#.#.#.#.#.###########.#.#.#########.#.#######.#.#.#
|
||||
#...#...#.#...#.....#...#.#...#.#.#.....#.#.#.....#.#.#.#...#...#.#...#...#.#.#.#...#.#...#.#.#.#.#.............#...#.......#...#...#...#.#.#
|
||||
###.#.#.#.#####.#####.###.###.#.#.#.#####.#.#####.#.#.#.###.#.###.#.#####.#.#.#.#.#.#.#.###.#.#.#.###################.#####.#####.#.#.###.#.#
|
||||
###...#.#.....#.....#...#...#.#...#.#...#.#...#...#.#.#...#.#.#...#.....#.#...#.#.#...#...#.#.#.#.#...#.....#.......#.....#.#.....#.#.#...#.#
|
||||
#######.#####.#####.###.###.#.#####.#.#.#.###.#.###.#.###.#.#.#.#######.#.#####.#.#######.#.#.#.#.#.#.#.###.#.#####.#####.#.#.#####.#.#.###.#
|
||||
#.....#.......###...#...#...#.#.....#.#...#...#...#.#.#...#.#.#.....#...#...###.#.....#...#.#.#.#.#.#.#...#.#.....#...#...#.#.#...#...#.#...#
|
||||
#.###.###########.###.###.###.#.#####.#####.#####.#.#.#.###.#.#####.#.#####.###.#####.#.###.#.#.#.#.#.###.#.#####.###.#.###.#.#.#.#####.#.###
|
||||
#...#.###...#...#.#...###.....#.....#...###.....#.#...#...#.#.#...#.#...#...#...#.....#...#.#...#...#.#...#.#...#.#...#...#.#...#...#...#...#
|
||||
###.#.###.#.#.#.#.#.###############.###.#######.#.#######.#.#.#.#.#.###.#.###.###.#######.#.#########.#.###.#.#.#.#.#####.#.#######.#.#####.#
|
||||
#...#.....#...#...#...#.........###.#...#.......#...#.....#.#.#.#...#...#...#...#.#...#...#.......###...###.#.#...#.#.....#.....#...#...#...#
|
||||
#.###################.#.#######.###.#.###.#########.#.#####.#.#.#####.#####.###.#.#.#.#.#########.#########.#.#####.#.#########.#.#####.#.###
|
||||
#...#.....#.......#...#...#...#.....#.#...#...#.....#.#.....#.#...#...#.....#...#.#.#...#...#...#.......#...#.....#.#.#...#...#...#.....#...#
|
||||
###.#.###.#.#####.#.#####.#.#.#######.#.###.#.#.#####.#.#####.###.#.###.#####.###.#.#####.#.#.#.#######.#.#######.#.#.#.#.#.#.#####.#######.#
|
||||
#...#...#.#.#.....#...###...#.......#.#...#.#.#.....#...#.....#...#...#.....#...#.#.#...#.#.#.#...#...#.#.....#...#.#...#...#.....#.#.......#
|
||||
#.#####.#.#.#.#######.#############.#.###.#.#.#####.#####.#####.#####.#####.###.#.#.#.#.#.#.#.###.#.#.#.#####.#.###.#############.#.#.#######
|
||||
#...#...#...#...#.....#.......#...#.#.###.#.#.#...#.....#.#...#.#.....#...#.#...#.#.#.#...#.#...#.#.#.#...#...#...#...#.....#.....#...#...###
|
||||
###.#.#########.#.#####.#####.#.#.#.#.###.#.#.#.#.#####.#.#.#.#.#.#####.#.#.#.###.#.#.#####.###.#.#.#.###.#.#####.###.#.###.#.#########.#.###
|
||||
#...#...#.......#.....#.#...#...#.#.#.#...#.#.#.#.#.....#...#.#.#...#...#.#.#.#...#.#.....#.#...#...#.#...#.#.....#...#...#.#...#...#...#...#
|
||||
#.#####.#.###########.#.#.#.#####.#.#.#.###.#.#.#.#.#########.#.###.#.###.#.#.#.###.#####.#.#.#######.#.###.#.#####.#####.#.###.#.#.#.#####.#
|
||||
#...#...#.......#.....#...#.....#...#.#...#.#.#.#.#.......#...#...#...###...#.#...#.#.....#.#.......#.#.#...#.....#.....#.#...#...#...#...#.#
|
||||
###.#.#########.#.#############.#####.###.#.#.#.#.#######.#.#####.###########.###.#.#.#####.#######.#.#.#.#######.#####.#.###.#########.#.#.#
|
||||
#...#.#.........#...#...#.......#...#...#.#.#.#.#.#...#...#...#...#...........#...#.#.#...#.........#...#...#.....#.....#...#.#.......#.#.#.#
|
||||
#.###.#.###########.#.#.#.#######.#.###.#.#.#.#.#.#.#.#.#####.#.###.###########.###.#.#.#.#################.#.#####.#######.#.#.#####.#.#.#.#
|
||||
#.#...#.......#...#.#.#...#.......#.#...#.#.#.#.#...#.#...#...#...#.....#.....#.###.#...#.................#.#.....#.#...#...#.#.....#...#.#.#
|
||||
#.#.#########.#.#.#.#.#####.#######.#.###.#.#.#.#####.###.#.#####.#####.#.###.#.###.#####################.#.#####.#.#.#.#.###.#####.#####.#.#
|
||||
#.#.#...###...#.#.#.#...#...#.......#.###.#.#.#.#.....#...#.#...#.#.....#.#...#...#.....#.....#...#.....#.#.#.....#...#...#...#.....#...#.#.#
|
||||
#.#.#.#.###.###.#.#.###.#.###.#######.###.#.#.#.#.#####.###.#.#.#.#.#####.#.#####.#####.#.###.#.#.#.###.#.#.#.#############.###.#####.#.#.#.#
|
||||
#.#.#.#.....#...#...###...###.....#...#...#.#...#...#...###...#...#.#.....#.#.....#.....#...#.#.#.#.###...#.#.............#...#.......#.#...#
|
||||
#.#.#.#######.###################.#.###.###.#######.#.#############.#.#####.#.#####.#######.#.#.#.#.#######.#############.###.#########.#####
|
||||
#...#.....#...#...#...#...#.......#...#...#...#.....#...........#...#.#.....#.....#...#...#.#...#.#.....###.#...#...#.....###...........#...#
|
||||
#########.#.###.#.#.#.#.#.#.#########.###.###.#.###############.#.###.#.#########.###.#.#.#.#####.#####.###.#.#.#.#.#.###################.#.#
|
||||
#...#.....#.###.#...#...#...#...#...#.###.....#...#...#.....#...#.....#...#.......#...#.#.#...###.....#...#...#...#.#.....................#.#
|
||||
#.#.#.#####.###.#############.#.#.#.#.###########.#.#.#.###.#.###########.#.#######.###.#.###.#######.###.#########.#######################.#
|
||||
#.#.#.....#...#.#...#...#...#.#.#.#.#.........#...#.#.#...#.#.#...#...#...#.......#...#.#...#.......#...#.........#.#.......#...#.....#...#.#
|
||||
#.#.#####.###.#.#.#.#.#.#.#.#.#.#.#.#########.#.###.#.###.#.#.#.#.#.#.#.#########.###.#.###.#######.###.#########.#.#.#####.#.#.#.###.#.#.#.#
|
||||
#.#.......#...#.#.#.#.#.#.#.#.#.#.#...#...#...#...#.#.#...#.#.#.#...#...#...#...#.#...#...#...#...#...#.#.....#...#.#...#...#.#.#...#.#.#.#.#
|
||||
#.#########.###.#.#.#.#.#.#.#.#.#.###.#.#.#.#####.#.#.#.###.#.#.#########.#.#.#.#.#.#####.###.#.#.###.#.#.###.#.###.###.#.###.#.###.#.#.#.#.#
|
||||
#...........###...#...#...#...#...###...#...#####...#...###...#...........#...#...#.......###...#.....#...###...###.....#.....#.....#...#...#
|
||||
#############################################################################################################################################
|
||||
2
data/21.ans
Normal file
2
data/21.ans
Normal file
@@ -0,0 +1,2 @@
|
||||
202274
|
||||
245881705840972
|
||||
5
data/21.in
Normal file
5
data/21.in
Normal file
@@ -0,0 +1,5 @@
|
||||
319A
|
||||
670A
|
||||
349A
|
||||
964A
|
||||
586A
|
||||
2
data/22.ans
Normal file
2
data/22.ans
Normal file
@@ -0,0 +1,2 @@
|
||||
16894083306
|
||||
1925
|
||||
2002
data/22.in
Normal file
2002
data/22.in
Normal file
File diff suppressed because it is too large
Load Diff
2
data/23.ans
Normal file
2
data/23.ans
Normal file
@@ -0,0 +1,2 @@
|
||||
1064
|
||||
aq,cc,ea,gc,jo,od,pa,rg,rv,ub,ul,vr,yy
|
||||
3380
data/23.in
Normal file
3380
data/23.in
Normal file
File diff suppressed because it is too large
Load Diff
2
data/24.ans
Normal file
2
data/24.ans
Normal file
@@ -0,0 +1,2 @@
|
||||
51837135476040
|
||||
hjf,kdh,kpp,sgj,vss,z14,z31,z35
|
||||
313
data/24.in
Normal file
313
data/24.in
Normal file
@@ -0,0 +1,313 @@
|
||||
x00: 1
|
||||
x01: 0
|
||||
x02: 0
|
||||
x03: 1
|
||||
x04: 1
|
||||
x05: 1
|
||||
x06: 0
|
||||
x07: 0
|
||||
x08: 1
|
||||
x09: 1
|
||||
x10: 0
|
||||
x11: 1
|
||||
x12: 0
|
||||
x13: 0
|
||||
x14: 1
|
||||
x15: 1
|
||||
x16: 1
|
||||
x17: 1
|
||||
x18: 0
|
||||
x19: 0
|
||||
x20: 0
|
||||
x21: 0
|
||||
x22: 1
|
||||
x23: 1
|
||||
x24: 1
|
||||
x25: 1
|
||||
x26: 1
|
||||
x27: 1
|
||||
x28: 0
|
||||
x29: 1
|
||||
x30: 1
|
||||
x31: 0
|
||||
x32: 1
|
||||
x33: 0
|
||||
x34: 0
|
||||
x35: 0
|
||||
x36: 0
|
||||
x37: 1
|
||||
x38: 1
|
||||
x39: 0
|
||||
x40: 0
|
||||
x41: 0
|
||||
x42: 0
|
||||
x43: 1
|
||||
x44: 1
|
||||
y00: 1
|
||||
y01: 1
|
||||
y02: 1
|
||||
y03: 1
|
||||
y04: 0
|
||||
y05: 0
|
||||
y06: 0
|
||||
y07: 0
|
||||
y08: 0
|
||||
y09: 1
|
||||
y10: 0
|
||||
y11: 1
|
||||
y12: 0
|
||||
y13: 0
|
||||
y14: 1
|
||||
y15: 0
|
||||
y16: 0
|
||||
y17: 0
|
||||
y18: 0
|
||||
y19: 1
|
||||
y20: 0
|
||||
y21: 0
|
||||
y22: 0
|
||||
y23: 0
|
||||
y24: 0
|
||||
y25: 1
|
||||
y26: 1
|
||||
y27: 0
|
||||
y28: 1
|
||||
y29: 0
|
||||
y30: 1
|
||||
y31: 0
|
||||
y32: 1
|
||||
y33: 1
|
||||
y34: 0
|
||||
y35: 1
|
||||
y36: 1
|
||||
y37: 1
|
||||
y38: 0
|
||||
y39: 1
|
||||
y40: 0
|
||||
y41: 1
|
||||
y42: 1
|
||||
y43: 0
|
||||
y44: 1
|
||||
|
||||
x07 AND y07 -> ncs
|
||||
y24 AND x24 -> wrf
|
||||
x19 XOR y19 -> tsm
|
||||
x40 XOR y40 -> svt
|
||||
rjf OR src -> dfv
|
||||
fsf XOR fgs -> z44
|
||||
mhc AND jqd -> qgn
|
||||
nrr XOR sms -> kpp
|
||||
y20 AND x20 -> ngc
|
||||
y21 AND x21 -> hbc
|
||||
sgj OR ptb -> rqf
|
||||
hbc OR wdr -> gjn
|
||||
tks XOR sbg -> z23
|
||||
ddh AND tnm -> hgg
|
||||
hsf OR bjw -> vbb
|
||||
x15 XOR y15 -> vqs
|
||||
x10 AND y10 -> dtm
|
||||
vqs XOR vss -> z15
|
||||
x29 XOR y29 -> mgd
|
||||
srg OR cwb -> qtn
|
||||
nmb OR mbk -> z45
|
||||
dhs OR njq -> tng
|
||||
jfw OR jrf -> vpd
|
||||
x07 XOR y07 -> gck
|
||||
tdw XOR vrk -> z03
|
||||
y11 AND x11 -> ffw
|
||||
x16 XOR y16 -> bth
|
||||
x39 XOR y39 -> tnm
|
||||
cfg AND ngh -> jrq
|
||||
vpd AND mvn -> hbj
|
||||
rgp XOR bth -> z16
|
||||
qtn AND cjd -> vrv
|
||||
x14 AND y14 -> cgt
|
||||
dwh XOR hsk -> z24
|
||||
tgp XOR dkh -> z13
|
||||
y26 XOR x26 -> cfg
|
||||
cpc XOR nbm -> z42
|
||||
y42 XOR x42 -> cpc
|
||||
x17 XOR y17 -> cjd
|
||||
rqf XOR pqn -> z36
|
||||
x27 AND y27 -> nwg
|
||||
bcq AND hnk -> vjp
|
||||
tks AND sbg -> wqr
|
||||
wvr OR skq -> gmw
|
||||
cwm AND tpv -> pqw
|
||||
x41 AND y41 -> tqh
|
||||
jcw AND wpk -> sbr
|
||||
tgp AND dkh -> tbh
|
||||
wrg XOR nwq -> z38
|
||||
y32 XOR x32 -> gds
|
||||
bmn OR hbj -> msb
|
||||
wps XOR mtn -> z33
|
||||
ncs OR pjf -> sws
|
||||
wqr OR tqk -> dwh
|
||||
x31 AND y31 -> pwg
|
||||
y12 XOR x12 -> jcw
|
||||
nrr AND sms -> z31
|
||||
x38 AND y38 -> npd
|
||||
y02 AND x02 -> fwt
|
||||
y37 AND x37 -> rnc
|
||||
fwt OR vtm -> tdw
|
||||
x38 XOR y38 -> nwq
|
||||
gds AND ghr -> ckd
|
||||
ffw OR nfb -> wpk
|
||||
ctv XOR wht -> z05
|
||||
y11 XOR x11 -> cmg
|
||||
y05 XOR x05 -> ctv
|
||||
jhw XOR tcv -> z18
|
||||
wrf OR gnt -> rmw
|
||||
y01 AND x01 -> tnr
|
||||
x36 XOR y36 -> pqn
|
||||
gjq OR dfg -> skp
|
||||
x40 AND y40 -> ptg
|
||||
y39 AND x39 -> dqn
|
||||
bjb OR hjf -> sbg
|
||||
rrn OR rpt -> qfs
|
||||
ctv AND wht -> dhs
|
||||
sgs AND rsb -> ccw
|
||||
rmw XOR psg -> z25
|
||||
y24 XOR x24 -> hsk
|
||||
bgd XOR msb -> z10
|
||||
y17 AND x17 -> fvv
|
||||
y22 AND x22 -> kdh
|
||||
qfs AND rfv -> fgp
|
||||
wds AND fps -> rhr
|
||||
y18 XOR x18 -> tcv
|
||||
ttd AND nhg -> tfw
|
||||
bbc AND jkb -> ptb
|
||||
djn OR tnr -> cpb
|
||||
y35 XOR x35 -> bbc
|
||||
tfw OR cgt -> z14
|
||||
rgp AND bth -> srg
|
||||
dwh AND hsk -> gnt
|
||||
pqw OR ngc -> frt
|
||||
y25 XOR x25 -> psg
|
||||
y13 XOR x13 -> tgp
|
||||
x30 XOR y30 -> rbw
|
||||
vrv OR fvv -> jhw
|
||||
skp XOR mgd -> z29
|
||||
cmg XOR ntv -> z11
|
||||
vjr XOR vbb -> z04
|
||||
gkj XOR sws -> z08
|
||||
x20 XOR y20 -> tpv
|
||||
ntv AND cmg -> nfb
|
||||
x32 AND y32 -> tdk
|
||||
wmr AND cpb -> vtm
|
||||
x19 AND y19 -> jps
|
||||
jhw AND tcv -> rqv
|
||||
y27 XOR x27 -> bcq
|
||||
x34 AND y34 -> hdk
|
||||
wqc XOR qtf -> z01
|
||||
wgk OR sbr -> dkh
|
||||
x43 AND y43 -> kdb
|
||||
y04 XOR x04 -> vjr
|
||||
rmw AND psg -> fgg
|
||||
gkj AND sws -> jfw
|
||||
cwm XOR tpv -> z20
|
||||
cjd XOR qtn -> z17
|
||||
fsf AND fgs -> nmb
|
||||
wps AND mtn -> rpt
|
||||
x33 XOR y33 -> mtn
|
||||
bcq XOR hnk -> z27
|
||||
tbh OR wwk -> nhg
|
||||
twb XOR tsm -> z19
|
||||
frt AND mhw -> wdr
|
||||
y15 AND x15 -> pwr
|
||||
rbw XOR dfv -> z30
|
||||
vss AND vqs -> ctt
|
||||
x28 AND y28 -> gjq
|
||||
y28 XOR x28 -> dvf
|
||||
bbc XOR jkb -> sgj
|
||||
x43 XOR y43 -> fps
|
||||
y04 AND x04 -> khw
|
||||
pwg OR kpp -> ghr
|
||||
x31 XOR y31 -> nrr
|
||||
gmw XOR gck -> z07
|
||||
frt XOR mhw -> z21
|
||||
spb AND tng -> skq
|
||||
svt AND hkg -> knf
|
||||
gjn AND kdh -> bjb
|
||||
qfs XOR rfv -> z34
|
||||
cpc AND nbm -> jtt
|
||||
tqh OR ccw -> nbm
|
||||
jtt OR qkv -> wds
|
||||
gds XOR ghr -> z32
|
||||
rbw AND dfv -> qnv
|
||||
msb AND bgd -> gjr
|
||||
qnv OR bjd -> sms
|
||||
y18 AND x18 -> pns
|
||||
x41 XOR y41 -> rsb
|
||||
x26 AND y26 -> srh
|
||||
nvc OR npd -> ddh
|
||||
dtm OR gjr -> ntv
|
||||
x08 AND y08 -> jrf
|
||||
y14 XOR x14 -> ttd
|
||||
y06 AND x06 -> wvr
|
||||
y16 AND x16 -> cwb
|
||||
rnc OR qgn -> wrg
|
||||
y30 AND x30 -> bjd
|
||||
jqd XOR mhc -> z37
|
||||
ddh XOR tnm -> z39
|
||||
x12 AND y12 -> wgk
|
||||
cqh OR fgg -> ngh
|
||||
kdh XOR gjn -> z22
|
||||
x01 XOR y01 -> wqc
|
||||
khw OR djm -> wht
|
||||
ctt OR pwr -> rgp
|
||||
y21 XOR x21 -> mhw
|
||||
vjp OR nwg -> dhh
|
||||
x02 XOR y02 -> wmr
|
||||
gck AND gmw -> pjf
|
||||
rqv OR pns -> twb
|
||||
y00 AND x00 -> qtf
|
||||
y05 AND x05 -> njq
|
||||
y29 AND x29 -> rjf
|
||||
vrk AND tdw -> hsf
|
||||
y42 AND x42 -> qkv
|
||||
y10 XOR x10 -> bgd
|
||||
cfg XOR ngh -> z26
|
||||
tng XOR spb -> z06
|
||||
y00 XOR x00 -> z00
|
||||
cpb XOR wmr -> z02
|
||||
ckd OR tdk -> wps
|
||||
jrq OR srh -> hnk
|
||||
y22 XOR x22 -> hjf
|
||||
x03 AND y03 -> bjw
|
||||
nhg XOR ttd -> vss
|
||||
tsm AND twb -> rwg
|
||||
dqn OR hgg -> hkg
|
||||
y34 XOR x34 -> rfv
|
||||
y35 AND x35 -> z35
|
||||
x25 AND y25 -> cqh
|
||||
y33 AND x33 -> rrn
|
||||
wqc AND qtf -> djn
|
||||
sgs XOR rsb -> z41
|
||||
x08 XOR y08 -> gkj
|
||||
rwg OR jps -> cwm
|
||||
rqf AND pqn -> wbv
|
||||
x37 XOR y37 -> mhc
|
||||
dvf XOR dhh -> z28
|
||||
kdb OR rhr -> fgs
|
||||
knf OR ptg -> sgs
|
||||
svt XOR hkg -> z40
|
||||
y13 AND x13 -> wwk
|
||||
y23 AND x23 -> tqk
|
||||
fgp OR hdk -> jkb
|
||||
jcw XOR wpk -> z12
|
||||
y06 XOR x06 -> spb
|
||||
x23 XOR y23 -> tks
|
||||
y09 AND x09 -> bmn
|
||||
wds XOR fps -> z43
|
||||
dhh AND dvf -> dfg
|
||||
mgd AND skp -> src
|
||||
wrg AND nwq -> nvc
|
||||
y03 XOR x03 -> vrk
|
||||
y36 AND x36 -> kqk
|
||||
vjr AND vbb -> djm
|
||||
x44 XOR y44 -> fsf
|
||||
x44 AND y44 -> mbk
|
||||
kqk OR wbv -> jqd
|
||||
vpd XOR mvn -> z09
|
||||
y09 XOR x09 -> mvn
|
||||
1
data/25.ans
Normal file
1
data/25.ans
Normal file
@@ -0,0 +1 @@
|
||||
3395
|
||||
3999
data/25.in
Normal file
3999
data/25.in
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user