20 lines
795 B
Text
20 lines
795 B
Text
F digroot(=n)
|
||
L n > 9
|
||
n = sum(String(n).map(d -> Int(d)))
|
||
R n
|
||
|
||
V lines = File(‘unixdict.txt’).read().split("\n")
|
||
V words = lines.filter(w -> w.len >= 4 & all(w.map(c -> c C ‘abcdef’)))
|
||
V results = words.map(w -> (w, Int(w, radix' 16), digroot(Int(w, radix' 16))))
|
||
|
||
print("Hex words in unixdict.txt:\nRoot Word Base 10\n "(‘-’ * 22))
|
||
L(a) sorted(results, key' x -> x[2])
|
||
print(f:‘{a[2]} {a[0]:<6}{a[1]:10}’)
|
||
|
||
print(‘Total count of these words: ’results.len)
|
||
print("\nHex words with > 3 distinct letters:\nRoot Word Base 10\n "(‘-’ * 22))
|
||
results = results.filter(a -> Set(Array(String(a[0]))).len > 3)
|
||
L(a) sorted(results, key' x -> x[2])
|
||
print(f:‘{a[2]} {a[0]:<6}{a[1]:10}’)
|
||
|
||
print(‘Total count of those words: ’results.len)
|