[2017 Day 4] In Review (High-Entropy Passphrases)
Today we're back to doing some string validation. And it's not letter based, it's word based.
Part 1 basically is just making sure you know how to test for uniqueness/duplicates. Typically, that means a hash/dictionary/set thing. However, sometimes that's not an option. The words are up to 7 characters long so there are 26^7 possibilities, and dc arrays (which can often substitute for this as the GNU version did decide to go with "sparse"... just awfully implemented) only allow indexes up to 2^31 - 1. So for my dc solution, rather than build a hash table and handle collisions, I just double-nested loop compared. And with the size of the input, it runs instantly anyway on old hardware in a language that shouldn't be doing this job (I didn't even do early breaks because conditionals and multilevel breaking would just be a headache of stack management). There are only 512 lines and 4-10 words on each.
Part 2 just tests if you can work out the "trick" to comparing if things are anagrams. Which is to sort the letters. Not exactly an amazingly hard problem today, but it is only day 4. It might seem like a step down from day 3... and sure enough, December 4, 2017 was a Monday.
Posted Mar 4, 2026, 7:12 AM UTC