28 lines
1.1 KiB
Text
28 lines
1.1 KiB
Text
with javascript_semantics
|
|
function af(string s) return max(s)<='f' and min(s)>='a' end function
|
|
function digital_root(integer n)
|
|
assert(n>=0)
|
|
while n>9 do
|
|
integer tot = 0
|
|
while n>0 do
|
|
tot += remainder(n,10)
|
|
n = floor(n/10)
|
|
end while
|
|
n = tot
|
|
end while
|
|
return n
|
|
end function
|
|
sequence words = filter(unix_dict(4),af),
|
|
decml = apply(true,to_integer,{words,0,16}),
|
|
roots = apply(decml,digital_root),
|
|
tags = custom_sort(roots,tagset(length(roots)))
|
|
|
|
function caejasp() -- columnize/apply/extract/join/apply/sprint(...)
|
|
sequence s = columnize(apply(true,extract,{{words,decml,roots},{tags}}))
|
|
return join(apply(true,sprintf,{{"%6s -> %8d -> %d\n"},s}))
|
|
end function
|
|
printf(1," %s\n %d hex words with 4 or more letters found,\n",{caejasp(),length(tags)})
|
|
function ge4(integer t) return length(unique(words[t]))>=4 end function
|
|
tags = filter(tags,ge4)
|
|
tags = extract(tags,reverse(custom_sort(extract(decml,tags),tagset(length(tags)))))
|
|
printf(1," %d with 4 or more distinct characters:\n\n %s\n",{length(tags),caejasp()})
|