Created
February 14, 2019 04:57
-
-
Save vishalkanaujia/e49aa078131e9a5de0f25bbfd246a046 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
def isNumber(s): | |
for i in range(len(s)): | |
┆ if s[i] == '-': | |
┆ ┆ try: | |
┆ ┆ ┆ if not s[i+1].isdigit(): | |
┆ ┆ ┆ ┆ return False | |
┆ ┆ except Exception: | |
┆ ┆ ┆ return False | |
┆ if ord(s[i]) >= 48 and ord(s[i]) <= 57: | |
┆ ┆ return True | |
return False | |
sum = 0 | |
# It reads three input lines from stdin | |
# and finds cumulative abs sum of only numbers | |
for i in range(3): | |
line = sys.stdin.readline() | |
x = isNumber(line.strip()) | |
print x | |
if x: | |
┆ sum += abs(int(line.strip())) | |
print(sum) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment