🪙
Crypto Wallet Password
Week 28
You have found an old hard drive containing a crypto wallet you made many years ago - you remember you chose the shortest possible allowed password which was 12 characters which you made by choosing 3 words from the generated seed phrase when your wallet was created
Note that your wallet's seed/recovery phrase - like many cryptocurrencies - are generated from the words in the BIP39 word list (BIP = Bitcoin Improvement Proposal)
Desperate to try and access your wallet, you initially decide to create a program to generate every 12 character combination of 3 valid words from the seed word list - you run the program, but after minutes of execution, you wonder whether this program will finish executing in any reasonable time. You therefore want to calculate the total number of unique 12 character passwords that can be made from 3 words to determine whether this approach is feasible - note that order matters - i.e. "WishTopPrize" != "PrizeTopWish". You should type the number of unique 3-word, 12 character passwords below, since it's the first answer of this two-part challenge:
After some hard thinking, you remember one of the words in your password was "zoo" - you don't remember what position this came in, but that will at least make your search quicker - you should output all the 12 character, 3-word passwords containing "zoo" on a new line (after your answer to part 1, you realise the answer might be quite large...hence it might be better to write the answer to a file, rather than the terminal (where you might hit buffer limits & copying/pasting into the browser textarea might cause the page to become unresponsive))
For example, your answer should be formatted like this - the order of passwords or capitalisation (the words below are capitalised purely for readibility) doesn't matter, since the site will convert all answers to lowercase and sort them lines when you click submit anyway
A reminder, if you are completely stuck, hints will be released after 24 hours :)
Click to upload or drag & drop text file here...
Hints
Hints will be released at the start of each of the following days - e.g. the start of day 3 is 48 hours after the challenge starts
| Release Day | Hint |
|---|---|
| 2 | It might be useful to use a data structure (object/hashmap/dictionary/associative array - whatever your language calls them) to map word lengths to an array of words of that length - of course you will have to read the words from the file into this structure. There are also no 2-letter words in the list, hence you can ignore any words of more than 6 characters, since when combined with 2 other words, that will create a string of more than 12 character |
| 3 | A simple approach is to create 3 nested loops representing the word lengths for word 1, word 2 and word 3 - in each loop, you can loop from 3 to 6 (i.e. valid word lengths to possibly make a 12 letter password) - and check if the variables wordlength1 + wordlength2 + wordlength3 = 12 - if it does, get the word count for each of these word lengths and multiply them together (due to the "rule of product" in combinatorics - i.e. we have n choices for word 1, n2 choices for word 2 etc |
| 4 | In terms of outputting all passwords with "zoo" as one of the words, a simple, but not particularly efficient approach is to check that at least 1 of the word lengths equals 3 from within your combined length equals 12 check above - if it does, then you will want to loop through all words of that length (e.g. w1 = 3, w2 = 5, w3 = 4 - outer loop loops through all 3 letter words, inner loop loops through all 5 letter words, innermost loop loops through 4 letter words) - if any of the words = "zoo", then you can output it. In the case where only 1 word length = 3, then you could make a more efficient solution by only looping over the other 2 words, since you know the single 3 letter word can only be zoo |