Isograms and heterograms: Difference between revisions

→‎{{header|ALGOL 68}}: small tweaks to code and formatting
(→‎{{header|ALGOL 68}}: small tweaks to code and formatting)
Line 53:
# file opened OK #
BOOL at eof := FALSE;
# set the EOF handler for the file - notes eof has been reached and #
# have another word returns TRUE so processing can continue #
on logical file end( input file
on logical file end( input file, ( REF FILE f )BOOL: at eof := TRUE );
BEGIN # note that we reached EOF on the latest read #
# and return TRUE so processing can continue #
at eof := TRUE
END
);
 
# in-place quick sort an array of strings #
Line 129 ⟶ 124:
[ 1 : 2 000 ]STRING words;
INT w count := 0;
WHILE NOT at eof
DO
STRING word;
get( input file, ( word, newline ) );
IF NOT at eof THEN
DO
# have another word #
# have another word #
INT order = ORDER word;
IFINT order >= 0ORDER THENword;
IF order > 0 INT w length = LENGTH word;THEN
IF ( order = 1 ANDINT w length > 10 ) OR order >= 1LENGTH THENword;
IF ( order = 1 AND w length #> a10 long) heterogramOR ororder an> isogram1 #THEN
# a long heterogram or an isogram # store the word prefixed by the max abs char complement #
# ofstore the orderword andprefixed by the lengthmax soabs whenchar sorted,complement the wordsof #
# arethe orderedorder as requierd byand the task length so when sorted, the words are #
# ordered as requierd STRINGby sthe wordtask = REPR ( max abs char - order ) #
STRING s word += REPR ( max abs char - worder length )
+ REPR ( max +abs char - w length word;)
words[ w count +:= 1 ] := s + word;
FIwords[ w count +:= 1 ] := s word
FI
FI
Line 167 ⟶ 161:
print( ( newline, "heterograms longer than 10 characters" ) )
ELSE
print( ( newline, "isograms of order ", whole( order, 0 ) ) )
)
FI;
prev order := order;
3,048

edits