darts exercise

This commit is contained in:
Xevion
2019-07-14 02:53:41 -05:00
parent fed57ab7ec
commit 25c4dffd84
4 changed files with 123 additions and 0 deletions
+8
View File
@@ -0,0 +1,8 @@
from math import sqrt
def dist(x1, y1, x2=0, y2=0):
return sqrt(((x2 - x1) ** 2) + ((y2 - y1) ** 2))
def score(x, y):
distance = dist(x, y)
return 10 if distance <= 1 else 5 if distance <= 5 else 1 if distance <= 10 else 0