Module day04

Module day04 

Source
Expand description

§High-Entropy Passphrases

§Part One

We use a FastSet to detect duplicates. Sorting the words in each line then checking for duplicates in adjacent values also works but is slower.

§Part Two

To detect anagrams we first convert each word into a histogram of its letter frequency values. As the cardinality is at most 26 we can use a fixed size array to represent the set.

Then a FastSet is used to detect duplicates. Sorting the letters in each word so that anagrams become the same also works but is slower.

Functions§

letter_frequency 🔒
Convert a token to its letter frequency histogram. Only 26 elements are needed but 32 is faster to hash.
parse
part1
part2