aboutsummaryrefslogtreecommitdiff
path: root/challenge-277/luca-ferrari/python/ch-2.py
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-277/luca-ferrari/python/ch-2.py')
-rw-r--r--challenge-277/luca-ferrari/python/ch-2.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/challenge-277/luca-ferrari/python/ch-2.py b/challenge-277/luca-ferrari/python/ch-2.py
new file mode 100644
index 0000000000..1b420ab4b7
--- /dev/null
+++ b/challenge-277/luca-ferrari/python/ch-2.py
@@ -0,0 +1,21 @@
+import sys
+
+# task implementation
+# the return value will be printed
+def task_2( args ):
+ nums = list( map( int, args ) )
+
+ strong = []
+
+ for i in range( 0, len( nums ) - 1 ):
+ for j in range( i + 1, len( nums ) ):
+ if nums[ i ] != nums[ j ] and abs( nums[ i ] - nums[ j ] ) < min( nums[ i ], nums[ j ] ):
+ strong.append( str( nums[ i ] ) + "<->" + str( nums[ j ] ) )
+
+ return len( strong )
+
+
+# invoke the main without the command itself
+if __name__ == '__main__':
+ print( task_2( sys.argv[ 1: ] ) )
+