[Python] Python - Maths & FOR-Loops[Python] Python - Maths & FOR-Loops

🪙

Crypto Wallet Password

Week 28, 2026

''' == FIRST PART == Value Count 3 103 4 442 5 555 6 508 7 352 ] X - No combination can result in Length=12 8 88 ] X - No combination can result in Length=12 all possible sums: 3 + 3 + 6 3 + 4 + 5 3 + 5 + 4 3 + 6 + 3 4 + 3 + 5 4 + 4 + 4 4 + 5 + 3 5 + 3 + 4 5 + 4 + 3 6 + 3 + 3 Final answer (multiply above values) = 254_120_584 However, this doesn't actually work since the words need tobe UNIQUE. Therefore, repeated words of same length need to be deducted. So, the answer becomes: 253_378_404 ^^^^ NOTE (After Submission): Mr. P wanted the original answer (254_120_584), I don't understand why he would mention: " You should type the number of unique 3-word, 12 character passwords below..." ''' def firstPart() -> None: file = open("bip39-seed-words.txt", 'r') seed_words = [line.rstrip() for line in file] seed_words.sort(key=len) lengths = [len(x) for x in seed_words] lengths2 = set(lengths) lenDict = {x: lengths.count(x) for x in lengths2} ans = 0 for x in lengths2: for y in lengths2: for z in lengths2: a, b, c = lenDict[x], lenDict[y], lenDict[z] # if x == y: b -= 1 # if y == z: c -= 1 # if x == z: c -= 1 if (x + y + z) == 12: ans += (a * b * c) print("First Part Answer = ", ans) file.close() def secondPart() -> None: file = open("bip39-seed-words.txt", 'r') seed_words = [line.rstrip() for line in file] file_write = open("ans.txt", 'w') # ------------------------------------------ (> O <) does anyone even read these? remove_list = [] for seed in seed_words: # remove x, where len(x) > 6 if len(seed) > 6: remove_list.append(seed) for seed in remove_list: seed_words.remove(seed) guess = "zoo" seed_words.sort(key=len) _3 = [x for x in seed_words if len(x) == 3] _4 = [x for x in seed_words if len(x) == 4] _5 = [x for x in seed_words if len(x) == 5] _6 = [x for x in seed_words if len(x) == 6] len_dict = {3: _3, 4: _4, 5: _5, 6: _6} valid_len_combos = [ [3, 3, 6], [3, 6, 3], [6, 3, 3], [3, 4, 5], [3, 5, 4], [4, 3, 5], [4, 5, 3], [5, 3, 4], [5, 4, 3], [4, 4, 4], ] for l1, l2, l3 in valid_len_combos: if guess not in (0,) and 3 not in (l1, l2, l3): continue # no length-3 slot means "zoo" can never appear here for word1 in len_dict[l1]: for word2 in len_dict[l2]: for word3 in len_dict[l3]: if guess in (word1, word2, word3): file_write.write(f"{word1}{word2}{word3}" + '\n') file.close() file_write.close() print("== DONE ==") # main firstPart() secondPart()