Hex words: Difference between revisions

Content added Content deleted
(Added Lua version)
(Add APL)
Line 260: Line 260:
Found 13 hex words with 4 or more distinct digits
Found 13 hex words with 4 or more distinct digits
</pre>
</pre>

=={{header|APL}}==
{{works with|Dyalog APL}}
<syntaxhighlight lang="apl">∇HexWords;todec;digroot;displayrow;words;distinct4
todec←16⊥9+'abcdef'∘⍳
digroot←(+/10⊥⍣¯1⊢)⍣(10≥⊢)
displayrow←{⍵ n (digroot⊢n←todec ⍵)}

words←((~∊)∘⎕TC⊆⊢)⊃⎕NGET'I:\unixdict.txt'
words←(words∧.∊¨⊂⊂'abcdef')/words
words←(4≤≢¨words)/words
words←words[⍋digroot∘todec¨words]

distinct4←(4≤≢∘∪¨words)/words
distinct4←distinct4[⍒todec¨distinct4]

⎕←(⍕≢words),' hex words with at least 4 letters in unixdict.txt:'
⎕←↑displayrow¨words
⎕←''

⎕←(⍕≢distinct4),' hex words with at least 4 distinct letters:'
⎕←↑displayrow¨distinct4
∇</syntaxhighlight>
{{out}}
<pre>26 hex words with at least 4 letters in unixdict.txt:
ababa 703162 1
abbe 43966 1
dada 56026 1
deaf 57007 1
decade 14600926 1
cede 52958 2
feed 65261 2
abed 44013 3
added 712173 3
bade 47838 3
beebe 782014 4
decca 912586 4
dade 56030 5
bead 48813 6
deface 14613198 6
babe 47806 7
fade 64222 7
dead 57005 8
efface 15727310 8
facade 16435934 8
accede 11325150 9
beef 48879 9
cafe 51966 9
dacca 896202 9
deed 57069 9
face 64206 9

13 hex words with at least 4 distinct letters:
facade 16435934 8
efface 15727310 8
deface 14613198 6
decade 14600926 1
accede 11325150 9
decca 912586 4
fade 64222 7
face 64206 9
deaf 57007 1
cafe 51966 9
bead 48813 6
bade 47838 3
abed 44013 3</pre>


=={{header|AppleScript}}==
=={{header|AppleScript}}==