Last active
July 31, 2018 11:06
-
-
Save nansenat16/7affef5ed5eaaad8be8e753eee56dbec 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
stdin=["44+44=88","4+6=10","6-2=4","2-6=?","6-3=2"] | |
total=0 | |
for line in stdin: | |
data=list(line) | |
if('?' in data): | |
total+=0 | |
elif('+' in data): | |
a=''.join(data[0:data.index('+')]) | |
b=''.join(data[data.index('+')+1:data.index('=')]) | |
d=int(a)+int(b) | |
data1=data[::-1] | |
c=data1[0:data1.index('=')] | |
e=''.join(c[::-1]) | |
if d==int(e): | |
total+=1 | |
elif('-' in data): | |
a=''.join(data[0:data.index('-')]) | |
b=''.join(data[data.index('-')+1:data.index('=')]) | |
d=int(a)-int(b) | |
data1=data[::-1] | |
c=data1[0:data1.index('=')] | |
e=''.join(c[::-1]) | |
if d==int(e): | |
total+=1 | |
elif('@@@' in data): | |
total+=0 | |
print total |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment