diff options
| author | 冯昶 <fengchang@novel-supertv.com> | 2024-02-06 10:57:00 +0800 |
|---|---|---|
| committer | 冯昶 <fengchang@novel-supertv.com> | 2024-02-06 10:57:00 +0800 |
| commit | 1bf81c8cd7a349e23f5cea03031f16d11af36f83 (patch) | |
| tree | adde1cb7a839ec7f3691bfc4bfd494636ed2503e /challenge-254/luca-ferrari/python | |
| parent | 409a0635fc8d10d342a7b6dd72c1c23a2c0702e0 (diff) | |
| parent | cde7d521095de2ce582570f6d8d1a9e7bbcec16c (diff) | |
| download | perlweeklychallenge-club-1bf81c8cd7a349e23f5cea03031f16d11af36f83.tar.gz perlweeklychallenge-club-1bf81c8cd7a349e23f5cea03031f16d11af36f83.tar.bz2 perlweeklychallenge-club-1bf81c8cd7a349e23f5cea03031f16d11af36f83.zip | |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'challenge-254/luca-ferrari/python')
| -rw-r--r-- | challenge-254/luca-ferrari/python/ch-1.python | 26 | ||||
| -rw-r--r-- | challenge-254/luca-ferrari/python/ch-2.python | 29 |
2 files changed, 55 insertions, 0 deletions
diff --git a/challenge-254/luca-ferrari/python/ch-1.python b/challenge-254/luca-ferrari/python/ch-1.python new file mode 100644 index 0000000000..a0533551d8 --- /dev/null +++ b/challenge-254/luca-ferrari/python/ch-1.python @@ -0,0 +1,26 @@ +#!python + +# +# Perl Weekly Challenge 254 +# Task 1 +# +# See <https://perlweeklychallenge.org/blog/perl-weekly-challenge-254> +# + +import sys +import math + +# task implementation +# the return value will be printed +def task_1( args ): + num = int( args[ 0 ] ) + for i in range( 2, int( math.sqrt( num ) ) ): + if ( i ** 3 ) == num: + return True + + return False + + +# invoke the main without the command itself +if __name__ == '__main__': + print( task_1( sys.argv[ 1: ] ) ) diff --git a/challenge-254/luca-ferrari/python/ch-2.python b/challenge-254/luca-ferrari/python/ch-2.python new file mode 100644 index 0000000000..dc37e2ad93 --- /dev/null +++ b/challenge-254/luca-ferrari/python/ch-2.python @@ -0,0 +1,29 @@ +#!python + +# +# Perl Weekly Challenge 254 +# Task 2 +# +# See <https://perlweeklychallenge.org/blog/perl-weekly-challenge-254> +# + +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 + + +# invoke the main without the command itself +if __name__ == '__main__': + print( task_2( sys.argv[ 1: ] ) ) |
