-
-
Save cored/dff0dba92f834e349503286ada049844 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
cond do | |
x * x + y * y > 100 -> 0 | |
x * x + y * y > 25 -> 1 | |
x * x + y * y > 1 -> 5 | |
true -> 10 | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment