diff --git a/2015/20151209 - animal game - ruby/animal_game.rb b/2015/20151209 - animal game - ruby/animal_game.rb index 2d72e17e..811d74f4 100644 --- a/2015/20151209 - animal game - ruby/animal_game.rb +++ b/2015/20151209 - animal game - ruby/animal_game.rb @@ -1,9 +1,12 @@ def prize(value, bet, drawed) - verifier = bet % 100 - 1 + bet = bet % 100 drawed = drawed % 100 - drawed = 99 if drawed == 0 - return value * 16 if verifier / 4 == drawed / 4 + bet = 100 if bet == 0 + drawed = 100 if drawed == 0 + + return value * 50 if bet == drawed + return value * 16 if (bet - 1) / 4 == (drawed - 1) / 4 0 end \ No newline at end of file diff --git a/2015/20151209 - animal game - ruby/animal_game_spec.rb b/2015/20151209 - animal game - ruby/animal_game_spec.rb index 23b02c7d..8643ade7 100644 --- a/2015/20151209 - animal game - ruby/animal_game_spec.rb +++ b/2015/20151209 - animal game - ruby/animal_game_spec.rb @@ -5,36 +5,52 @@ expect(prize(1, 1234, 0)).to eq(0) end - it "gives 16x value if is from same group 1" do - expect(prize(1, 1299, 0)).to eq(16) - end + context "gives 16x value if is from same group" do + it "1" do + expect(prize(1, 1299, 0)).to eq(16) + end - it "gives 16x value if is from same group 2" do - expect(prize(2, 1299, 0)).to eq(32) - end + it "2" do + expect(prize(2, 1299, 0)).to eq(32) + end - it "gives 16x value if is from same group 3" do - expect(prize(2, 1297, 0)).to eq(32) - end + it "3" do + expect(prize(2, 1297, 0)).to eq(32) + end - it "gives 16x value if is from same group 4" do - expect(prize(2, 1201, 2)).to eq(32) - end + it "4" do + expect(prize(2, 1201, 2)).to eq(32) + end - it "gives 16x value if is from same group 5" do - expect(prize(2, 1205, 7)).to eq(32) - end + it "5" do + expect(prize(2, 1205, 7)).to eq(32) + end - it "gives 16x value if is from same group 6" do - expect(prize(2, 1205, 3)).to eq(0) - end + it "6" do + expect(prize(2, 1205, 3)).to eq(0) + end + + it "7" do + expect(prize(2, 3405, 3)).to eq(0) + end + + it "8" do + expect(prize(2, 3405, 1206)).to eq(32) + end + + it "9" do + expect(prize(2, 1200, 5601)).to eq(0) + end - it "gives 16x value if is from same group 6" do - expect(prize(2, 3405, 3)).to eq(0) + it "10" do + expect(prize(2, 1200, 5699)).to eq(32) + end end - it "gives 16x value if is from same group 6" do - expect(prize(2, 3405, 1206)).to eq(32) + context "gives 50x if last 2 digits are equal" do + it "1" do + expect(prize(2, 1299, 5699)).to eq(100) + end end end \ No newline at end of file diff --git a/2015/20151209 - animal game - ruby/dojo.log b/2015/20151209 - animal game - ruby/dojo.log index f86682b1..b656f4a6 100644 --- a/2015/20151209 - animal game - ruby/dojo.log +++ b/2015/20151209 - animal game - ruby/dojo.log @@ -2,3 +2,4 @@ Qua Dez 9 19:32:36 BRST 2015 - Toti Cavalcanti e Otavio Cardoso Qua Dez 9 19:46:15 BRST 2015 - Otavio Cardoso e Toti Cavalcanti Qua Dez 9 19:54:55 BRST 2015 - Toti Cavalcanti e Otavio Cardoso Qua Dez 9 20:02:24 BRST 2015 - Otavio Cardoso e Toti Cavalcanti +Qua Dez 9 20:10:08 BRST 2015 - Toti Cavalcanti e Otavio Cardoso