Isograms and heterograms: Difference between revisions
Content added Content deleted
(Added AppleScript.) |
(→{{header|Ruby}}: Add Ruby) |
||
Line 1,111: | Line 1,111: | ||
valedictory |
valedictory |
||
voluntarism</pre> |
voluntarism</pre> |
||
=={{header|Ruby}}== |
|||
Blameworthy exclusionary lexicography causes unixdict.txt to make it incomputable if the word isogram is itself an isogram. |
|||
<syntaxhighlight lang="ruby" line>words = File.readlines("unixdict.txt", chomp: true) |
|||
isograms = words.group_by do |word| |
|||
char_counts = word.downcase.chars.tally.values |
|||
char_counts.first if char_counts.uniq.size == 1 |
|||
end |
|||
isograms.delete(nil) |
|||
isograms.transform_values!{|ar| ar.sort_by{|word| [-word.size, word]} } |
|||
keys = isograms.keys.sort.reverse |
|||
keys.each{|k| puts "(#{isograms[k].size}) #{k}-isograms: #{isograms[k]} " if k > 1 } |
|||
min_chars = 10 |
|||
large_heterograms = isograms[1].select{|word| word.size > min_chars } |
|||
puts "" , "(#{large_heterograms.size}) heterograms with more then #{min_chars} chars:" |
|||
puts large_heterograms |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre>(2) 3-isograms: ["aaa", "iii"] |
|||
(31) 2-isograms: ["beriberi", "bilabial", "caucasus", "couscous", "teammate", "appall", "emmett", "hannah", "murmur", "tartar", "testes", "anna", "coco", "dada", "deed", "dodo", "gogo", "isis", "juju", "lulu", "mimi", "noon", "otto", "papa", "peep", "poop", "teet", "tete", "toot", "tutu", "ii"] |
|||
(32) heterograms with more then 10 chars: |
|||
ambidextrous |
|||
bluestocking |
|||
exclusionary |
|||
incomputable |
|||
lexicography |
|||
loudspeaking |
|||
malnourished |
|||
atmospheric |
|||
blameworthy |
|||
centrifugal |
|||
christendom |
|||
consumptive |
|||
countervail |
|||
countryside |
|||
countrywide |
|||
disturbance |
|||
documentary |
|||
earthmoving |
|||
exculpatory |
|||
geophysical |
|||
inscrutable |
|||
misanthrope |
|||
problematic |
|||
selfadjoint |
|||
stenography |
|||
sulfonamide |
|||
switchblade |
|||
switchboard |
|||
switzerland |
|||
thunderclap |
|||
valedictory |
|||
voluntarism |
|||
</pre> |
|||
=={{header|Wren}}== |
=={{header|Wren}}== |