From a0915a8d335d34daf6eaafa4a6a75ae390530a02 Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Thu, 6 Mar 2025 20:19:04 +0100 Subject: [PATCH 01/34] Add `baffling-birthdays` exercise --- .../baffling-birthdays/canonical-data.json | 176 ++++++++++++++++++ exercises/baffling-birthdays/instructions.md | 15 ++ exercises/baffling-birthdays/introduction.md | 25 +++ exercises/baffling-birthdays/metadata.toml | 4 + 4 files changed, 220 insertions(+) create mode 100644 exercises/baffling-birthdays/canonical-data.json create mode 100644 exercises/baffling-birthdays/instructions.md create mode 100644 exercises/baffling-birthdays/introduction.md create mode 100644 exercises/baffling-birthdays/metadata.toml diff --git a/exercises/baffling-birthdays/canonical-data.json b/exercises/baffling-birthdays/canonical-data.json new file mode 100644 index 0000000000..4595abb10c --- /dev/null +++ b/exercises/baffling-birthdays/canonical-data.json @@ -0,0 +1,176 @@ +{ + "exercise": "baffling-birthdays", + "comments": [ + "Dates are formatted as 'YYYY-MM-DD'.", + "", + "To increase the likelihood of consistent result, the tests should run the code returning random results many times.", + "", + "The expected probability values should be compared using some tolerance to allow for small deviations." + ], + "cases": [ + { + "uuid": "f7b3eb26-bcfc-4c1e-a2de-af07afc33f45", + "description": "matching birthday for same date", + "property": "matchingBirthday", + "input": { + "birthday1": "2000-01-01", + "birthday2": "2000-01-01" + }, + "expected": true + }, + { + "uuid": "7193409a-6e16-4bcb-b4cc-9ffe55f79b25", + "description": "matching birthday for same year and month but different day", + "property": "matchingBirthday", + "input": { + "birthday1": "2012-05-09", + "birthday2": "2012-05-17" + }, + "expected": false + }, + { + "uuid": "d04db648-121b-4b72-93e8-d7d2dced4495", + "description": "matching birthday for same month and day but different year", + "property": "matchingBirthday", + "input": { + "birthday1": "1999-10-23", + "birthday2": "1988-10-23" + }, + "expected": true + }, + { + "uuid": "3c8bd0f0-14c6-4d4c-975a-4c636bfdc233", + "description": "matching birthday for same year but different month and day", + "property": "matchingBirthday", + "input": { + "birthday1": "2007-12-19", + "birthday2": "2007-04-27" + }, + "expected": false + }, + { + "uuid": "df5daba6-0879-4480-883c-e855c99cdaa3", + "description": "matching birthday for different year month and day", + "property": "matchingBirthday", + "input": { + "birthday1": "1997-08-04", + "birthday2": "1963-11-23" + }, + "expected": false + }, + { + "uuid": "70b38cea-d234-4697-b146-7d130cd4ee12", + "description": "random birthdays return specified number of birthdays", + "scenarios": ["random"], + "property": "randomBirthdays", + "input": {}, + "expected": "length == groupsize" + }, + { + "uuid": "d9d5b7d3-5fea-4752-b9c1-3fcd176d1b03", + "description": "random birthdays have fixed year per batch", + "scenarios": ["random"], + "property": "randomBirthdays", + "input": {}, + "expected": { + "years": { + "fixed": true + } + } + }, + { + "uuid": "8da69a53-6900-4b63-897d-9f025f149fd2", + "description": "random birthdays have random year between batches", + "scenarios": ["random"], + "property": "randomBirthdays", + "input": {}, + "expected": { + "years": { + "random": true + } + } + }, + { + "uuid": "d1074327-f68c-4c8a-b0ff-e3730d0f0521", + "description": "random birthdays have random months", + "scenarios": ["random"], + "property": "randomBirthdays", + "input": {}, + "expected": { + "months": { + "random": true + } + } + }, + { + "uuid": "7df706b3-c3f5-471d-9563-23a4d0577940", + "description": "random birthdays have random days", + "scenarios": ["random"], + "property": "randomBirthdays", + "input": {}, + "expected": { + "days": { + "random": true + } + } + }, + { + "uuid": "ade37c87-f41d-4929-962a-286b4d1d048a", + "description": "has matching birthdays with matching birthday pair", + "property": "hasMatchingBirthdays", + "input": { + "birthdays": ["1970-01-19", "1975-06-03", "2003-01-19"] + }, + "expected": true + }, + { + "uuid": "1d155b33-c6e1-46b9-81fa-09123ae378ea", + "description": "has matching birthdays without matching birthday pair", + "property": "hasMatchingBirthdays", + "input": { + "birthdays": ["1984-04-05", "2000-09-17", "1966-10-12"] + }, + "expected": false + }, + { + "uuid": "89a462a4-4265-4912-9506-fb027913f221", + "description": "probability for matching birthday for one person", + "scenarios": ["random"], + "property": "probabilityForMatchingBirthdays", + "input": { + "groupSize": 1 + }, + "expected": 0.0 + }, + { + "uuid": "ec31c787-0ebb-4548-970c-5dcb4eadfb5f", + "description": "probability for matching birthday for ten people", + "scenarios": ["random"], + "property": "probabilityForMatchingBirthdays", + "input": { + "groupSize": 10 + }, + "expected": 11.7 + }, + { + "uuid": "b548afac-a451-46a3-9bb0-cb1f60c48e2f", + "description": "probability for matching birthday for twenty-three people", + "scenarios": ["random"], + "property": "probabilityForMatchingBirthdays", + "input": { + "groupSize": 23 + }, + "expected": 50.7 + }, + { + "uuid": "e43e6b9d-d77b-4f6c-a960-0fc0129a0bc5", + "description": "probability for matching birthday for seventy people", + "scenarios": ["random"], + "property": "probabilityForMatchingBirthdays", + "input": { + "groupSize": 70 + }, + "expected": 99.9 + } + ] +} diff --git a/exercises/baffling-birthdays/instructions.md b/exercises/baffling-birthdays/instructions.md new file mode 100644 index 0000000000..dc611c9e71 --- /dev/null +++ b/exercises/baffling-birthdays/instructions.md @@ -0,0 +1,15 @@ +# Instructions + +Your task is to implement a solution that verifies the Birthday Problem's probabilities. + +To do this, you need to: + +- Determine if two birthdates match (same month and day). +- Generate random birthdates. +- Check if a set of randomly generated birthdates contains at least one matching pair. +- Calculate the probability of at least one match for different group sizes. + +~~~~exercism/caution +The Birthday Problem assumes that birthdays are uniformly distributed within a single year. +While the year should vary between different random birthdate generation calls, all birthdates within a single call must share the same year. +~~~~ diff --git a/exercises/baffling-birthdays/introduction.md b/exercises/baffling-birthdays/introduction.md new file mode 100644 index 0000000000..43a5ade2b9 --- /dev/null +++ b/exercises/baffling-birthdays/introduction.md @@ -0,0 +1,25 @@ +# Introduction + +Fresh out of graduation, you're throwing a huge party to celebrate with friends and family. +Over 70 people have shown up, including your mildly eccentric Uncle Ted. + +In one of his usual antics, he bets you £100 that at least two people in the room share the same birthday. +That sounds ridiculous—there are 365 possible birthdays, so you confidently accept. + +To your astonishment, after collecting just 32 birthdays, you've already found a match. +Magnanimous, you hand Uncle Ted his £100, but something feels off. + +The next day, curiosity gets the better of you. +A quick web search leads you to the [Birthday Problem][birthday-problem], which reveals that with just 23 people, the probability of a shared birthday exceeds 50%. + +Ah. So _that's_ why Uncle Ted was so confident. + +Determined to turn the tables, you start looking up other paradoxes—next time, _you'll_ be the one making the bets. + +~~~~exercism/note +The birthday paradox is a veridical paradox: even though it feels wrong, it is actually true. + +[veridical-paradox]: https://en.wikipedia.org/wiki/Paradox#Quine's_classification +~~~~ + +[birthday-problem]: https://en.wikipedia.org/wiki/Birthday_problem diff --git a/exercises/baffling-birthdays/metadata.toml b/exercises/baffling-birthdays/metadata.toml new file mode 100644 index 0000000000..3555dc9448 --- /dev/null +++ b/exercises/baffling-birthdays/metadata.toml @@ -0,0 +1,4 @@ +title = "Baffling Birthdays" +blurb = "Verify the Birthday Problem's probabilities." +source = "Erik Schierboom" +source_url = "https://github.com/exercism/problem-specifications/pull/2539" From b749603eb628d08f479292b549058cb57ecdb18f Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Thu, 6 Mar 2025 21:21:18 +0100 Subject: [PATCH 02/34] Update exercises/baffling-birthdays/introduction.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: András B Nagy <20251272+BNAndras@users.noreply.github.com> --- exercises/baffling-birthdays/introduction.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/baffling-birthdays/introduction.md b/exercises/baffling-birthdays/introduction.md index 43a5ade2b9..a7851f5ac3 100644 --- a/exercises/baffling-birthdays/introduction.md +++ b/exercises/baffling-birthdays/introduction.md @@ -10,7 +10,7 @@ To your astonishment, after collecting just 32 birthdays, you've already found a Magnanimous, you hand Uncle Ted his £100, but something feels off. The next day, curiosity gets the better of you. -A quick web search leads you to the [Birthday Problem][birthday-problem], which reveals that with just 23 people, the probability of a shared birthday exceeds 50%. +A quick web search leads you to the [birthday paradox][birthday-problem], which reveals that with just 23 people, the probability of a shared birthday exceeds 50%. Ah. So _that's_ why Uncle Ted was so confident. From 416e446576860c68ec33bd45c3b3dbebcb721bc1 Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Thu, 6 Mar 2025 21:21:27 +0100 Subject: [PATCH 03/34] Update exercises/baffling-birthdays/introduction.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: András B Nagy <20251272+BNAndras@users.noreply.github.com> --- exercises/baffling-birthdays/introduction.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/baffling-birthdays/introduction.md b/exercises/baffling-birthdays/introduction.md index a7851f5ac3..2364a254c7 100644 --- a/exercises/baffling-birthdays/introduction.md +++ b/exercises/baffling-birthdays/introduction.md @@ -17,7 +17,7 @@ Ah. So _that's_ why Uncle Ted was so confident. Determined to turn the tables, you start looking up other paradoxes—next time, _you'll_ be the one making the bets. ~~~~exercism/note -The birthday paradox is a veridical paradox: even though it feels wrong, it is actually true. +The birthday paradox is a [veridical paradox][veridical-paradox]: even though it feels wrong, it is actually true. [veridical-paradox]: https://en.wikipedia.org/wiki/Paradox#Quine's_classification ~~~~ From e90009e3651f77d2465b32933f8e92f12cefc5ba Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Thu, 6 Mar 2025 21:24:30 +0100 Subject: [PATCH 04/34] Consistency --- exercises/baffling-birthdays/instructions.md | 4 ++-- exercises/baffling-birthdays/introduction.md | 4 ++-- exercises/baffling-birthdays/metadata.toml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/exercises/baffling-birthdays/instructions.md b/exercises/baffling-birthdays/instructions.md index dc611c9e71..13accf8438 100644 --- a/exercises/baffling-birthdays/instructions.md +++ b/exercises/baffling-birthdays/instructions.md @@ -1,6 +1,6 @@ # Instructions -Your task is to implement a solution that verifies the Birthday Problem's probabilities. +Your task is to implement a solution that verifies the Birthday Paradox's probabilities. To do this, you need to: @@ -10,6 +10,6 @@ To do this, you need to: - Calculate the probability of at least one match for different group sizes. ~~~~exercism/caution -The Birthday Problem assumes that birthdays are uniformly distributed within a single year. +The Birthday Paradox assumes that birthdays are uniformly distributed within a single year. While the year should vary between different random birthdate generation calls, all birthdates within a single call must share the same year. ~~~~ diff --git a/exercises/baffling-birthdays/introduction.md b/exercises/baffling-birthdays/introduction.md index 2364a254c7..813f2636d0 100644 --- a/exercises/baffling-birthdays/introduction.md +++ b/exercises/baffling-birthdays/introduction.md @@ -10,14 +10,14 @@ To your astonishment, after collecting just 32 birthdays, you've already found a Magnanimous, you hand Uncle Ted his £100, but something feels off. The next day, curiosity gets the better of you. -A quick web search leads you to the [birthday paradox][birthday-problem], which reveals that with just 23 people, the probability of a shared birthday exceeds 50%. +A quick web search leads you to the [Birthday Paradox][birthday-problem], which reveals that with just 23 people, the probability of a shared birthday exceeds 50%. Ah. So _that's_ why Uncle Ted was so confident. Determined to turn the tables, you start looking up other paradoxes—next time, _you'll_ be the one making the bets. ~~~~exercism/note -The birthday paradox is a [veridical paradox][veridical-paradox]: even though it feels wrong, it is actually true. +The Birthday Paradox is a [veridical paradox][veridical-paradox]: even though it feels wrong, it is actually true. [veridical-paradox]: https://en.wikipedia.org/wiki/Paradox#Quine's_classification ~~~~ diff --git a/exercises/baffling-birthdays/metadata.toml b/exercises/baffling-birthdays/metadata.toml index 3555dc9448..7f0686791a 100644 --- a/exercises/baffling-birthdays/metadata.toml +++ b/exercises/baffling-birthdays/metadata.toml @@ -1,4 +1,4 @@ title = "Baffling Birthdays" -blurb = "Verify the Birthday Problem's probabilities." +blurb = "Verify the Birthday Paradox's probabilities." source = "Erik Schierboom" source_url = "https://github.com/exercism/problem-specifications/pull/2539" From 17b5e11b4144a36c02554ecb4c4e8800d8cd4e1b Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Fri, 7 Mar 2025 06:18:26 +0100 Subject: [PATCH 05/34] Update instructions.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: András B Nagy <20251272+BNAndras@users.noreply.github.com> --- exercises/baffling-birthdays/instructions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/baffling-birthdays/instructions.md b/exercises/baffling-birthdays/instructions.md index 13accf8438..f4fc3ced56 100644 --- a/exercises/baffling-birthdays/instructions.md +++ b/exercises/baffling-birthdays/instructions.md @@ -4,7 +4,7 @@ Your task is to implement a solution that verifies the Birthday Paradox's probab To do this, you need to: -- Determine if two birthdates match (same month and day). +- Determine if two birthdates have the same month and day. - Generate random birthdates. - Check if a set of randomly generated birthdates contains at least one matching pair. - Calculate the probability of at least one match for different group sizes. From 97608739eee75892c0b047d12df95179900f68da Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Fri, 7 Mar 2025 13:03:37 +0100 Subject: [PATCH 06/34] Update instructions.md Co-authored-by: Isaac Good --- exercises/baffling-birthdays/instructions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/baffling-birthdays/instructions.md b/exercises/baffling-birthdays/instructions.md index f4fc3ced56..1b847f2fa1 100644 --- a/exercises/baffling-birthdays/instructions.md +++ b/exercises/baffling-birthdays/instructions.md @@ -1,6 +1,6 @@ # Instructions -Your task is to implement a solution that verifies the Birthday Paradox's probabilities. +Your task is to verify the Birthday Paradox's probabilities. To do this, you need to: From 7df140a6ba653f47d4fe39eae2fb23c0f3a64378 Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Fri, 7 Mar 2025 13:03:58 +0100 Subject: [PATCH 07/34] Update introduction.md Co-authored-by: Isaac Good --- exercises/baffling-birthdays/introduction.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/baffling-birthdays/introduction.md b/exercises/baffling-birthdays/introduction.md index 813f2636d0..418c01e9f6 100644 --- a/exercises/baffling-birthdays/introduction.md +++ b/exercises/baffling-birthdays/introduction.md @@ -4,7 +4,7 @@ Fresh out of graduation, you're throwing a huge party to celebrate with friends Over 70 people have shown up, including your mildly eccentric Uncle Ted. In one of his usual antics, he bets you £100 that at least two people in the room share the same birthday. -That sounds ridiculous—there are 365 possible birthdays, so you confidently accept. +That sounds ridiculous — there are 365 possible birthdays, so you confidently accept. To your astonishment, after collecting just 32 birthdays, you've already found a match. Magnanimous, you hand Uncle Ted his £100, but something feels off. From 8659d9fd5ba48e92b2f3829ecd58fc335d8caa0f Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Fri, 7 Mar 2025 13:04:19 +0100 Subject: [PATCH 08/34] Update introduction.md Co-authored-by: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com> --- exercises/baffling-birthdays/introduction.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/baffling-birthdays/introduction.md b/exercises/baffling-birthdays/introduction.md index 418c01e9f6..fffd6a6643 100644 --- a/exercises/baffling-birthdays/introduction.md +++ b/exercises/baffling-birthdays/introduction.md @@ -7,7 +7,7 @@ In one of his usual antics, he bets you £100 that at least two people in the ro That sounds ridiculous — there are 365 possible birthdays, so you confidently accept. To your astonishment, after collecting just 32 birthdays, you've already found a match. -Magnanimous, you hand Uncle Ted his £100, but something feels off. +Accepting your loss, you hand Uncle Ted his £100, but something feels off. The next day, curiosity gets the better of you. A quick web search leads you to the [Birthday Paradox][birthday-problem], which reveals that with just 23 people, the probability of a shared birthday exceeds 50%. From 106670c3b508fc65beb792879d2f164fca92d472 Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Fri, 7 Mar 2025 13:04:26 +0100 Subject: [PATCH 09/34] Update introduction.md Co-authored-by: Isaac Good --- exercises/baffling-birthdays/introduction.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/baffling-birthdays/introduction.md b/exercises/baffling-birthdays/introduction.md index fffd6a6643..2cfc117a4d 100644 --- a/exercises/baffling-birthdays/introduction.md +++ b/exercises/baffling-birthdays/introduction.md @@ -14,7 +14,7 @@ A quick web search leads you to the [Birthday Paradox][birthday-problem], which Ah. So _that's_ why Uncle Ted was so confident. -Determined to turn the tables, you start looking up other paradoxes—next time, _you'll_ be the one making the bets. +Determined to turn the tables, you start looking up other paradoxes; next time, _you'll_ be the one making the bets. ~~~~exercism/note The Birthday Paradox is a [veridical paradox][veridical-paradox]: even though it feels wrong, it is actually true. From 59258da59df22fa76b81b4e1ac09a4b6637f2cc2 Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Fri, 7 Mar 2025 18:47:01 +0100 Subject: [PATCH 10/34] Lowercase birthday paradox --- exercises/baffling-birthdays/instructions.md | 4 ++-- exercises/baffling-birthdays/introduction.md | 4 ++-- exercises/baffling-birthdays/metadata.toml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/exercises/baffling-birthdays/instructions.md b/exercises/baffling-birthdays/instructions.md index 1b847f2fa1..c42a276f53 100644 --- a/exercises/baffling-birthdays/instructions.md +++ b/exercises/baffling-birthdays/instructions.md @@ -1,6 +1,6 @@ # Instructions -Your task is to verify the Birthday Paradox's probabilities. +Your task is to verify the birthday paradox's probabilities. To do this, you need to: @@ -10,6 +10,6 @@ To do this, you need to: - Calculate the probability of at least one match for different group sizes. ~~~~exercism/caution -The Birthday Paradox assumes that birthdays are uniformly distributed within a single year. +The birthday paradox assumes that birthdays are uniformly distributed within a single year. While the year should vary between different random birthdate generation calls, all birthdates within a single call must share the same year. ~~~~ diff --git a/exercises/baffling-birthdays/introduction.md b/exercises/baffling-birthdays/introduction.md index 2cfc117a4d..a8d5f5250f 100644 --- a/exercises/baffling-birthdays/introduction.md +++ b/exercises/baffling-birthdays/introduction.md @@ -10,14 +10,14 @@ To your astonishment, after collecting just 32 birthdays, you've already found a Accepting your loss, you hand Uncle Ted his £100, but something feels off. The next day, curiosity gets the better of you. -A quick web search leads you to the [Birthday Paradox][birthday-problem], which reveals that with just 23 people, the probability of a shared birthday exceeds 50%. +A quick web search leads you to the [birthday paradox][birthday-problem], which reveals that with just 23 people, the probability of a shared birthday exceeds 50%. Ah. So _that's_ why Uncle Ted was so confident. Determined to turn the tables, you start looking up other paradoxes; next time, _you'll_ be the one making the bets. ~~~~exercism/note -The Birthday Paradox is a [veridical paradox][veridical-paradox]: even though it feels wrong, it is actually true. +The birthday paradox is a [veridical paradox][veridical-paradox]: even though it feels wrong, it is actually true. [veridical-paradox]: https://en.wikipedia.org/wiki/Paradox#Quine's_classification ~~~~ diff --git a/exercises/baffling-birthdays/metadata.toml b/exercises/baffling-birthdays/metadata.toml index 7f0686791a..9c4840f2a7 100644 --- a/exercises/baffling-birthdays/metadata.toml +++ b/exercises/baffling-birthdays/metadata.toml @@ -1,4 +1,4 @@ title = "Baffling Birthdays" -blurb = "Verify the Birthday Paradox's probabilities." +blurb = "Verify the birthday paradox's probabilities." source = "Erik Schierboom" source_url = "https://github.com/exercism/problem-specifications/pull/2539" From 1e0ed9fa22d50f3a8d73795877d503f621e44fae Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Fri, 7 Mar 2025 18:48:36 +0100 Subject: [PATCH 11/34] Use estimate --- exercises/baffling-birthdays/instructions.md | 2 +- exercises/baffling-birthdays/metadata.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/baffling-birthdays/instructions.md b/exercises/baffling-birthdays/instructions.md index c42a276f53..60fb2198f3 100644 --- a/exercises/baffling-birthdays/instructions.md +++ b/exercises/baffling-birthdays/instructions.md @@ -1,6 +1,6 @@ # Instructions -Your task is to verify the birthday paradox's probabilities. +Your task is to estimate the birthday paradox's probabilities. To do this, you need to: diff --git a/exercises/baffling-birthdays/metadata.toml b/exercises/baffling-birthdays/metadata.toml index 9c4840f2a7..11ac9d0f63 100644 --- a/exercises/baffling-birthdays/metadata.toml +++ b/exercises/baffling-birthdays/metadata.toml @@ -1,4 +1,4 @@ title = "Baffling Birthdays" -blurb = "Verify the birthday paradox's probabilities." +blurb = "Estimate the birthday paradox's probabilities." source = "Erik Schierboom" source_url = "https://github.com/exercism/problem-specifications/pull/2539" From 9a47667947f2f0f90feca981147b7c5228551e32 Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Fri, 7 Mar 2025 18:48:48 +0100 Subject: [PATCH 12/34] Out of college --- exercises/baffling-birthdays/introduction.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/baffling-birthdays/introduction.md b/exercises/baffling-birthdays/introduction.md index a8d5f5250f..925516ec63 100644 --- a/exercises/baffling-birthdays/introduction.md +++ b/exercises/baffling-birthdays/introduction.md @@ -1,6 +1,6 @@ # Introduction -Fresh out of graduation, you're throwing a huge party to celebrate with friends and family. +Fresh out of college, you're throwing a huge party to celebrate with friends and family. Over 70 people have shown up, including your mildly eccentric Uncle Ted. In one of his usual antics, he bets you £100 that at least two people in the room share the same birthday. From fdeb83685735311498ec986465ec45315783f687 Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Fri, 7 Mar 2025 18:52:02 +0100 Subject: [PATCH 13/34] Change birthday to birthdates --- .../baffling-birthdays/canonical-data.json | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/exercises/baffling-birthdays/canonical-data.json b/exercises/baffling-birthdays/canonical-data.json index 4595abb10c..700c9f248d 100644 --- a/exercises/baffling-birthdays/canonical-data.json +++ b/exercises/baffling-birthdays/canonical-data.json @@ -13,8 +13,8 @@ "description": "matching birthday for same date", "property": "matchingBirthday", "input": { - "birthday1": "2000-01-01", - "birthday2": "2000-01-01" + "birthdate1": "2000-01-01", + "birthdate2": "2000-01-01" }, "expected": true }, @@ -23,8 +23,8 @@ "description": "matching birthday for same year and month but different day", "property": "matchingBirthday", "input": { - "birthday1": "2012-05-09", - "birthday2": "2012-05-17" + "birthdate1": "2012-05-09", + "birthdate2": "2012-05-17" }, "expected": false }, @@ -33,8 +33,8 @@ "description": "matching birthday for same month and day but different year", "property": "matchingBirthday", "input": { - "birthday1": "1999-10-23", - "birthday2": "1988-10-23" + "birthdate1": "1999-10-23", + "birthdate2": "1988-10-23" }, "expected": true }, @@ -43,8 +43,8 @@ "description": "matching birthday for same year but different month and day", "property": "matchingBirthday", "input": { - "birthday1": "2007-12-19", - "birthday2": "2007-04-27" + "birthdate1": "2007-12-19", + "birthdate2": "2007-04-27" }, "expected": false }, @@ -53,24 +53,24 @@ "description": "matching birthday for different year month and day", "property": "matchingBirthday", "input": { - "birthday1": "1997-08-04", - "birthday2": "1963-11-23" + "birthdate1": "1997-08-04", + "birthdate2": "1963-11-23" }, "expected": false }, { "uuid": "70b38cea-d234-4697-b146-7d130cd4ee12", - "description": "random birthdays return specified number of birthdays", + "description": "random birthdates return specified number of birthdays", "scenarios": ["random"], - "property": "randomBirthdays", + "property": "randomBirthdates", "input": {}, "expected": "length == groupsize" }, { "uuid": "d9d5b7d3-5fea-4752-b9c1-3fcd176d1b03", - "description": "random birthdays have fixed year per batch", + "description": "random birthdates have fixed year per batch", "scenarios": ["random"], - "property": "randomBirthdays", + "property": "randomBirthdates", "input": {}, "expected": { "years": { @@ -80,9 +80,9 @@ }, { "uuid": "8da69a53-6900-4b63-897d-9f025f149fd2", - "description": "random birthdays have random year between batches", + "description": "random birthdates have random year between batches", "scenarios": ["random"], - "property": "randomBirthdays", + "property": "randomBirthdates", "input": {}, "expected": { "years": { @@ -92,9 +92,9 @@ }, { "uuid": "d1074327-f68c-4c8a-b0ff-e3730d0f0521", - "description": "random birthdays have random months", + "description": "random birthdates have random months", "scenarios": ["random"], - "property": "randomBirthdays", + "property": "randomBirthdates", "input": {}, "expected": { "months": { @@ -104,9 +104,9 @@ }, { "uuid": "7df706b3-c3f5-471d-9563-23a4d0577940", - "description": "random birthdays have random days", + "description": "random birthdates have random days", "scenarios": ["random"], - "property": "randomBirthdays", + "property": "randomBirthdates", "input": {}, "expected": { "days": { From 6fc865cdbe72d18886c638274cc64bb055012c90 Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Fri, 7 Mar 2025 18:53:19 +0100 Subject: [PATCH 14/34] Add leap year note --- exercises/baffling-birthdays/instructions.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/exercises/baffling-birthdays/instructions.md b/exercises/baffling-birthdays/instructions.md index 60fb2198f3..8295f61b48 100644 --- a/exercises/baffling-birthdays/instructions.md +++ b/exercises/baffling-birthdays/instructions.md @@ -10,6 +10,9 @@ To do this, you need to: - Calculate the probability of at least one match for different group sizes. ~~~~exercism/caution -The birthday paradox assumes that birthdays are uniformly distributed within a single year. -While the year should vary between different random birthdate generation calls, all birthdates within a single call must share the same year. +The birthday paradox assumes that: +- Birthdays are uniformly distributed within a single year +- That year has 365 days (no leap years) + +While the year should vary between different random birthdate generation calls, all birthdates within a single call _must_ share the same year. ~~~~ From c8d1f72970569075e4aff546a9ab1c2d7bcd4fe8 Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Fri, 7 Mar 2025 18:55:40 +0100 Subject: [PATCH 15/34] Change quantity --- exercises/baffling-birthdays/introduction.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/baffling-birthdays/introduction.md b/exercises/baffling-birthdays/introduction.md index 925516ec63..9f5636b891 100644 --- a/exercises/baffling-birthdays/introduction.md +++ b/exercises/baffling-birthdays/introduction.md @@ -4,7 +4,7 @@ Fresh out of college, you're throwing a huge party to celebrate with friends and Over 70 people have shown up, including your mildly eccentric Uncle Ted. In one of his usual antics, he bets you £100 that at least two people in the room share the same birthday. -That sounds ridiculous — there are 365 possible birthdays, so you confidently accept. +That sounds ridiculous — there are many more possible birthdays, so you confidently accept. To your astonishment, after collecting just 32 birthdays, you've already found a match. Accepting your loss, you hand Uncle Ted his £100, but something feels off. From 1d6eda6f2a677cdb8434bef4de6cfc179187080d Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Fri, 7 Mar 2025 20:58:38 +0100 Subject: [PATCH 16/34] Update exercises/baffling-birthdays/canonical-data.json Co-authored-by: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com> --- exercises/baffling-birthdays/canonical-data.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/baffling-birthdays/canonical-data.json b/exercises/baffling-birthdays/canonical-data.json index 700c9f248d..9de5973b39 100644 --- a/exercises/baffling-birthdays/canonical-data.json +++ b/exercises/baffling-birthdays/canonical-data.json @@ -150,7 +150,7 @@ "input": { "groupSize": 10 }, - "expected": 11.7 + "expected": 11.694818 }, { "uuid": "b548afac-a451-46a3-9bb0-cb1f60c48e2f", From 0650ae0992adad0be7cec615b2e10925b04a7010 Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Fri, 7 Mar 2025 20:58:45 +0100 Subject: [PATCH 17/34] Update exercises/baffling-birthdays/canonical-data.json Co-authored-by: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com> --- exercises/baffling-birthdays/canonical-data.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/baffling-birthdays/canonical-data.json b/exercises/baffling-birthdays/canonical-data.json index 9de5973b39..0d8b84fbc7 100644 --- a/exercises/baffling-birthdays/canonical-data.json +++ b/exercises/baffling-birthdays/canonical-data.json @@ -170,7 +170,7 @@ "input": { "groupSize": 70 }, - "expected": 99.9 + "expected": 99.915958 } ] } From 304daaa6818b00ece8057e00b5fe97d6fe4ea436 Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Fri, 7 Mar 2025 20:58:58 +0100 Subject: [PATCH 18/34] Update exercises/baffling-birthdays/canonical-data.json Co-authored-by: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com> --- exercises/baffling-birthdays/canonical-data.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/baffling-birthdays/canonical-data.json b/exercises/baffling-birthdays/canonical-data.json index 0d8b84fbc7..3d64514437 100644 --- a/exercises/baffling-birthdays/canonical-data.json +++ b/exercises/baffling-birthdays/canonical-data.json @@ -160,7 +160,7 @@ "input": { "groupSize": 23 }, - "expected": 50.7 + "expected": 50.729723 }, { "uuid": "e43e6b9d-d77b-4f6c-a960-0fc0129a0bc5", From a20320a3ea9ad0384d7fd024326fcd458d4be6da Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Sat, 8 Mar 2025 08:51:05 +0100 Subject: [PATCH 19/34] Use collection instead of set --- exercises/baffling-birthdays/instructions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/baffling-birthdays/instructions.md b/exercises/baffling-birthdays/instructions.md index 8295f61b48..50c45d26fb 100644 --- a/exercises/baffling-birthdays/instructions.md +++ b/exercises/baffling-birthdays/instructions.md @@ -6,7 +6,7 @@ To do this, you need to: - Determine if two birthdates have the same month and day. - Generate random birthdates. -- Check if a set of randomly generated birthdates contains at least one matching pair. +- Check if a collection of randomly generated birthdates contains at least one matching pair. - Calculate the probability of at least one match for different group sizes. ~~~~exercism/caution From a717d1df44b90f4574c97f6271639b02740a41fb Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Sat, 8 Mar 2025 08:51:28 +0100 Subject: [PATCH 20/34] Estimate --- exercises/baffling-birthdays/instructions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/baffling-birthdays/instructions.md b/exercises/baffling-birthdays/instructions.md index 50c45d26fb..845334e499 100644 --- a/exercises/baffling-birthdays/instructions.md +++ b/exercises/baffling-birthdays/instructions.md @@ -7,7 +7,7 @@ To do this, you need to: - Determine if two birthdates have the same month and day. - Generate random birthdates. - Check if a collection of randomly generated birthdates contains at least one matching pair. -- Calculate the probability of at least one match for different group sizes. +- Estimate the probability of at least one match for different group sizes. ~~~~exercism/caution The birthday paradox assumes that: From 76b8f129dc9c3cb7f8f999d1e8b91666bc23b69d Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Sat, 8 Mar 2025 09:30:33 +0100 Subject: [PATCH 21/34] Simplify instructions --- exercises/baffling-birthdays/instructions.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/exercises/baffling-birthdays/instructions.md b/exercises/baffling-birthdays/instructions.md index 845334e499..3c5a4635e5 100644 --- a/exercises/baffling-birthdays/instructions.md +++ b/exercises/baffling-birthdays/instructions.md @@ -11,8 +11,9 @@ To do this, you need to: ~~~~exercism/caution The birthday paradox assumes that: -- Birthdays are uniformly distributed within a single year -- That year has 365 days (no leap years) -While the year should vary between different random birthdate generation calls, all birthdates within a single call _must_ share the same year. +- There are 365 possible birthdays (no leap years). +- Each birthday is equally likely (uniform distribution). + +Your implementation must follow these assumptions. ~~~~ From de2675feaf2fb4afa631bf1e9727ba94be8217de Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Sat, 8 Mar 2025 09:33:15 +0100 Subject: [PATCH 22/34] Simplify canonical data --- .../baffling-birthdays/canonical-data.json | 22 +++++-------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/exercises/baffling-birthdays/canonical-data.json b/exercises/baffling-birthdays/canonical-data.json index 3d64514437..3ba2d77414 100644 --- a/exercises/baffling-birthdays/canonical-data.json +++ b/exercises/baffling-birthdays/canonical-data.json @@ -60,7 +60,7 @@ }, { "uuid": "70b38cea-d234-4697-b146-7d130cd4ee12", - "description": "random birthdates return specified number of birthdays", + "description": "random birthdates generates requested number of birthdays", "scenarios": ["random"], "property": "randomBirthdates", "input": {}, @@ -68,31 +68,19 @@ }, { "uuid": "d9d5b7d3-5fea-4752-b9c1-3fcd176d1b03", - "description": "random birthdates have fixed year per batch", + "description": "random birthdates have non-leap year", "scenarios": ["random"], "property": "randomBirthdates", "input": {}, "expected": { "years": { - "fixed": true - } - } - }, - { - "uuid": "8da69a53-6900-4b63-897d-9f025f149fd2", - "description": "random birthdates have random year between batches", - "scenarios": ["random"], - "property": "randomBirthdates", - "input": {}, - "expected": { - "years": { - "random": true + "leapYear": false } } }, { "uuid": "d1074327-f68c-4c8a-b0ff-e3730d0f0521", - "description": "random birthdates have random months", + "description": "random birthdates have random month", "scenarios": ["random"], "property": "randomBirthdates", "input": {}, @@ -104,7 +92,7 @@ }, { "uuid": "7df706b3-c3f5-471d-9563-23a4d0577940", - "description": "random birthdates have random days", + "description": "random birthdates have random day", "scenarios": ["random"], "property": "randomBirthdates", "input": {}, From d5dfc362eacd68fadf1d96ec69a9f1c5613eaa18 Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Sat, 8 Mar 2025 12:53:01 +0100 Subject: [PATCH 23/34] Update instructions.md Co-authored-by: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com> --- exercises/baffling-birthdays/instructions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/baffling-birthdays/instructions.md b/exercises/baffling-birthdays/instructions.md index 3c5a4635e5..7c7d641c52 100644 --- a/exercises/baffling-birthdays/instructions.md +++ b/exercises/baffling-birthdays/instructions.md @@ -6,7 +6,7 @@ To do this, you need to: - Determine if two birthdates have the same month and day. - Generate random birthdates. -- Check if a collection of randomly generated birthdates contains at least one matching pair. +- Check if a collection of randomly generated birthdates contains any two with the same month and day. - Estimate the probability of at least one match for different group sizes. ~~~~exercism/caution From beb85f718c30a98e61bb6d650ebee8ce8b22fdd3 Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Sat, 8 Mar 2025 15:10:46 +0100 Subject: [PATCH 24/34] Update instructions.md Co-authored-by: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com> --- exercises/baffling-birthdays/instructions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/baffling-birthdays/instructions.md b/exercises/baffling-birthdays/instructions.md index 7c7d641c52..dc5a089aa4 100644 --- a/exercises/baffling-birthdays/instructions.md +++ b/exercises/baffling-birthdays/instructions.md @@ -7,7 +7,7 @@ To do this, you need to: - Determine if two birthdates have the same month and day. - Generate random birthdates. - Check if a collection of randomly generated birthdates contains any two with the same month and day. -- Estimate the probability of at least one match for different group sizes. +- Estimate the probability that at least two people in a group share the same birthday (month and day) for different group sizes. ~~~~exercism/caution The birthday paradox assumes that: From 047070988d4470eb32467ffcfdaab99b1d823cab Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Sat, 8 Mar 2025 21:24:01 +0100 Subject: [PATCH 25/34] Another attempt --- exercises/baffling-birthdays/instructions.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/exercises/baffling-birthdays/instructions.md b/exercises/baffling-birthdays/instructions.md index dc5a089aa4..544f95bac2 100644 --- a/exercises/baffling-birthdays/instructions.md +++ b/exercises/baffling-birthdays/instructions.md @@ -6,8 +6,13 @@ To do this, you need to: - Determine if two birthdates have the same month and day. - Generate random birthdates. -- Check if a collection of randomly generated birthdates contains any two with the same month and day. -- Estimate the probability that at least two people in a group share the same birthday (month and day) for different group sizes. +- Check if a collection of randomly generated birthdates contains any two with the same birthday. +- Estimate the probability that at least two people in a group share the same birthday for different group sizes. + +~~~~exercism/note +A birthdate includes the full date of birth (year, month, and day), whereas a birthday refers only to the month and day, which repeat each year. +Two birthdates with the same month and day correspond to the same birthday. +~~~~ ~~~~exercism/caution The birthday paradox assumes that: From 893130f537baadcfdc92a613c4eca7a411f74800 Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Sun, 9 Mar 2025 08:45:24 +0100 Subject: [PATCH 26/34] Tweaks --- exercises/baffling-birthdays/canonical-data.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/exercises/baffling-birthdays/canonical-data.json b/exercises/baffling-birthdays/canonical-data.json index 3ba2d77414..a55b190a11 100644 --- a/exercises/baffling-birthdays/canonical-data.json +++ b/exercises/baffling-birthdays/canonical-data.json @@ -50,7 +50,7 @@ }, { "uuid": "df5daba6-0879-4480-883c-e855c99cdaa3", - "description": "matching birthday for different year month and day", + "description": "matching birthday for different year, month and day", "property": "matchingBirthday", "input": { "birthdate1": "1997-08-04", @@ -122,7 +122,7 @@ }, { "uuid": "89a462a4-4265-4912-9506-fb027913f221", - "description": "probability for matching birthday for one person", + "description": "probability for matching birthday pair for one person", "scenarios": ["random"], "property": "probabilityForMatchingBirthdays", "input": { @@ -132,7 +132,7 @@ }, { "uuid": "ec31c787-0ebb-4548-970c-5dcb4eadfb5f", - "description": "probability for matching birthday for ten people", + "description": "probability for matching birthday pair for ten people", "scenarios": ["random"], "property": "probabilityForMatchingBirthdays", "input": { @@ -142,7 +142,7 @@ }, { "uuid": "b548afac-a451-46a3-9bb0-cb1f60c48e2f", - "description": "probability for matching birthday for twenty-three people", + "description": "probability for matching birthday pair for twenty-three people", "scenarios": ["random"], "property": "probabilityForMatchingBirthdays", "input": { @@ -152,7 +152,7 @@ }, { "uuid": "e43e6b9d-d77b-4f6c-a960-0fc0129a0bc5", - "description": "probability for matching birthday for seventy people", + "description": "probability for matching birthday pair for seventy people", "scenarios": ["random"], "property": "probabilityForMatchingBirthdays", "input": { From 48c7205bd6efba469cda440e96a02740c351b5e3 Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Sun, 9 Mar 2025 12:19:30 +0100 Subject: [PATCH 27/34] Update canonical-data.json Co-authored-by: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com> --- exercises/baffling-birthdays/canonical-data.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/baffling-birthdays/canonical-data.json b/exercises/baffling-birthdays/canonical-data.json index a55b190a11..76af343cea 100644 --- a/exercises/baffling-birthdays/canonical-data.json +++ b/exercises/baffling-birthdays/canonical-data.json @@ -116,7 +116,7 @@ "description": "has matching birthdays without matching birthday pair", "property": "hasMatchingBirthdays", "input": { - "birthdays": ["1984-04-05", "2000-09-17", "1966-10-12"] + "birthdates": ["1984-04-05", "2000-09-17", "1966-10-12"] }, "expected": false }, From 3af6486dba9d4c251fd1b68900dd0a3ddc37a1ed Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Sun, 9 Mar 2025 12:19:37 +0100 Subject: [PATCH 28/34] Update canonical-data.json Co-authored-by: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com> --- exercises/baffling-birthdays/canonical-data.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/baffling-birthdays/canonical-data.json b/exercises/baffling-birthdays/canonical-data.json index 76af343cea..eeb9a37c16 100644 --- a/exercises/baffling-birthdays/canonical-data.json +++ b/exercises/baffling-birthdays/canonical-data.json @@ -107,7 +107,7 @@ "description": "has matching birthdays with matching birthday pair", "property": "hasMatchingBirthdays", "input": { - "birthdays": ["1970-01-19", "1975-06-03", "2003-01-19"] + "birthdates": ["1970-01-19", "1975-06-03", "2003-01-19"] }, "expected": true }, From 3a0a25753d107d2c9202a5fe9544caf0ebdb447c Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Sun, 9 Mar 2025 18:42:05 +0100 Subject: [PATCH 29/34] Use nesting and improve naming --- .../baffling-birthdays/canonical-data.json | 302 ++++++++++-------- 1 file changed, 161 insertions(+), 141 deletions(-) diff --git a/exercises/baffling-birthdays/canonical-data.json b/exercises/baffling-birthdays/canonical-data.json index eeb9a37c16..61b314ec17 100644 --- a/exercises/baffling-birthdays/canonical-data.json +++ b/exercises/baffling-birthdays/canonical-data.json @@ -9,156 +9,176 @@ ], "cases": [ { - "uuid": "f7b3eb26-bcfc-4c1e-a2de-af07afc33f45", - "description": "matching birthday for same date", - "property": "matchingBirthday", - "input": { - "birthdate1": "2000-01-01", - "birthdate2": "2000-01-01" - }, - "expected": true - }, - { - "uuid": "7193409a-6e16-4bcb-b4cc-9ffe55f79b25", - "description": "matching birthday for same year and month but different day", - "property": "matchingBirthday", - "input": { - "birthdate1": "2012-05-09", - "birthdate2": "2012-05-17" - }, - "expected": false - }, - { - "uuid": "d04db648-121b-4b72-93e8-d7d2dced4495", - "description": "matching birthday for same month and day but different year", - "property": "matchingBirthday", - "input": { - "birthdate1": "1999-10-23", - "birthdate2": "1988-10-23" - }, - "expected": true - }, - { - "uuid": "3c8bd0f0-14c6-4d4c-975a-4c636bfdc233", - "description": "matching birthday for same year but different month and day", - "property": "matchingBirthday", - "input": { - "birthdate1": "2007-12-19", - "birthdate2": "2007-04-27" - }, - "expected": false - }, - { - "uuid": "df5daba6-0879-4480-883c-e855c99cdaa3", - "description": "matching birthday for different year, month and day", - "property": "matchingBirthday", - "input": { - "birthdate1": "1997-08-04", - "birthdate2": "1963-11-23" - }, - "expected": false - }, - { - "uuid": "70b38cea-d234-4697-b146-7d130cd4ee12", - "description": "random birthdates generates requested number of birthdays", - "scenarios": ["random"], - "property": "randomBirthdates", - "input": {}, - "expected": "length == groupsize" - }, - { - "uuid": "d9d5b7d3-5fea-4752-b9c1-3fcd176d1b03", - "description": "random birthdates have non-leap year", - "scenarios": ["random"], - "property": "randomBirthdates", - "input": {}, - "expected": { - "years": { - "leapYear": false + "description": "matching birthday", + "cases": [ + { + "uuid": "f7b3eb26-bcfc-4c1e-a2de-af07afc33f45", + "description": "same year, month, and day", + "property": "matchingBirthday", + "input": { + "birthdate1": "2000-01-01", + "birthdate2": "2000-01-01" + }, + "expected": true + }, + { + "uuid": "7193409a-6e16-4bcb-b4cc-9ffe55f79b25", + "description": "same year and month, but different day", + "property": "matchingBirthday", + "input": { + "birthdate1": "2012-05-09", + "birthdate2": "2012-05-17" + }, + "expected": false + }, + { + "uuid": "d04db648-121b-4b72-93e8-d7d2dced4495", + "description": "same month and day, but different year", + "property": "matchingBirthday", + "input": { + "birthdate1": "1999-10-23", + "birthdate2": "1988-10-23" + }, + "expected": true + }, + { + "uuid": "3c8bd0f0-14c6-4d4c-975a-4c636bfdc233", + "description": "same year, but different month and day", + "property": "matchingBirthday", + "input": { + "birthdate1": "2007-12-19", + "birthdate2": "2007-04-27" + }, + "expected": false + }, + { + "uuid": "df5daba6-0879-4480-883c-e855c99cdaa3", + "description": "different year, month, and day", + "property": "matchingBirthday", + "input": { + "birthdate1": "1997-08-04", + "birthdate2": "1963-11-23" + }, + "expected": false } - } + ] }, { - "uuid": "d1074327-f68c-4c8a-b0ff-e3730d0f0521", - "description": "random birthdates have random month", - "scenarios": ["random"], - "property": "randomBirthdates", - "input": {}, - "expected": { - "months": { - "random": true + "description": "random birthdates", + "cases": [ + { + "uuid": "70b38cea-d234-4697-b146-7d130cd4ee12", + "description": "generate requested number of birthdates", + "scenarios": ["random"], + "property": "randomBirthdates", + "input": {}, + "expected": "length == groupsize" + }, + { + "uuid": "d9d5b7d3-5fea-4752-b9c1-3fcd176d1b03", + "description": "years are not leap years", + "scenarios": ["random"], + "property": "randomBirthdates", + "input": {}, + "expected": { + "years": { + "leapYear": false + } + } + }, + { + "uuid": "d1074327-f68c-4c8a-b0ff-e3730d0f0521", + "description": "months are random", + "scenarios": ["random"], + "property": "randomBirthdates", + "input": {}, + "expected": { + "months": { + "random": true + } + } + }, + { + "uuid": "7df706b3-c3f5-471d-9563-23a4d0577940", + "description": "days are random", + "scenarios": ["random"], + "property": "randomBirthdates", + "input": {}, + "expected": { + "days": { + "random": true + } + } } - } + ] }, { - "uuid": "7df706b3-c3f5-471d-9563-23a4d0577940", - "description": "random birthdates have random day", - "scenarios": ["random"], - "property": "randomBirthdates", - "input": {}, - "expected": { - "days": { - "random": true + "description": "has shared birthdays", + "cases": [ + { + "uuid": "ade37c87-f41d-4929-962a-286b4d1d048a", + "description": "with match", + "property": "hasSharedBirthday", + "input": { + "birthdates": ["1970-01-19", "1975-06-03", "2003-01-19"] + }, + "expected": true + }, + { + "uuid": "1d155b33-c6e1-46b9-81fa-09123ae378ea", + "description": "without match", + "property": "hasSharedBirthday", + "input": { + "birthdates": ["1984-04-05", "2000-09-17", "1966-10-12"] + }, + "expected": false } - } + ] }, { - "uuid": "ade37c87-f41d-4929-962a-286b4d1d048a", - "description": "has matching birthdays with matching birthday pair", - "property": "hasMatchingBirthdays", - "input": { - "birthdates": ["1970-01-19", "1975-06-03", "2003-01-19"] - }, - "expected": true - }, - { - "uuid": "1d155b33-c6e1-46b9-81fa-09123ae378ea", - "description": "has matching birthdays without matching birthday pair", - "property": "hasMatchingBirthdays", - "input": { - "birthdates": ["1984-04-05", "2000-09-17", "1966-10-12"] - }, - "expected": false - }, - { - "uuid": "89a462a4-4265-4912-9506-fb027913f221", - "description": "probability for matching birthday pair for one person", - "scenarios": ["random"], - "property": "probabilityForMatchingBirthdays", - "input": { - "groupSize": 1 - }, - "expected": 0.0 - }, - { - "uuid": "ec31c787-0ebb-4548-970c-5dcb4eadfb5f", - "description": "probability for matching birthday pair for ten people", - "scenarios": ["random"], - "property": "probabilityForMatchingBirthdays", - "input": { - "groupSize": 10 - }, - "expected": 11.694818 - }, - { - "uuid": "b548afac-a451-46a3-9bb0-cb1f60c48e2f", - "description": "probability for matching birthday pair for twenty-three people", - "scenarios": ["random"], - "property": "probabilityForMatchingBirthdays", - "input": { - "groupSize": 23 - }, - "expected": 50.729723 - }, - { - "uuid": "e43e6b9d-d77b-4f6c-a960-0fc0129a0bc5", - "description": "probability for matching birthday pair for seventy people", - "scenarios": ["random"], - "property": "probabilityForMatchingBirthdays", - "input": { - "groupSize": 70 - }, - "expected": 99.915958 + "description": "probability of at least one shared birthday", + "cases": [ + { + "uuid": "89a462a4-4265-4912-9506-fb027913f221", + "description": "for one person", + "scenarios": ["random"], + "property": "probabilityForSharedBirthday", + "input": { + "groupSize": 1 + }, + "expected": 0.0 + }, + { + "uuid": "ec31c787-0ebb-4548-970c-5dcb4eadfb5f", + "description": "among ten people", + "scenarios": ["random"], + "property": "probabilityForSharedBirthday", + "input": { + "groupSize": 10 + }, + "expected": 11.694818 + }, + { + "uuid": "b548afac-a451-46a3-9bb0-cb1f60c48e2f", + "description": "among twenty-three people", + "scenarios": ["random"], + "property": "probabilityForSharedBirthday", + "input": { + "groupSize": 23 + }, + "expected": 50.729723 + }, + { + "uuid": "e43e6b9d-d77b-4f6c-a960-0fc0129a0bc5", + "description": "among seventy people", + "scenarios": ["random"], + "property": "probabilityForSharedBirthday", + "input": { + "groupSize": 70 + }, + "expected": 99.915958 + } + ] } ] } From 8f5576210bb893bffab791ab9e63d40a39cb98e7 Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Sun, 9 Mar 2025 20:04:04 +0100 Subject: [PATCH 30/34] More work --- .../baffling-birthdays/canonical-data.json | 22 +++++++++---------- exercises/baffling-birthdays/instructions.md | 2 +- exercises/baffling-birthdays/introduction.md | 6 ++--- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/exercises/baffling-birthdays/canonical-data.json b/exercises/baffling-birthdays/canonical-data.json index 61b314ec17..5de0d17020 100644 --- a/exercises/baffling-birthdays/canonical-data.json +++ b/exercises/baffling-birthdays/canonical-data.json @@ -9,12 +9,12 @@ ], "cases": [ { - "description": "matching birthday", + "description": "shared birthday", "cases": [ { "uuid": "f7b3eb26-bcfc-4c1e-a2de-af07afc33f45", "description": "same year, month, and day", - "property": "matchingBirthday", + "property": "sharedBirthday", "input": { "birthdate1": "2000-01-01", "birthdate2": "2000-01-01" @@ -24,7 +24,7 @@ { "uuid": "7193409a-6e16-4bcb-b4cc-9ffe55f79b25", "description": "same year and month, but different day", - "property": "matchingBirthday", + "property": "sharedBirthday", "input": { "birthdate1": "2012-05-09", "birthdate2": "2012-05-17" @@ -34,7 +34,7 @@ { "uuid": "d04db648-121b-4b72-93e8-d7d2dced4495", "description": "same month and day, but different year", - "property": "matchingBirthday", + "property": "sharedBirthday", "input": { "birthdate1": "1999-10-23", "birthdate2": "1988-10-23" @@ -44,7 +44,7 @@ { "uuid": "3c8bd0f0-14c6-4d4c-975a-4c636bfdc233", "description": "same year, but different month and day", - "property": "matchingBirthday", + "property": "sharedBirthday", "input": { "birthdate1": "2007-12-19", "birthdate2": "2007-04-27" @@ -54,7 +54,7 @@ { "uuid": "df5daba6-0879-4480-883c-e855c99cdaa3", "description": "different year, month, and day", - "property": "matchingBirthday", + "property": "sharedBirthday", "input": { "birthdate1": "1997-08-04", "birthdate2": "1963-11-23" @@ -113,12 +113,12 @@ ] }, { - "description": "has shared birthdays", + "description": "contains shared birthdays", "cases": [ { "uuid": "ade37c87-f41d-4929-962a-286b4d1d048a", - "description": "with match", - "property": "hasSharedBirthday", + "description": "with shared birthday", + "property": "containsSharedBirthday", "input": { "birthdates": ["1970-01-19", "1975-06-03", "2003-01-19"] }, @@ -126,8 +126,8 @@ }, { "uuid": "1d155b33-c6e1-46b9-81fa-09123ae378ea", - "description": "without match", - "property": "hasSharedBirthday", + "description": "without shared birthday", + "property": "containsSharedBirthday", "input": { "birthdates": ["1984-04-05", "2000-09-17", "1966-10-12"] }, diff --git a/exercises/baffling-birthdays/instructions.md b/exercises/baffling-birthdays/instructions.md index 544f95bac2..0d0c95484d 100644 --- a/exercises/baffling-birthdays/instructions.md +++ b/exercises/baffling-birthdays/instructions.md @@ -6,7 +6,7 @@ To do this, you need to: - Determine if two birthdates have the same month and day. - Generate random birthdates. -- Check if a collection of randomly generated birthdates contains any two with the same birthday. +- Check if a collection of randomly generated birthdates contains at least two with the same birthday. - Estimate the probability that at least two people in a group share the same birthday for different group sizes. ~~~~exercism/note diff --git a/exercises/baffling-birthdays/introduction.md b/exercises/baffling-birthdays/introduction.md index 9f5636b891..e4a86267fb 100644 --- a/exercises/baffling-birthdays/introduction.md +++ b/exercises/baffling-birthdays/introduction.md @@ -3,10 +3,10 @@ Fresh out of college, you're throwing a huge party to celebrate with friends and family. Over 70 people have shown up, including your mildly eccentric Uncle Ted. -In one of his usual antics, he bets you £100 that at least two people in the room share the same birthday. -That sounds ridiculous — there are many more possible birthdays, so you confidently accept. +In one of his usual antics, he bets you £100 that at least two people in the room share their birthdays. +That sounds ridiculous — there are many more possible birthdays than there are guests, so you confidently accept. -To your astonishment, after collecting just 32 birthdays, you've already found a match. +To your astonishment, after collecting the birthdays of just 32 guests, you've already found two guests that share the same birthday. Accepting your loss, you hand Uncle Ted his £100, but something feels off. The next day, curiosity gets the better of you. From 7019b7195fd3a7a6606ee4829487ee8ea20c7ab1 Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Mon, 10 Mar 2025 19:06:16 +0100 Subject: [PATCH 31/34] Merge properties --- .../baffling-birthdays/canonical-data.json | 111 +++++++++++------- 1 file changed, 68 insertions(+), 43 deletions(-) diff --git a/exercises/baffling-birthdays/canonical-data.json b/exercises/baffling-birthdays/canonical-data.json index 5de0d17020..09b4e37c62 100644 --- a/exercises/baffling-birthdays/canonical-data.json +++ b/exercises/baffling-birthdays/canonical-data.json @@ -11,55 +11,103 @@ { "description": "shared birthday", "cases": [ + { + "uuid": "716dcc2b-8fe4-4fc9-8c48-cbe70d8e6b67", + "description": "one birthdate", + "property": "sharedBirthday", + "input": { + "birthdates": ["2000-01-01"] + }, + "expected": false + }, + , { "uuid": "f7b3eb26-bcfc-4c1e-a2de-af07afc33f45", - "description": "same year, month, and day", + "description": "two birthdates with same year, month, and day", "property": "sharedBirthday", "input": { - "birthdate1": "2000-01-01", - "birthdate2": "2000-01-01" + "birthdates": ["2000-01-01", "2000-01-01"] }, "expected": true }, { "uuid": "7193409a-6e16-4bcb-b4cc-9ffe55f79b25", - "description": "same year and month, but different day", + "description": "two birthdates with same year and month, but different day", "property": "sharedBirthday", "input": { - "birthdate1": "2012-05-09", - "birthdate2": "2012-05-17" + "birthdates": ["2012-05-09", "2012-05-17"] }, "expected": false }, { "uuid": "d04db648-121b-4b72-93e8-d7d2dced4495", - "description": "same month and day, but different year", + "description": "two birthdates with same month and day, but different year", "property": "sharedBirthday", "input": { - "birthdate1": "1999-10-23", - "birthdate2": "1988-10-23" + "birthdates": ["1999-10-23", "1988-10-23"] }, "expected": true }, { "uuid": "3c8bd0f0-14c6-4d4c-975a-4c636bfdc233", - "description": "same year, but different month and day", + "description": "two birthdates with same year, but different month and day", "property": "sharedBirthday", "input": { - "birthdate1": "2007-12-19", - "birthdate2": "2007-04-27" + "birthdates": ["2007-12-19", "2007-04-27"] }, "expected": false }, { "uuid": "df5daba6-0879-4480-883c-e855c99cdaa3", - "description": "different year, month, and day", + "description": "two birthdates with different year, month, and day", "property": "sharedBirthday", "input": { - "birthdate1": "1997-08-04", - "birthdate2": "1963-11-23" + "birthdates": ["1997-08-04", "1963-11-23"] }, "expected": false + }, + { + "uuid": "0c17b220-cbb9-4bd7-872f-373044c7b406", + "description": "multiple birthdates without shared birthday", + "property": "sharedBirthday", + "input": { + "birthdates": [ + "1966-07-29", + "1977-02-12", + "2001-12-25", + "1980-11-10" + ] + }, + "expected": false + }, + { + "uuid": "966d6b0b-5c0a-4b8c-bc2d-64939ada49f8", + "description": "multiple birthdates with one shared birthday", + "property": "sharedBirthday", + "input": { + "birthdates": [ + "1966-07-29", + "1977-02-12", + "2001-07-29", + "1980-11-10" + ] + }, + "expected": true + }, + { + "uuid": "b7937d28-403b-4500-acce-4d9fe3a9620d", + "description": "multiple birthdates with more than one shared birthday", + "property": "sharedBirthday", + "input": { + "birthdates": [ + "1966-07-29", + "1977-02-12", + "2001-12-25", + "1980-07-29", + "2019-02-12" + ] + }, + "expected": true } ] }, @@ -113,36 +161,13 @@ ] }, { - "description": "contains shared birthdays", - "cases": [ - { - "uuid": "ade37c87-f41d-4929-962a-286b4d1d048a", - "description": "with shared birthday", - "property": "containsSharedBirthday", - "input": { - "birthdates": ["1970-01-19", "1975-06-03", "2003-01-19"] - }, - "expected": true - }, - { - "uuid": "1d155b33-c6e1-46b9-81fa-09123ae378ea", - "description": "without shared birthday", - "property": "containsSharedBirthday", - "input": { - "birthdates": ["1984-04-05", "2000-09-17", "1966-10-12"] - }, - "expected": false - } - ] - }, - { - "description": "probability of at least one shared birthday", + "description": "estimated probability of at least one shared birthday", "cases": [ { "uuid": "89a462a4-4265-4912-9506-fb027913f221", "description": "for one person", "scenarios": ["random"], - "property": "probabilityForSharedBirthday", + "property": "estimatedProbabilityOfSharedBirthday", "input": { "groupSize": 1 }, @@ -152,7 +177,7 @@ "uuid": "ec31c787-0ebb-4548-970c-5dcb4eadfb5f", "description": "among ten people", "scenarios": ["random"], - "property": "probabilityForSharedBirthday", + "property": "estimatedProbabilityOfSharedBirthday", "input": { "groupSize": 10 }, @@ -162,7 +187,7 @@ "uuid": "b548afac-a451-46a3-9bb0-cb1f60c48e2f", "description": "among twenty-three people", "scenarios": ["random"], - "property": "probabilityForSharedBirthday", + "property": "estimatedProbabilityOfSharedBirthday", "input": { "groupSize": 23 }, @@ -172,7 +197,7 @@ "uuid": "e43e6b9d-d77b-4f6c-a960-0fc0129a0bc5", "description": "among seventy people", "scenarios": ["random"], - "property": "probabilityForSharedBirthday", + "property": "estimatedProbabilityOfSharedBirthday", "input": { "groupSize": 70 }, From cddceb0a60160f6e88ddd32b93af4995749c7334 Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Mon, 10 Mar 2025 20:49:52 +0100 Subject: [PATCH 32/34] Update exercises/baffling-birthdays/canonical-data.json Co-authored-by: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com> --- exercises/baffling-birthdays/canonical-data.json | 1 - 1 file changed, 1 deletion(-) diff --git a/exercises/baffling-birthdays/canonical-data.json b/exercises/baffling-birthdays/canonical-data.json index 09b4e37c62..20c27169e3 100644 --- a/exercises/baffling-birthdays/canonical-data.json +++ b/exercises/baffling-birthdays/canonical-data.json @@ -20,7 +20,6 @@ }, "expected": false }, - , { "uuid": "f7b3eb26-bcfc-4c1e-a2de-af07afc33f45", "description": "two birthdates with same year, month, and day", From ead1f83cc6e9084ceeb3129d4a0e13383f5f83c7 Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Mon, 10 Mar 2025 20:50:01 +0100 Subject: [PATCH 33/34] Update exercises/baffling-birthdays/introduction.md Co-authored-by: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com> --- exercises/baffling-birthdays/introduction.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/baffling-birthdays/introduction.md b/exercises/baffling-birthdays/introduction.md index e4a86267fb..97dabd1e6c 100644 --- a/exercises/baffling-birthdays/introduction.md +++ b/exercises/baffling-birthdays/introduction.md @@ -3,7 +3,7 @@ Fresh out of college, you're throwing a huge party to celebrate with friends and family. Over 70 people have shown up, including your mildly eccentric Uncle Ted. -In one of his usual antics, he bets you £100 that at least two people in the room share their birthdays. +In one of his usual antics, he bets you £100 that at least two people in the room share the same birthday. That sounds ridiculous — there are many more possible birthdays than there are guests, so you confidently accept. To your astonishment, after collecting the birthdays of just 32 guests, you've already found two guests that share the same birthday. From 9ba5c1d0cab253113a18946d3847cf8307f6c65c Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Tue, 11 Mar 2025 10:27:54 +0100 Subject: [PATCH 34/34] Update exercises/baffling-birthdays/instructions.md Co-authored-by: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com> --- exercises/baffling-birthdays/instructions.md | 1 - 1 file changed, 1 deletion(-) diff --git a/exercises/baffling-birthdays/instructions.md b/exercises/baffling-birthdays/instructions.md index 0d0c95484d..a01ec86796 100644 --- a/exercises/baffling-birthdays/instructions.md +++ b/exercises/baffling-birthdays/instructions.md @@ -4,7 +4,6 @@ Your task is to estimate the birthday paradox's probabilities. To do this, you need to: -- Determine if two birthdates have the same month and day. - Generate random birthdates. - Check if a collection of randomly generated birthdates contains at least two with the same birthday. - Estimate the probability that at least two people in a group share the same birthday for different group sizes.