Project Euler #222: Sphere Packing

  • + 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))