Skip to content

Commit

Permalink
add examples
Browse files Browse the repository at this point in the history
  • Loading branch information
zehengl committed Jan 18, 2024
1 parent 6f75d50 commit a17aaa5
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/dartscores.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
t = io.read("*n")
for _ = 1, t do
n = io.read("*n")
score = 0
for _ = 1, n do
x, y = io.read("*n", "*n")
dist = (x ^ 2 + y ^ 2) ^ 0.5
if dist > 200 then
p = 0
elseif dist % 20 == 0 then
p = math.min(11 - dist // 20, 10)
else
p = 10 - dist // 20
end
score = score + math.floor(p)
end
print(score)
end
15 changes: 15 additions & 0 deletions src/dartscores.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
t = int(input())
for _ in range(t):
n = int(input())
score = 0
for _ in range(n):
x, y = [int(d) for d in input().split()]
dist = (x**2 + y**2) ** 0.5
if dist > 200:
p = 0
elif dist % 20 == 0:
p = min(11 - dist // 20, 10)
else:
p = 10 - dist // 20
score += int(p)
print(score)

0 comments on commit a17aaa5

Please sign in to comment.