Jump to content

Isograms and heterograms: Difference between revisions

Added Perl
m (slightly emphasize the syntactic (or "type") difference between less than (x < y) and unbox (> y))
(Added Perl)
Line 313:
valedictory 11
voluntarism 11
</pre>
 
=={{header|Perl}}==
<lang perl>use strict;
use warnings;
use feature 'say';
use Path::Tiny;
use List::Util 'uniq';
 
my @words = map { lc } path('ref/unixdict.txt')->slurp =~ /^[A-z]{2,}$/gm;
 
my(@heterogram, %isogram);
for my $w (@words) {
my %l;
$l{$_}++ for split '', $w;
next unless 1 == scalar (my @x = uniq values %l);
if ($x[0] == 1) { push @heterogram, $w if length $w > 10 }
else { push @{$isogram{$x[0]}}, $w }
}
 
for my $n (reverse sort keys %isogram) {
my @i = sort { length $b <=> length $a } @{$isogram{$n}};
say scalar @i . " $n-isograms:\n" . join("\n", @i) . "\n";
}
 
say scalar(@heterogram) . " heterograms with 10 or more characters:\n" . join "\n", sort { length $b <=> length $a } @heterogram;</lang>
{{out}}
<pre style="height:40ex">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 10 or more characters:
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>
 
2,392

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.