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
//! # Day 14: Disk Defragmentation
//!
//! Suddenly, a scheduled job activates the system's [disk defragmenter]. Were the situation
//! different, you might [sit and watch it for a while], but today, you just don't have that kind of
//! time. It's soaking up valuable system resources that are needed elsewhere, and so the only
//! option is to help it finish its task as soon as possible.
//!
//! The disk in question consists of a 128x128 grid; each square of the grid is either **free** or
//! **used**. On this disk, the state of the grid is tracked by the bits in a sequence of
//! [knot hashes].
//!
//! A total of 128 knot hashes are calculated, each corresponding to a single row in the grid; each
//! hash contains 128 bits which correspond to individual grid squares. Each bit of a hash indicates
//! whether that square is **free** (`0`) or **used** (`1`).
//!
//! The hash inputs are a key string (your puzzle input), a dash, and a number from `0` to `127`
//! corresponding to the row. For example, if your key string were `flqrgnkx`, then the first row
//! would be given by the bits of the knot hash of `flqrgnkx-0`, the second row from the bits of the
//! knot hash of `flqrgnkx-1`, and so on until the last row, `flqrgnkx-127`.
//!
//! The output of a knot hash is traditionally represented by 32 hexadecimal digits; each of these
//! digits correspond to 4 bits, for a total of `4 * 32 = 128` bits. To convert to bits, turn each
//! hexadecimal digit to its equivalent binary value, high-bit first: `0` becomes `0000`, `1`
//! becomes `0001`, `e` becomes `1110`, `f` becomes `1111`, and so on; a hash that begins with
//! `a0c2017...` in hexadecimal would begin with `10100000110000100000000101110000...` in binary.
//!
//! Continuing this process, the **first 8 rows and columns** for key `flqrgnkx` appear as follows,
//! using `#` to denote used squares, and `.` to denote free ones:
//!
//! ```txt
//! ##.#.#..-->
//! .#.#.#.#
//! ....#.#.
//! #.#.##.#
//! .##.#...
//! ##..#..#
//! .#...#..
//! ##.#.##.-->
//! | |
//! V V
//! ```
//!
//! In this example, `8108` squares are used across the entire 128x128 grid.
//!
//! Given your actual key string, **how many squares are used**?
//!
//! [disk defragmenter]: https://en.wikipedia.org/wiki/Defragmentation
//! [sit and watch it for a while]: https://www.youtube.com/watch?v=kPv1gQ5Rs8A&t=37
//! [knot hashes]: super::d10
use anyhow::Result;
pub const INPUT: &str = include_str!("d14.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() {}
}