Find words which contain the most consonants: Difference between revisions

Added XPL0 example.
m (→‎{{header|R}}: Syntax highlighting.)
(Added XPL0 example.)
Line 2,517:
3 words found with 4 unique consonants:
audiovisual bourgeoisie onomatopoeia
</pre>
 
=={{header|XPL0}}==
<lang XPL0>string 0; \use zero-terminated strings
int MaxCon, Con, Set, I, Ch;
char Word(25), MaxWord(25);
def LF=$0A, CR=$0D, EOF=$1A;
[FSet(FOpen("unixdict.txt", 0), ^I);
OpenI(3);
MaxCon:= 0;
repeat I:= 0; Con:= 0; Set:= 0;
loop [repeat Ch:= ChIn(3) until Ch # CR; \remove possible CR
if Ch=LF or Ch=EOF then quit;
Word(I):= Ch;
I:= I+1;
case Ch of ^a,^e,^i,^o,^u: [] \assume lowercase words
other [Con:= Con+1; \count constant
if Set & 1<<(Ch-^a) then Con:= 0; \reject if not unique
Set:= Set ! 1<<(Ch-^a);
];
];
Word(I):= 0; \terminate string
if Con > MaxCon then \save Word with maximum
[MaxCon:= Con; \ constants
CopyMem(MaxWord, Word, 25);
];
until Ch = EOF;
Text(0, MaxWord);
]</lang>
 
{{out}}
<pre>
comprehensible
</pre>
772

edits