diff options
| author | Luca Ferrari <fluca1978@gmail.com> | 2024-02-05 08:15:45 +0100 |
|---|---|---|
| committer | Luca Ferrari <fluca1978@gmail.com> | 2024-02-05 10:50:22 +0100 |
| commit | 7ae41852c28f903f5821561705eba50147c9c6e4 (patch) | |
| tree | 04e002a28a40f0c90decf80589db836d56f304ae /challenge-255/luca-ferrari/python/ch-2.python | |
| parent | d58258463850d2949fe13a4097a83a5d17951548 (diff) | |
| download | perlweeklychallenge-club-7ae41852c28f903f5821561705eba50147c9c6e4.tar.gz perlweeklychallenge-club-7ae41852c28f903f5821561705eba50147c9c6e4.tar.bz2 perlweeklychallenge-club-7ae41852c28f903f5821561705eba50147c9c6e4.zip | |
PWC 255
Task 1 Raku done
Task 2 Raku done
Task 1 PL/Perl done
Task 2 PL/perl done
Task 1 PL/PgSQL done
Task 2 PL/PgSQL done
Task 1 Python done
Task 2 Python done
Task 1 PL/Java done
Task 2 PL/Java done
Diffstat (limited to 'challenge-255/luca-ferrari/python/ch-2.python')
| -rw-r--r-- | challenge-255/luca-ferrari/python/ch-2.python | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/challenge-255/luca-ferrari/python/ch-2.python b/challenge-255/luca-ferrari/python/ch-2.python index dc37e2ad93..6493199950 100644 --- a/challenge-255/luca-ferrari/python/ch-2.python +++ b/challenge-255/luca-ferrari/python/ch-2.python @@ -1,7 +1,7 @@ #!python # -# Perl Weekly Challenge 254 +# Perl Weekly Challenge 255 # Task 2 # # See <https://perlweeklychallenge.org/blog/perl-weekly-challenge-254> @@ -12,17 +12,16 @@ import sys # task implementation # the return value will be printed def task_2( args ): - word = args[ 0 ].lower() - vowels = list( reversed( list( filter( lambda x: x in ('a','e','i','o','u'), word ) ) ) ) - output = '' - for letter in word: - if letter not in ( 'a', 'e', 'i', 'o', 'u' ) or len( vowels ) == 0 - output += letter - else: - output += vowels.pop( 0 ) - - return output + paragraph = args[ 0 ] + banned = args[ 1 ] + classification = {} + for w in paragraph.split(): + if w != banned: + if not w in classification: + classification[ w ] = 0 + classification[ w ] += 1 + return sorted( classification.items() )[ -1 ][ 0 ] # invoke the main without the command itself if __name__ == '__main__': |
