Skip to content

Commit 15b7755

Browse files
committed
even digits - pending -- kick start gogl
1 parent 54f8386 commit 15b7755

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

ProblemSolving/evenDigits/even.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Naive add/sub with 2 pointers
2+
3+
def isEven(num):
4+
for i in list(str(num).strip()):
5+
if int(i)%2 != 0:
6+
return False
7+
return True
8+
9+
def uniqCalc(N):
10+
left = right = 0
11+
12+
while not isEven(N-left) and not isEven(N+right):
13+
#print N+left, N+right, isEven(N+left), isEven(N+right)
14+
left += 1
15+
right += 1
16+
17+
if isEven(N-left):
18+
return left
19+
else:
20+
return right
21+
22+
testcases = input()
23+
for i in range(testcases):
24+
num = input()
25+
print "Case #"+str(i+1)+": "+str(uniqCalc(num))
26+

0 commit comments

Comments
 (0)