We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
def solve(a):
if len(a) == 0:
return 0
evn = [nmbr for nmbr in a if nmbr%2==0]
od = [nmbr for nmbr in a if nmbr%2!=0]
ven = 2**(len(evn)) - 1
if len(od) > 0:
do = 2**(len(od)-1) - 1
else:
do = 0
tot = ven+do+do*ven
return tot%1000000007
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
A Chocolate Fiesta
You are viewing a single comment's thread. Return to all comments →
def solve(a): if len(a) == 0: return 0 evn = [nmbr for nmbr in a if nmbr%2==0] od = [nmbr for nmbr in a if nmbr%2!=0] ven = 2**(len(evn)) - 1 if len(od) > 0: do = 2**(len(od)-1) - 1 else: do = 0 tot = ven+do+do*ven return tot%1000000007