Skip to content

Commit

Permalink
Toti Cavalcanti e Otavio Cardoso
Browse files Browse the repository at this point in the history
  • Loading branch information
dojorio committed Dec 9, 2015
1 parent 29801f0 commit ad59784
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 25 deletions.
9 changes: 6 additions & 3 deletions 2015/20151209 - animal game - ruby/animal_game.rb
Original file line number Diff line number Diff line change
@@ -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
60 changes: 38 additions & 22 deletions 2015/20151209 - animal game - ruby/animal_game_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions 2015/20151209 - animal game - ruby/dojo.log
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit ad59784

Please sign in to comment.