aboutsummaryrefslogtreecommitdiff
path: root/challenge-143/paulo-custodio/python
diff options
context:
space:
mode:
authorPaulo Custodio <pauloscustodio@gmail.com>2021-12-13 16:19:32 +0000
committerPaulo Custodio <pauloscustodio@gmail.com>2021-12-13 16:19:32 +0000
commit8d4cd3c68f9bf9ec693fedf996ac00bb499e22e4 (patch)
tree0431a5d153051d8ef0f6a4a8082378e4a84284b2 /challenge-143/paulo-custodio/python
parenta7ce07821aad2cde7884ec1c6e2e9ea145787107 (diff)
downloadperlweeklychallenge-club-8d4cd3c68f9bf9ec693fedf996ac00bb499e22e4.tar.gz
perlweeklychallenge-club-8d4cd3c68f9bf9ec693fedf996ac00bb499e22e4.tar.bz2
perlweeklychallenge-club-8d4cd3c68f9bf9ec693fedf996ac00bb499e22e4.zip
whitespace
Diffstat (limited to 'challenge-143/paulo-custodio/python')
-rw-r--r--challenge-143/paulo-custodio/python/ch-1.py6
-rw-r--r--challenge-143/paulo-custodio/python/ch-2.py30
2 files changed, 18 insertions, 18 deletions
diff --git a/challenge-143/paulo-custodio/python/ch-1.py b/challenge-143/paulo-custodio/python/ch-1.py
index a81c52fd0e..7705a4eafe 100644
--- a/challenge-143/paulo-custodio/python/ch-1.py
+++ b/challenge-143/paulo-custodio/python/ch-1.py
@@ -3,10 +3,10 @@
# TASK #1 > Calculator
# Submitted by: Mohammad S Anwar
# You are given a string, $s, containing mathematical expression.
-#
+#
# Write a script to print the result of the mathematical expression. To keep
# it simple, please only accept + - * ().
-#
+#
# Example 1:
# Input: $s = "10 + 20 - 5"
# Output: 25
@@ -46,7 +46,7 @@ def factor(input):
value -= b
else:
return input, value
-
+
def term(input):
input = input.strip()+" "
match = re.match(r"[-+]?\d+", input)
diff --git a/challenge-143/paulo-custodio/python/ch-2.py b/challenge-143/paulo-custodio/python/ch-2.py
index 3d1976d3f0..850ebfac33 100644
--- a/challenge-143/paulo-custodio/python/ch-2.py
+++ b/challenge-143/paulo-custodio/python/ch-2.py
@@ -3,40 +3,40 @@
# TASK #2 > Stealthy Number
# Submitted by: Mohammad S Anwar
# You are given a positive number, $n.
-#
+#
# Write a script to find out if the given number is Stealthy Number.
-#
+#
# A positive integer N is stealthy, if there exist positive integers a, b, c, d
# such that a * b = c * d = N and a + b = c + d + 1.
-#
+#
# Example 1
# Input: $n = 36
# Output: 1
-#
+#
# Since 36 = 4 (a) * 9 (b) = 6 (c) * 6 (d) and 4 (a) + 9 (b) = 6 (c) + 6 (d) + 1.
# Example 2
# Input: $n = 12
# Output: 1
-#
+#
# Since 2 * 6 = 3 * 4 and 2 + 6 = 3 + 4 + 1
# Example 3
# Input: $n = 6
# Output: 0
-#
+#
# Since 2 * 3 = 1 * 6 but 2 + 3 != 1 + 6 + 1
import sys
def is_stealthy(n):
- for a in range(1, n+1):
- if n%a==0:
- b = n/a # a*b=n
- for c in range(1, n+1):
- if n%c==0:
- d = n/c # c*d=n
- if a+b==c+d+1:
- return 1
- return 0
+ for a in range(1, n+1):
+ if n%a==0:
+ b = n/a # a*b=n
+ for c in range(1, n+1):
+ if n%c==0:
+ d = n/c # c*d=n
+ if a+b==c+d+1:
+ return 1
+ return 0
n = int(sys.argv[1])
print(is_stealthy(n))