-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathLove.rb
36 lines (30 loc) · 839 Bytes
/
Love.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
=begin
Who remembers back to their time in the schoolyard, when girls would take a
flower and tear its petals, saying each of the following phrases each time a
petal was torn:
I love you
a little
a lot
passionately
madly
not at all
When the last petal was torn there were cries of excitement, dreams, surging
thoughts and emotions.
Your goal in this kata is to determine which phrase the girls would say for a
flower of a given number of petals, where nb_petals > 0.
=end
# My Solution
def how_much_i_love_you(nb_petals)
case nb_petals % 6
when 1 ; "I love you"
when 2 ; "a little"
when 3 ; "a lot"
when 4 ; "passionately"
when 5 ; "madly"
when 0 ; "not at all"
end
end
# Better Solution
def how_much_i_love_you(n)
["I love you", "a little", "a lot", "passionately", "madly", "not at all"][(n-1)%6]
end