diff options
| author | rir <rirans@comcast.net> | 2024-02-09 21:20:12 -0500 |
|---|---|---|
| committer | rir <rirans@comcast.net> | 2024-02-09 21:20:12 -0500 |
| commit | 138a757205ea1278fec6191eecdfa31b9d4fd3cc (patch) | |
| tree | 08d8157e2f400c51e90e1bc6fcdb34581decb9b9 /challenge-255/luca-ferrari/python/ch-2.python | |
| parent | 844af3cafa518e1f64f5a0729fcc69e1adfcba14 (diff) | |
| parent | 399287fcd1fa2800c9ab44b9a065116e9a55ec86 (diff) | |
| download | perlweeklychallenge-club-138a757205ea1278fec6191eecdfa31b9d4fd3cc.tar.gz perlweeklychallenge-club-138a757205ea1278fec6191eecdfa31b9d4fd3cc.tar.bz2 perlweeklychallenge-club-138a757205ea1278fec6191eecdfa31b9d4fd3cc.zip | |
Merge branch 'master' of https://github.com/manwar/perlweeklychallenge-club
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__': |
