Hex words: Difference between revisions

Added 11l
m (→‎{{header|jq}}: letters)
(Added 11l)
Line 12:
Also filter out all such words which contain at least '''4''' distinct letters and display the same statistics but in decreasing order of decimal equivalent together with their total count.
<br><br>
 
=={{header|11l}}==
{{trans|Python}}
 
<lang 11l>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)</lang>
 
{{out}}
<pre>
Hex words in unixdict.txt:
Root Word Base 10
----------------------
1 ababa 703162
1 abbe 43966
1 dada 56026
1 deaf 57007
1 decade 14600926
2 cede 52958
2 feed 65261
3 abed 44013
3 added 712173
3 bade 47838
4 beebe 782014
4 decca 912586
5 dade 56030
6 bead 48813
6 deface 14613198
7 babe 47806
7 fade 64222
8 dead 57005
8 efface 15727310
8 facade 16435934
9 accede 11325150
9 beef 48879
9 cafe 51966
9 dacca 896202
9 deed 57069
9 face 64206
Total count of these words: 26
 
Hex words with > 3 distinct letters:
Root Word Base 10
----------------------
1 deaf 57007
1 decade 14600926
3 abed 44013
3 bade 47838
4 decca 912586
6 bead 48813
6 deface 14613198
7 fade 64222
8 efface 15727310
8 facade 16435934
9 accede 11325150
9 cafe 51966
9 face 64206
Total count of those words: 13
</pre>
 
=={{header|ALGOL 68}}==
Line 184 ⟶ 260:
Found 13 hex words with 4 or more distinct digits
</pre>
 
=={{header|AWK}}==
<lang AWK>
1,453

edits