Initial commit

This commit is contained in:
2023-12-17 00:26:14 -05:00
commit 59d97be20c
89 changed files with 3184 additions and 0 deletions

17
elixir/darts/lib/darts.ex Normal file
View File

@@ -0,0 +1,17 @@
defmodule Darts do
@type position :: {number, number}
@doc """
Calculate the score of a single dart hitting a target
"""
@spec score(position) :: integer
def score({x, y}) do
in_radius = (x ** 2 + y ** 2) ** 0.5
cond do
in_radius <= 1 -> 10
in_radius <= 5 -> 5
in_radius <= 10 -> 1
true -> 0
end
end
end