Project Euler #222: Sphere Packing

Sort by

recency

|

22 Discussions

|

  • + 0 comments

    I have no idea why i didn't pass all test case

    import math
    
    R, n = input().split()
    R, n = int(R), int(n)
    rOld = sorted([int(i) for i in input().split(" ")])
    if n == 1:
        res = 2*rOld[0]
    else:
        r = []
        for i in range(len(rOld)):
            if i % 2 == 0:
                r.append(rOld[i])
            else:
                r = [rOld[i]] + r
        res = r[0] + r[-1]
        for i in range(n-1):
            res += math.sqrt((r[i]+r[i+1])**2 - (2*R-(r[i]+r[i+1]))**2)
    print(round(res*1000))
    
  • + 0 comments

    can some one please explain the question? I am unable to understand what exactly the question refers to

  • + 1 comment

    hi can anyone please tell me what's wrong with this code cause it's not working after test case 2 import math

    import math
    R,n = map(int,input().split())
    r = list(map(int,input().split()))
    dist = []
    for i in range(n):
        if i!=n-1:
            d = r[i]+r[i+1]
            x = 2*R - d
            y = math.sqrt(d*d-x*x)
            dist.append(y)
    height = sum(dist)+r[0]+r[len(r)-1]
    print(round(height*1000))
    
  • + 0 comments

    hey help me that i am going in right direction or not In this problem i calculate shortest distance between two sphere is p=sqrt(math.fabs(r1*r1-r2*r2)) can you please help me

  • + 0 comments

    I cannot unlock testcases. Could someone please post testcase #40 or #41+? Thanks.