All SolutionsAll Solutions
🪙
Crypto Wallet Password
Week 28, 2026
Looping all the way deep | greenya | Odin Solutions
package main
import "core:fmt"
import "core:os"
import "core:strings"
SEED_WORDS_TXT := #load("bip39-seed-words.txt", string)
RESULT_FILENAME :: "result.txt"
TARGET_LEN :: 12
TARGET_WORD :: "zoo"
main :: proc () {
words := strings.split_lines(SEED_WORDS_TXT)
defer delete(words)
fmt.printfln("There are %d words", len(words))
fmt.printfln("Target length is %d", TARGET_LEN)
fmt.printfln("Target word is `%s`", TARGET_WORD)
f, err := os.open(RESULT_FILENAME, { .Write })
defer os.close(f)
assert(err == nil)
total_trios_of_target_len: int
for w1 in words {
trio_len := len(w1)
trio_has_target_word := w1 == TARGET_WORD
if trio_len < TARGET_LEN do for w2 in words {
trio_len += len(w2)
trio_has_target_word ||= w2 == TARGET_WORD
if trio_len < TARGET_LEN do for w3 in words {
trio_len += len(w3)
trio_has_target_word ||= w3 == TARGET_WORD
if trio_len == TARGET_LEN {
total_trios_of_target_len += 1
if trio_has_target_word do fmt.fprintln(f, w1, w2, w3, sep="")
}
trio_has_target_word = w1 == TARGET_WORD || w2 == TARGET_WORD
trio_len -= len(w3)
}
trio_has_target_word = w1 == TARGET_WORD
trio_len -= len(w2)
}
}
fmt.printfln("There are %d trios of the target length", total_trios_of_target_len)
}
Python - Maths & FOR-Loops | BMC | Python Solutions
'''
== 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()