diff --git a/src/main/resources/eu/sim642/adventofcode2024/day12.txt b/src/main/resources/eu/sim642/adventofcode2024/day12.txt new file mode 100644 index 00000000..d0b3daa5 --- /dev/null +++ b/src/main/resources/eu/sim642/adventofcode2024/day12.txt @@ -0,0 +1,140 @@ +UUUUUUUUUUUUUUUUUUUDQQQQQQQOOOOOHHSSSSSYYYYYYYYGGGGNNNNNNNNTTTTTTTTTTTTTTDDDDDDDDDDDDDDDDDDNNNCCNJJJJOOHHHDDDDDDDDDDDDDDDDDDXXMBBBBMMCCCCCCC +UUUKUUUUUUUUUUUUUDDDDDDDQQQOOOOOOOOOSSSSSYYYYYYYYGGGGGNNNNTTTTTTTTTTTTTTTTTTTTDDDDDDIIDDDNNNNNCCNJJJOOOHDDDDDDDDDDXDDDDDDDMMMXMMMMMMMMCCCCCC +UUUKKUUUUUUWUUUUUUDDDDDDDDDROOOOOOOWWSSSSYYYYYYYGGGGGGGQNTTTTTTTTTTTTTTTTTTTTTDDDDDDDIDIINNNNLNNNNOOOOODDDDDDDDDDXXDDDDDDDMMMMMMMMMMMMCCCCCC +UUKKUUKKXUUUUUUUUDDDDDDDDDDDDOOOOOOOOYSSSSSYYYYYGGGGGGQQNNTTTTTTTTTTTTTTTTTTTTDDDDDIDIIIINNNNNNNNNNOOOODDDDDDDXDDXXDDDDDDDMMMMMMMMMMMMMMCCCC +UUKKUKKKXXUQQQQUUDDDDDDDDDDDDOOOOOOOOYYYYYYYYYYYGGGGGQQIINTTTTITTTTTTTTTTTTTTTTDDDIIIIIIIINNNNNNNNNOOODDDDDDDDXXXXXXDDDDDMMMMMMMMMMMMFFFFCCC +UKKKKKKKXKAWWWWWDDDDDDDDDDDDDOOOOUUOYYYYYYYYYYYYGGGGQQQQIIDITIIIITTTTTTTTTTTTTDDDDIIIIIIINNNNNNNNLLLLODDDDDDXXXXXXXXDXDDDMMMMMMMMMMMMFFFFCCC +KKKKKKKKKKKWWWWKDPPDDDDDDDWWWOOOOOUUYYYYYYYYYYYYYGR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PPPPXXXOOOOOOOOOUUGGGGGGGGGGGGIIIIIIIIIIIIHHIIHHHHHHHHHIIIIJJJHXXXXXXXWXFFFXXXXZZZZZZZZZZZVZZZZZZZYYYYEEEEEEHHHH +GGGGGGGGGGGAAAJJJJJNNNNNNNNNPPPXXXXOOXXOOOOOGGGGGGGGGGGGGGGGIIIIIIIIIIIHHHHHHHHHHHHHHHHHHHHHXXXXXXXXXFFFFXXZZZZZZZZZZZZZZZZZZZZZYYEEEEEHHHHH diff --git a/src/main/scala/eu/sim642/adventofcode2024/Day12.scala b/src/main/scala/eu/sim642/adventofcode2024/Day12.scala new file mode 100644 index 00000000..860b2bd8 --- /dev/null +++ b/src/main/scala/eu/sim642/adventofcode2024/Day12.scala @@ -0,0 +1,54 @@ +package eu.sim642.adventofcode2024 + +import eu.sim642.adventofcodelib.Grid +import eu.sim642.adventofcodelib.GridImplicits.* +import eu.sim642.adventofcodelib.box.Box +import eu.sim642.adventofcodelib.graph.{BFS, GraphComponents} +import eu.sim642.adventofcodelib.pos.Pos + +object Day12 { + + case class Region(poss: Set[Pos]) { + def area: Int = poss.size + + def perimeter: Int = { + 4 * area - + poss.iterator + .map(pos => Pos.axisOffsets.map(pos + _).count(poss)) //.tapEach(println) + .sum + } + } + + def regions(grid: Grid[Char]): Set[Region] = { + val graphComponents = new GraphComponents[Pos] { + override def nodes: IterableOnce[Pos] = Box(Pos.zero, Pos(grid(0).size - 1, grid.size - 1)).iterator + + override def unitNeighbors(pos: Pos): IterableOnce[Pos] = { + val region = grid(pos) + for { + offset <- Pos.axisOffsets + newPos = pos + offset + if grid.containsPos(newPos) + if grid(newPos) == region + } yield newPos + } + } + + BFS.components(graphComponents).map(x => Region(x.toSet)).toSet // TODO: avoid weird toSet-s + } + + def totalFencingPrice(grid: Grid[Char]): Int = { + val regs = regions(grid) + //for (region <- regs) + // println(s"${grid(region.poss.head)}: area=${region.area} perimeter=${region.perimeter}") + regs.iterator.map(region => region.area * region.perimeter).sum + } + + def parseGrid(input: String): Grid[Char] = input.linesIterator.map(_.toVector).toVector + + lazy val input: String = scala.io.Source.fromInputStream(getClass.getResourceAsStream("day12.txt")).mkString.trim + + def main(args: Array[String]): Unit = { + println(totalFencingPrice(parseGrid(input))) + } +} diff --git a/src/test/scala/eu/sim642/adventofcode2024/Day12Test.scala b/src/test/scala/eu/sim642/adventofcode2024/Day12Test.scala new file mode 100644 index 00000000..17204528 --- /dev/null +++ b/src/test/scala/eu/sim642/adventofcode2024/Day12Test.scala @@ -0,0 +1,42 @@ +package eu.sim642.adventofcode2024 + +import Day12._ +import org.scalatest.funsuite.AnyFunSuite + +class Day12Test extends AnyFunSuite { + + val exampleInput = + """AAAA + |BBCD + |BBCC + |EEEC""".stripMargin + + val exampleInput2 = + """OOOOO + |OXOXO + |OOOOO + |OXOXO + |OOOOO""".stripMargin + + val exampleInput3 = + """RRRRIICCFF + |RRRRIICCCF + |VVRRRCCFFF + |VVRCCCJFFF + |VVVVCJJCFE + |VVIVCCJJEE + |VVIIICJJEE + |MIIIIIJJEE + |MIIISIJEEE + |MMMISSJEEE""".stripMargin + + test("Part 1 examples") { + assert(totalFencingPrice(parseGrid(exampleInput)) == 140) + assert(totalFencingPrice(parseGrid(exampleInput2)) == 772) + assert(totalFencingPrice(parseGrid(exampleInput3)) == 1930) + } + + test("Part 1 input answer") { + assert(totalFencingPrice(parseGrid(input)) == 1433460) + } +}