Skip to content

Commit 2678b2d

Browse files
authored
Baffling Birthdays - Reduce the odds of a false failure (#762)
* Baffling Birthdays - Reduce the odds of a false failure * Reduce odds of a different failure
1 parent bc86225 commit 2678b2d

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

exercises/practice/baffling-birthdays/.meta/src/example.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ class BafflingBirthdays
2424
end
2525

2626
def self.estimated_probability_of_shared_birthday(size : Int) : Float
27-
return (1..10000).sum { |_| shared_birthday(random_birthdates(size)) ? 1 : 0 } / 100.0
27+
return (1..100000).sum { |_| shared_birthday(random_birthdates(size)) ? 1 : 0 } / 1000.0
2828
end
2929
end

exercises/practice/baffling-birthdays/.meta/test_template.ecr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ describe "<%-= to_capitalized(@json["exercise"].to_s) %>" do
1919
result = <%= to_capitalized(@json["exercise"].to_s) %>.<%= sub_case["property"].to_s.underscore %>(50)
2020
result.all? { |date| Time.leap_year?(date.year) }.should be_false
2121
<%- elsif (sub_case["expected"]["months"]? || {} of String => Bool)["random"]? -%>
22-
result = <%= to_capitalized(@json["exercise"].to_s) %>.<%= sub_case["property"].to_s.underscore %>(100)
22+
result = <%= to_capitalized(@json["exercise"].to_s) %>.<%= sub_case["property"].to_s.underscore %>(300)
2323
result.to_set { |date| date.month }.size.should eq(12)
2424
<%- elsif (sub_case["expected"]["days"]? || {} of String => Bool)["random"]? -%>
25-
result = <%= to_capitalized(@json["exercise"].to_s) %>.<%= sub_case["property"].to_s.underscore %>(300)
25+
result = <%= to_capitalized(@json["exercise"].to_s) %>.<%= sub_case["property"].to_s.underscore %>(1000)
2626
result.to_set { |date| date.day }.size.should eq(31)
2727
<% end %>
2828
end

exercises/practice/baffling-birthdays/spec/baffling_birthdays_spec.cr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@ describe "BafflingBirthdays" do
6969
end
7070

7171
pending "months are random" do
72-
result = BafflingBirthdays.random_birthdates(100)
72+
result = BafflingBirthdays.random_birthdates(300)
7373
result.to_set { |date| date.month }.size.should eq(12)
7474
end
7575

7676
pending "days are random" do
77-
result = BafflingBirthdays.random_birthdates(300)
77+
result = BafflingBirthdays.random_birthdates(1000)
7878
result.to_set { |date| date.day }.size.should eq(31)
7979
end
8080

0 commit comments

Comments
 (0)