Changeable words: Difference between revisions
Content deleted Content added
Alextretyak (talk | contribs) Added 11l |
→{{header|Ruby}}: Add Ruby |
||
Line 1,633:
</pre>
=={{header|Ruby}}==
<lang ruby>words = File.open("unixdict.txt").readlines.map(&:chomp).select{|w| w.size > 11 }
size_groups = words.group_by(&:size).sort.map(&:last)
res = size_groups.flat_map do |group|
group.combination(2).select{|word1, word2| word1.chars.zip(word2.chars).one?{|c1, c2| c1 != c2} }
end
puts "Found #{res.size} changeable word pairs:"
res.each{|w1, w2|puts "#{w1} - #{w2}" }
</lang>
{{out}}
<pre>Found 26 changeable word pairs:
aristotelean - aristotelian
committeeman - committeemen
confirmation - conformation
councilwoman - councilwomen
craftsperson - draftsperson
eavesdropped - eavesdropper
frontiersman - frontiersmen
incommutable - incomputable
installation - instillation
kaleidescope - kaleidoscope
neuroanatomy - neuroanotomy
newspaperman - newspapermen
nonagenarian - nonogenarian
onomatopoeia - onomatopoeic
philanthrope - philanthropy
prescription - proscription
spectroscope - spectroscopy
complementary - complimentary
congresswoman - congresswomen
schizophrenia - schizophrenic
shakespearean - shakespearian
underclassman - underclassmen
upperclassman - upperclassmen
claustrophobia - claustrophobic
committeewoman - committeewomen
handicraftsman - handicraftsmen
</pre>
=={{header|Sidef}}==
{{trans|Perl}}
|