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.
defsolve(balls):r=0n=len(balls)foriinrange(0,n):# in half of the combinations (2**(n)), each ball is not picked# so we can compute its aggregated contribution to the final value asr+=2**(n-1)*balls[i]ev=r/(2**n)#expectedvaluereturn"%.1f"%ev`
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
B'day Gift
You are viewing a single comment's thread. Return to all comments →