1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
//! # Day 21: Fractal Art
//!
//! You find a program trying to generate some art. It uses a strange process that involves
//! repeatedly enhancing the detail of an image through a set of rules.
//!
//! The image consists of a two-dimensional square grid of pixels that are either on (`#`) or off
//! (`.`). The program always begins with this pattern:
//!
//! ```txt
//! .#.
//! ..#
//! ###
//! ```
//!
//! Because the pattern is both `3` pixels wide and `3` pixels tall, it is said to have a **size**
//! of `3`.
//!
//! Then, the program repeats the following process:
//!
//! - If the size is evenly divisible by `2`, break the pixels up into `2x2` squares, and convert
//! each `2x2` square into a `3x3` square by following the corresponding **enhancement rule**.
//! - Otherwise, the size is evenly divisible by `3`; break the pixels up into `3x3` squares, and
//! convert each `3x3` square into a `4x4` square by following the corresponding **enhancement
//! rule**.
//!
//! Because each square of pixels is replaced by a larger one, the image gains pixels and so its
//! **size** increases.
//!
//! The artist's book of enhancement rules is nearby (your puzzle input); however, it seems to be
//! missing rules. The artist explains that sometimes, one must **rotate** or **flip** the input
//! pattern to find a match. (Never rotate or flip the output pattern, though.) Each pattern is
//! written concisely: rows are listed as single units, ordered top-down, and separated by slashes.
//! For example, the following rules correspond to the adjacent patterns:
//!
//! ```txt
//! ../.# = ..
//! .#
//!
//! .#.
//! .#./..#/### = ..#
//! ###
//!
//! #..#
//! #..#/..../#..#/.##. = ....
//! #..#
//! .##.
//! ```
//!
//! When searching for a rule to use, rotate and flip the pattern as necessary. For example, all of
//! the following patterns match the same rule:
//!
//! ```txt
//! .#. .#. #.. ###
//! ..# #.. #.# ..#
//! ### ### ##. .#.
//! ```
//!
//! Suppose the book contained the following two rules:
//!
//! ```txt
//! ../.# => ##./#../...
//! .#./..#/### => #..#/..../..../#..#
//! ```
//!
//! As before, the program begins with this pattern:
//!
//! ```txt
//! .#.
//! ..#
//! ###
//! ```
//!
//! The size of the grid (`3`) is not divisible by `2`, but it is divisible by `3`. It divides
//! evenly into a single square; the square matches the second rule, which produces:
//!
//! ```txt
//! #..#
//! ....
//! ....
//! #..#
//! ```
//!
//! The size of this enhanced grid (`4`) is evenly divisible by `2`, so that rule is used. It
//! divides evenly into four squares:
//!
//! ```txt
//! #.|.#
//! ..|..
//! --+--
//! ..|..
//! #.|.#
//! ```
//!
//! Each of these squares matches the same rule (`../.# => ##./#../...`), three of which require
//! some flipping and rotation to line up with the rule. The output for the rule is the same in all
//! four cases:
//!
//! ```txt
//! ##.|##.
//! #..|#..
//! ...|...
//! ---+---
//! ##.|##.
//! #..|#..
//! ...|...
//! ```
//!
//! Finally, the squares are joined into a new grid:
//!
//! ```txt
//! ##.##.
//! #..#..
//! ......
//! ##.##.
//! #..#..
//! ......
//! ```
//!
//! Thus, after `2` iterations, the grid contains `12` pixels that are on.
//!
//! **How many pixels stay on** after `5` iterations?
use anyhow::Result;
pub const INPUT: &str = include_str!("d21.txt");
pub fn solve_part_one(input: &str) -> Result<i64> {
Ok(0)
}
pub fn solve_part_two(input: &str) -> Result<i64> {
Ok(0)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn part_one() {}
#[test]
fn part_two() {}
}