I would like to give some feedback about ...
From: http://www.checkio.org/mission/space-golf/solve/
HTTP_USER_AGENT:
Mozilla/5.0 (Windows NT 6.3; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0
my code is:
-
def golf(h,j=0,k=0,r=[]):
for i in range(len(h)):
j,k,d=min([[x,y,((y-k)**2+(x-j)**2)**.5]for x,y in h],key=lambda a:a[2])
h=[z for z in h if z!=(j,k)]
r+=[d]
return sum(r)
-
When I run this code in Python 3.4.1 Shell, I get the correct answer of 12.727922061357857, but when I run it in checkio, I get a Fail claiming that "Your result: 36.04163056034262".
Created at: 2015/01/09 22:37; Updated at: 2015/01/10 09:29