aboutsummaryrefslogtreecommitdiff
path: root/challenge-210/spadacciniweb/python
diff options
context:
space:
mode:
authorMariano Spadaccini <spadacciniweb@gmail.com>2023-03-30 18:55:26 +0200
committerMariano Spadaccini <spadacciniweb@gmail.com>2023-03-30 18:55:26 +0200
commita07ac0ca20938228084ca317d1961365373ded29 (patch)
tree49e6ce9ab8e1f971f245eb366bee157869bd8445 /challenge-210/spadacciniweb/python
parent8915a66de2cb2a724aee5e55ddfc15580cfdf1d5 (diff)
downloadperlweeklychallenge-club-a07ac0ca20938228084ca317d1961365373ded29.tar.gz
perlweeklychallenge-club-a07ac0ca20938228084ca317d1961365373ded29.tar.bz2
perlweeklychallenge-club-a07ac0ca20938228084ca317d1961365373ded29.zip
PWC-210
Diffstat (limited to 'challenge-210/spadacciniweb/python')
-rw-r--r--challenge-210/spadacciniweb/python/ch-1.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/challenge-210/spadacciniweb/python/ch-1.py b/challenge-210/spadacciniweb/python/ch-1.py
new file mode 100644
index 0000000000..6503dc43ea
--- /dev/null
+++ b/challenge-210/spadacciniweb/python/ch-1.py
@@ -0,0 +1,33 @@
+# Task 1: Kill and Win
+# Submitted by: Mohammad S Anwar
+#
+# You are given a list of integers.
+#
+# Write a script to get the maximum points. You are allowed to take out (kill) any integer and remove from the list. However if you do that then all integers exactly one-less or one-more would also be removed. Find out the total of integers removed.
+#
+# Example 1
+# Input: @int = (2, 3, 1)
+# Output: 6
+#
+# First we delete 2 and that would also delete 1 and 3. So the maximum points we get is 6.
+#
+# Example 2
+# Input: @int = (1, 1, 2, 2, 2, 3)
+# Output: 11
+#
+# First we delete 2 and that would also delete both the 1's and the 3. Now we have (2, 2).
+# Then we delete another 2 and followed by the third deletion of 2. So the maximum points we get is 11.
+
+import re
+import sys
+
+if __name__ == "__main__":
+ input = sys.argv[1:]
+ if (len(input) < 1
+ or
+ len(list(filter(lambda x: re.search(r'\D', x), input))) != 0):
+ sys.exit("Input error\n")
+
+ input = list(map(int, input))
+ print(sum(input))
+