Function advent_solutions::advent2017::day14::part1 [] [src]

pub fn part1<'a, I, J>(hashes: I) -> u32 where
    I: IntoIterator<Item = J>,
    J: IntoIterator<Item = &'a u8>, 

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:

##.#.#..-->
.#.#.#.#
....#.#.
#.#.##.#
.##.#...
##..#..#
.#...#..
##.#.##.-->
|      |
V      V

In this example, 8108 squares are used across the entire 128x128 grid.

let hashes = make_hashes("flqrgnkx");
assert_eq!(part1(&hashes), 8108);

Given your actual key string, how many squares are used?