Skip to content

Commit fa475a9

Browse files
committed
Merge branch 'main' of github.com:exercism/problem-specifications into exercise/intergalactic-transmission
2 parents cbfcebd + 30931f4 commit fa475a9

File tree

13 files changed

+354
-51
lines changed

13 files changed

+354
-51
lines changed

.github/workflows/action-format.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
run: ./bin/reorder-keys
6666

6767
- name: Use Node.js LTS (16.x)
68-
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8
68+
uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e
6969
with:
7070
node-version: '16'
7171

@@ -75,7 +75,7 @@ jobs:
7575
run: echo "::set-output name=dir::$(yarn cache dir)"
7676

7777
- name: Cache yarn
78-
uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf
78+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684
7979
id: yarn-cache
8080
with:
8181
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.0.0
4747

4848
- name: Setup nodejs
49-
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
49+
uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
5050
with:
5151
node-version: 16
5252
cache: "yarn"
@@ -124,7 +124,7 @@ jobs:
124124
**/*.md
125125
126126
- name: Setup nodejs
127-
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
127+
uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
128128
with:
129129
node-version: 16
130130
cache: "yarn"
@@ -148,7 +148,7 @@ jobs:
148148
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.0.0
149149

150150
- name: Check links
151-
uses: lycheeverse/lychee-action@f613c4a64e50d792e0b31ec34bbcbba12263c6a6 # 2.3.0
151+
uses: lycheeverse/lychee-action@1d97d84f0bc547f7b25f4c2170d87d810dc2fb2c # 2.4.0
152152
with:
153153
args: --require-https --user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36" --no-progress **/*.md **/*.html **/*.toml **/*.json
154154
fail: true
@@ -162,7 +162,7 @@ jobs:
162162
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.0.0
163163

164164
- name: Setup nodejs
165-
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
165+
uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
166166
with:
167167
node-version: 16
168168
cache: "yarn"
Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
{
2+
"exercise": "baffling-birthdays",
3+
"comments": [
4+
"Dates are formatted as 'YYYY-MM-DD'.",
5+
"",
6+
"To increase the likelihood of consistent result, the tests should run the code returning random results many times.",
7+
"",
8+
"The expected probability values should be compared using some tolerance to allow for small deviations."
9+
],
10+
"cases": [
11+
{
12+
"description": "shared birthday",
13+
"cases": [
14+
{
15+
"uuid": "716dcc2b-8fe4-4fc9-8c48-cbe70d8e6b67",
16+
"description": "one birthdate",
17+
"property": "sharedBirthday",
18+
"input": {
19+
"birthdates": ["2000-01-01"]
20+
},
21+
"expected": false
22+
},
23+
{
24+
"uuid": "f7b3eb26-bcfc-4c1e-a2de-af07afc33f45",
25+
"description": "two birthdates with same year, month, and day",
26+
"property": "sharedBirthday",
27+
"input": {
28+
"birthdates": ["2000-01-01", "2000-01-01"]
29+
},
30+
"expected": true
31+
},
32+
{
33+
"uuid": "7193409a-6e16-4bcb-b4cc-9ffe55f79b25",
34+
"description": "two birthdates with same year and month, but different day",
35+
"property": "sharedBirthday",
36+
"input": {
37+
"birthdates": ["2012-05-09", "2012-05-17"]
38+
},
39+
"expected": false
40+
},
41+
{
42+
"uuid": "d04db648-121b-4b72-93e8-d7d2dced4495",
43+
"description": "two birthdates with same month and day, but different year",
44+
"property": "sharedBirthday",
45+
"input": {
46+
"birthdates": ["1999-10-23", "1988-10-23"]
47+
},
48+
"expected": true
49+
},
50+
{
51+
"uuid": "3c8bd0f0-14c6-4d4c-975a-4c636bfdc233",
52+
"description": "two birthdates with same year, but different month and day",
53+
"property": "sharedBirthday",
54+
"input": {
55+
"birthdates": ["2007-12-19", "2007-04-27"]
56+
},
57+
"expected": false
58+
},
59+
{
60+
"uuid": "df5daba6-0879-4480-883c-e855c99cdaa3",
61+
"description": "two birthdates with different year, month, and day",
62+
"property": "sharedBirthday",
63+
"input": {
64+
"birthdates": ["1997-08-04", "1963-11-23"]
65+
},
66+
"expected": false
67+
},
68+
{
69+
"uuid": "0c17b220-cbb9-4bd7-872f-373044c7b406",
70+
"description": "multiple birthdates without shared birthday",
71+
"property": "sharedBirthday",
72+
"input": {
73+
"birthdates": [
74+
"1966-07-29",
75+
"1977-02-12",
76+
"2001-12-25",
77+
"1980-11-10"
78+
]
79+
},
80+
"expected": false
81+
},
82+
{
83+
"uuid": "966d6b0b-5c0a-4b8c-bc2d-64939ada49f8",
84+
"description": "multiple birthdates with one shared birthday",
85+
"property": "sharedBirthday",
86+
"input": {
87+
"birthdates": [
88+
"1966-07-29",
89+
"1977-02-12",
90+
"2001-07-29",
91+
"1980-11-10"
92+
]
93+
},
94+
"expected": true
95+
},
96+
{
97+
"uuid": "b7937d28-403b-4500-acce-4d9fe3a9620d",
98+
"description": "multiple birthdates with more than one shared birthday",
99+
"property": "sharedBirthday",
100+
"input": {
101+
"birthdates": [
102+
"1966-07-29",
103+
"1977-02-12",
104+
"2001-12-25",
105+
"1980-07-29",
106+
"2019-02-12"
107+
]
108+
},
109+
"expected": true
110+
}
111+
]
112+
},
113+
{
114+
"description": "random birthdates",
115+
"cases": [
116+
{
117+
"uuid": "70b38cea-d234-4697-b146-7d130cd4ee12",
118+
"description": "generate requested number of birthdates",
119+
"scenarios": ["random"],
120+
"property": "randomBirthdates",
121+
"input": {},
122+
"expected": "length == groupsize"
123+
},
124+
{
125+
"uuid": "d9d5b7d3-5fea-4752-b9c1-3fcd176d1b03",
126+
"description": "years are not leap years",
127+
"scenarios": ["random"],
128+
"property": "randomBirthdates",
129+
"input": {},
130+
"expected": {
131+
"years": {
132+
"leapYear": false
133+
}
134+
}
135+
},
136+
{
137+
"uuid": "d1074327-f68c-4c8a-b0ff-e3730d0f0521",
138+
"description": "months are random",
139+
"scenarios": ["random"],
140+
"property": "randomBirthdates",
141+
"input": {},
142+
"expected": {
143+
"months": {
144+
"random": true
145+
}
146+
}
147+
},
148+
{
149+
"uuid": "7df706b3-c3f5-471d-9563-23a4d0577940",
150+
"description": "days are random",
151+
"scenarios": ["random"],
152+
"property": "randomBirthdates",
153+
"input": {},
154+
"expected": {
155+
"days": {
156+
"random": true
157+
}
158+
}
159+
}
160+
]
161+
},
162+
{
163+
"description": "estimated probability of at least one shared birthday",
164+
"cases": [
165+
{
166+
"uuid": "89a462a4-4265-4912-9506-fb027913f221",
167+
"description": "for one person",
168+
"scenarios": ["random"],
169+
"property": "estimatedProbabilityOfSharedBirthday",
170+
"input": {
171+
"groupSize": 1
172+
},
173+
"expected": 0.0
174+
},
175+
{
176+
"uuid": "ec31c787-0ebb-4548-970c-5dcb4eadfb5f",
177+
"description": "among ten people",
178+
"scenarios": ["random"],
179+
"property": "estimatedProbabilityOfSharedBirthday",
180+
"input": {
181+
"groupSize": 10
182+
},
183+
"expected": 11.694818
184+
},
185+
{
186+
"uuid": "b548afac-a451-46a3-9bb0-cb1f60c48e2f",
187+
"description": "among twenty-three people",
188+
"scenarios": ["random"],
189+
"property": "estimatedProbabilityOfSharedBirthday",
190+
"input": {
191+
"groupSize": 23
192+
},
193+
"expected": 50.729723
194+
},
195+
{
196+
"uuid": "e43e6b9d-d77b-4f6c-a960-0fc0129a0bc5",
197+
"description": "among seventy people",
198+
"scenarios": ["random"],
199+
"property": "estimatedProbabilityOfSharedBirthday",
200+
"input": {
201+
"groupSize": 70
202+
},
203+
"expected": 99.915958
204+
}
205+
]
206+
}
207+
]
208+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Instructions
2+
3+
Your task is to estimate the birthday paradox's probabilities.
4+
5+
To do this, you need to:
6+
7+
- Generate random birthdates.
8+
- Check if a collection of randomly generated birthdates contains at least two with the same birthday.
9+
- Estimate the probability that at least two people in a group share the same birthday for different group sizes.
10+
11+
~~~~exercism/note
12+
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.
13+
Two birthdates with the same month and day correspond to the same birthday.
14+
~~~~
15+
16+
~~~~exercism/caution
17+
The birthday paradox assumes that:
18+
19+
- There are 365 possible birthdays (no leap years).
20+
- Each birthday is equally likely (uniform distribution).
21+
22+
Your implementation must follow these assumptions.
23+
~~~~
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Introduction
2+
3+
Fresh out of college, you're throwing a huge party to celebrate with friends and family.
4+
Over 70 people have shown up, including your mildly eccentric Uncle Ted.
5+
6+
In one of his usual antics, he bets you £100 that at least two people in the room share the same birthday.
7+
That sounds ridiculous — there are many more possible birthdays than there are guests, so you confidently accept.
8+
9+
To your astonishment, after collecting the birthdays of just 32 guests, you've already found two guests that share the same birthday.
10+
Accepting your loss, you hand Uncle Ted his £100, but something feels off.
11+
12+
The next day, curiosity gets the better of you.
13+
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%.
14+
15+
Ah. So _that's_ why Uncle Ted was so confident.
16+
17+
Determined to turn the tables, you start looking up other paradoxes; next time, _you'll_ be the one making the bets.
18+
19+
~~~~exercism/note
20+
The birthday paradox is a [veridical paradox][veridical-paradox]: even though it feels wrong, it is actually true.
21+
22+
[veridical-paradox]: https://en.wikipedia.org/wiki/Paradox#Quine's_classification
23+
~~~~
24+
25+
[birthday-problem]: https://en.wikipedia.org/wiki/Birthday_problem
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
title = "Baffling Birthdays"
2+
blurb = "Estimate the birthday paradox's probabilities."
3+
source = "Erik Schierboom"
4+
source_url = "https://github.com/exercism/problem-specifications/pull/2539"

exercises/largest-series-product/canonical-data.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,19 @@
113113
"error": "span must be smaller than string length"
114114
}
115115
},
116+
{
117+
"uuid": "0ae1ce53-d9ba-41bb-827f-2fceb64f058b",
118+
"reimplements": "5d81aaf7-4f67-4125-bf33-11493cc7eab7",
119+
"description": "rejects span longer than string length",
120+
"property": "largestProduct",
121+
"input": {
122+
"digits": "123",
123+
"span": 4
124+
},
125+
"expected": {
126+
"error": "span must not exceed string length"
127+
}
128+
},
116129
{
117130
"uuid": "06bc8b90-0c51-4c54-ac22-3ec3893a079e",
118131
"description": "reports 1 for empty string and empty product (0 span)",
@@ -163,6 +176,19 @@
163176
"error": "span must be smaller than string length"
164177
}
165178
},
179+
{
180+
"uuid": "6cf66098-a6af-4223-aab1-26aeeefc7402",
181+
"reimplements": "6d96c691-4374-4404-80ee-2ea8f3613dd4",
182+
"description": "rejects empty string and nonzero span",
183+
"property": "largestProduct",
184+
"input": {
185+
"digits": "",
186+
"span": 1
187+
},
188+
"expected": {
189+
"error": "span must not exceed string length"
190+
}
191+
},
166192
{
167193
"uuid": "7a38f2d6-3c35-45f6-8d6f-12e6e32d4d74",
168194
"description": "rejects invalid character in digits",

0 commit comments

Comments
 (0)