Skip to content

Commit b8dab3a

Browse files
committed
exercism-86 Darts
1 parent 8eafe76 commit b8dab3a

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ solution of many challenges of [Leetcode](https://leetcode.com/), [Exercism](htt
311311
83. [ISBN Verifier](https://github.com/kumar91gopi/Algorithms-and-Data-Structures-in-Ruby/blob/master/exercism/isbn_verifier.rb)
312312
84. [Complex Number](https://github.com/kumar91gopi/Algorithms-and-Data-Structures-in-Ruby/blob/master/exercism/complex_number.rb)
313313
85. [Microwave](https://github.com/kumar91gopi/Algorithms-and-Data-Structures-in-Ruby/blob/master/exercism/microwave.rb)
314+
86. [Darts](https://github.com/kumar91gopi/Algorithms-and-Data-Structures-in-Ruby/blob/master/exercism/darts.rb)
314315

315316
<a name="leetcode"/>
316317

exercism/darts.rb

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Problem: https://exercism.org/tracks/ruby/exercises/darts
2+
3+
# Solution
4+
class Darts
5+
6+
def initialize(x,y)
7+
@x=x
8+
@y=y
9+
end
10+
11+
def score
12+
distance = Math.sqrt(@x*@x + @y*@y)
13+
14+
if distance <=1
15+
return 10
16+
end
17+
18+
if distance<=5
19+
return 5
20+
end
21+
22+
if distance<=10
23+
return 1
24+
end
25+
26+
return 0
27+
end
28+
end

0 commit comments

Comments
 (0)