I have tested many different scenarios and test cases , And my code has
successfully produced outputs-As the problem suggests there can be many
solution I need to show any one but don't know why is it failing?
def FourPresent(n):
f=0
#print("for ",n)
while(n>0):
a=n%10
#print("now checking digit ",a)
if a==4:
f=1
break
n=n//10
if f==0:
return False
else:
return True
def chk_Four_occurance_lowest_place(n):
nd=1
while n>0:
if n%10==4:
return nd
nd+=1
n=n//10
return nd
def no_of_dig(n):
c=0
while(n>0):
c+=1
n=n//10
return c
t=int(input())
for ix in range(t):
n=int(input())
nod=no_of_dig(n)
if nod==1:
a=n//2
b=n-a
else:
nd=nod-2
#c=5*(10**nd)+1
a=n
b=n-a
while(FourPresent(a) or FourPresent(b)):
pd=chk_Four_occurance_lowest_place(a)
if pd<=2:
p=pd-1
else:
p=pd-2
inc_fact=5*(10**p)+1
a-=inc_fact
b=n-a
#print("now pd ",pd,inc_fact)
#print("After operation a,b",a,b)
print("Case #{}: {} {}".format(ix+1, a, b))
Thanks in advance for your help!!
--
You received this message because you are subscribed to the Google Groups
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-code/caa02693-a747-416e-84be-6921b6e78608%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.