Skip to content

Commit

Permalink
even digits kickstart gogl - attempt 1
Browse files Browse the repository at this point in the history
  • Loading branch information
sri authored and Srinivas11789 committed Mar 24, 2019
1 parent 54f8386 commit 14022d0
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions ProblemSolving/evenDigits/even.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Naive add/sub with 2 pointers

def isEven(num):
for i in list(str(num).strip()):
if int(i)%2 != 0:
return False
return True

def uniqCalc(N):
left = right = 0

while not isEven(N-left) and not isEven(N+right):
#print N+left, N+right, isEven(N+left), isEven(N+right)
left += 1
right += 1

if isEven(N-left):
return left
else:
return right

testcases = input()
for i in range(testcases):
num = input()
print "Case #"+str(i+1)+": "+str(uniqCalc(num))

0 comments on commit 14022d0

Please sign in to comment.