Hello
I'm also new to google kickstart challenges. I use Python and the code can
output correct answer on my local machine, however it throws a RE when I
try to submit my answer. Below is my code:
Thanks a lot for your help.
Best wishes,
Yitong
import numpy as np
import pandas as pd
from itertools import combinations
def eleva(xx):
news=list()
for k in range(9):
if (xx[k]!=0):
news.append([k+1]*xx[k])
out_new= list(itertools.chain.from_iterable(news))
####
if len(out_new)%2==0:
combins = [c for c in combinations(out_new, round(len(out_new)/2))]
sum_new=sum(out_new)
flag="NO"
for k in range(len(combins)):
sum_minus=sum(out_new)-sum(combins[k])-sum(combins[k])
if abs(sum_minus)%11==0:
flag="YES"
return flag
return flag
else: # odd number
combins = [c for c in combinations(out_new,
round((len(out_new)-1)/2))]
sum_new=sum(out_new)
comb_=list(range(len(combins)))
flag="NO"
for k in range(len(combins)):
sum_minus=sum(out_new)-sum(combins[k])-sum(combins[k])
if abs(sum_minus)%11==0:
flag="YES"
return flag
combins = [c for c in combinations(out_new,
round((len(out_new)+1)/2))]
sum_new=sum(out_new)
flag="NO"
for k in range(len(combins)):
sum_minus=sum(out_new)-sum(combins[k])-sum(combins[k])
if abs(sum_minus)%11==0:
flag="YES"
return flag
return flag
case=int(input())
for k in range(1,case+1):
x=[int(s) for s in input().split(" ")]
dd=eleva(x)
print("Case #{}: {}".format(k, dd))
--
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 view this discussion on the web visit
https://groups.google.com/d/msgid/google-code/7638cc54-60a8-4836-948b-7d7381b6e6ec%40googlegroups.com.