diff options
Diffstat (limited to 'challenge-287/luca-ferrari/python')
| -rw-r--r-- | challenge-287/luca-ferrari/python/ch-1.py | 25 | ||||
| -rw-r--r-- | challenge-287/luca-ferrari/python/ch-2.py | 22 |
2 files changed, 47 insertions, 0 deletions
diff --git a/challenge-287/luca-ferrari/python/ch-1.py b/challenge-287/luca-ferrari/python/ch-1.py new file mode 100644 index 0000000000..2fbe66f7b9 --- /dev/null +++ b/challenge-287/luca-ferrari/python/ch-1.py @@ -0,0 +1,25 @@ +#!python + +# +# Perl Weekly Challenge 287 +# Task 1 +# +# See <https://perlweeklychallenge.org/blog/perl-weekly-challenge-287> +# + +import sys +import re + +# task implementation +# the return value will be printed +def task_1( args ): + password = args[ 0 ] + lc = re.compile( '[a-z]' ) + uc = re.compile( '[A-Z]' ) + dg = re.compile( '[0-9]' ) + wrong = re.compile( '(.)\\1\\1' ) + return lc.search( password ) and uc.search( password ) and dg.search( password ) and wrong.search( password ) is None + +# invoke the main without the command itself +if __name__ == '__main__': + print( task_1( sys.argv[ 1: ] ) ) diff --git a/challenge-287/luca-ferrari/python/ch-2.py b/challenge-287/luca-ferrari/python/ch-2.py new file mode 100644 index 0000000000..d76523ff39 --- /dev/null +++ b/challenge-287/luca-ferrari/python/ch-2.py @@ -0,0 +1,22 @@ +#!python + +# +# Perl Weekly Challenge 287 +# Task 2 +# +# See <https://perlweeklychallenge.org/blog/perl-weekly-challenge-287> +# + +import sys +import re + +# task implementation +# the return value will be printed +def task_2( args ): + number = args[ 0 ] + good = re.compile( '^[+-]?\\d+([.]\\d+)?(E[+-]?\\d+)?$' ) + return good.match( number ) is not None + +# invoke the main without the command itself +if __name__ == '__main__': + print( task_2( sys.argv[ 1: ] ) ) |
