Skip to content

Commit 9cf4f70

Browse files
Add meetup exercise (#340)
1 parent 59019c5 commit 9cf4f70

8 files changed

Lines changed: 789 additions & 0 deletions

File tree

config.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,14 @@
709709
"prerequisites": [],
710710
"difficulty": 5
711711
},
712+
{
713+
"slug": "meetup",
714+
"name": "Meetup",
715+
"uuid": "5bd16c82-2889-4719-89e9-3af135f4d82b",
716+
"practices": [],
717+
"prerequisites": [],
718+
"difficulty": 5
719+
},
712720
{
713721
"slug": "pig-latin",
714722
"name": "Pig Latin",
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Instructions
2+
3+
Your task is to find the exact date of a meetup, given a month, year, weekday and week.
4+
5+
There are six week values to consider: `first`, `second`, `third`, `fourth`, `last`, `teenth`.
6+
7+
For example, you might be asked to find the date for the meetup on the first Monday in January 2018 (January 1, 2018).
8+
9+
Similarly, you might be asked to find:
10+
11+
- the third Tuesday of August 2019 (August 20, 2019)
12+
- the teenth Wednesday of May 2020 (May 13, 2020)
13+
- the fourth Sunday of July 2021 (July 25, 2021)
14+
- the last Thursday of November 2022 (November 24, 2022)
15+
- the teenth Saturday of August 1953 (August 15, 1953)
16+
17+
## Teenth
18+
19+
The teenth week refers to the seven days in a month that end in '-teenth' (13th, 14th, 15th, 16th, 17th, 18th and 19th).
20+
21+
If asked to find the teenth Saturday of August, 1953, we check its calendar:
22+
23+
```plaintext
24+
August 1953
25+
Su Mo Tu We Th Fr Sa
26+
1
27+
2 3 4 5 6 7 8
28+
9 10 11 12 13 14 15
29+
16 17 18 19 20 21 22
30+
23 24 25 26 27 28 29
31+
30 31
32+
```
33+
34+
From this we find that the teenth Saturday is August 15, 1953.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Introduction
2+
3+
Every month, your partner meets up with their best friend.
4+
Both of them have very busy schedules, making it challenging to find a suitable date!
5+
Given your own busy schedule, your partner always double-checks potential meetup dates with you:
6+
7+
- "Can I meet up on the first Friday of next month?"
8+
- "What about the third Wednesday?"
9+
- "Maybe the last Sunday?"
10+
11+
In this month's call, your partner asked you this question:
12+
13+
- "I'd like to meet up on the teenth Thursday; is that okay?"
14+
15+
Confused, you ask what a "teenth" day is.
16+
Your partner explains that a teenth day, a concept they made up, refers to the days in a month that end in '-teenth':
17+
18+
- 13th (thirteenth)
19+
- 14th (fourteenth)
20+
- 15th (fifteenth)
21+
- 16th (sixteenth)
22+
- 17th (seventeenth)
23+
- 18th (eighteenth)
24+
- 19th (nineteenth)
25+
26+
As there are also seven weekdays, it is guaranteed that each day of the week has _exactly one_ teenth day each month.
27+
28+
Now that you understand the concept of a teenth day, you check your calendar.
29+
You don't have anything planned on the teenth Thursday, so you happily confirm the date with your partner.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"authors": [
3+
"keiravillekode"
4+
],
5+
"files": {
6+
"solution": [
7+
"source/meetup.d"
8+
],
9+
"test": [
10+
"source/meetup.d"
11+
],
12+
"example": [
13+
"example/meetup.d"
14+
]
15+
},
16+
"blurb": "Calculate the date of meetups.",
17+
"source": "Jeremy Hinegardner mentioned a Boulder meetup that happens on the Wednesteenth of every month"
18+
}
Lines changed: 295 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,295 @@
1+
# This is an auto-generated file.
2+
#
3+
# Regenerating this file via `configlet sync` will:
4+
# - Recreate every `description` key/value pair
5+
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
6+
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
7+
# - Preserve any other key/value pair
8+
#
9+
# As user-added comments (using the # character) will be removed when this file
10+
# is regenerated, comments can be added via a `comment` key.
11+
12+
[d7f8eadd-d4fc-46ee-8a20-e97bd3fd01c8]
13+
description = "when teenth Monday is the 13th, the first day of the teenth week"
14+
15+
[f78373d1-cd53-4a7f-9d37-e15bf8a456b4]
16+
description = "when teenth Monday is the 19th, the last day of the teenth week"
17+
18+
[8c78bea7-a116-425b-9c6b-c9898266d92a]
19+
description = "when teenth Monday is some day in the middle of the teenth week"
20+
21+
[cfef881b-9dc9-4d0b-8de4-82d0f39fc271]
22+
description = "when teenth Tuesday is the 19th, the last day of the teenth week"
23+
24+
[69048961-3b00-41f9-97ee-eb6d83a8e92b]
25+
description = "when teenth Tuesday is some day in the middle of the teenth week"
26+
27+
[d30bade8-3622-466a-b7be-587414e0caa6]
28+
description = "when teenth Tuesday is the 13th, the first day of the teenth week"
29+
30+
[8db4b58b-92f3-4687-867b-82ee1a04f851]
31+
description = "when teenth Wednesday is some day in the middle of the teenth week"
32+
33+
[6c27a2a2-28f8-487f-ae81-35d08c4664f7]
34+
description = "when teenth Wednesday is the 13th, the first day of the teenth week"
35+
36+
[008a8674-1958-45b5-b8e6-c2c9960d973a]
37+
description = "when teenth Wednesday is the 19th, the last day of the teenth week"
38+
39+
[e4abd5e3-57cb-4091-8420-d97e955c0dbd]
40+
description = "when teenth Thursday is some day in the middle of the teenth week"
41+
42+
[85da0b0f-eace-4297-a6dd-63588d5055b4]
43+
description = "when teenth Thursday is the 13th, the first day of the teenth week"
44+
45+
[ecf64f9b-8413-489b-bf6e-128045f70bcc]
46+
description = "when teenth Thursday is the 19th, the last day of the teenth week"
47+
48+
[ac4e180c-7d0a-4d3d-b05f-f564ebb584ca]
49+
description = "when teenth Friday is the 19th, the last day of the teenth week"
50+
51+
[b79101c7-83ad-4f8f-8ec8-591683296315]
52+
description = "when teenth Friday is some day in the middle of the teenth week"
53+
54+
[6ed38b9f-0072-4901-bd97-7c8b8b0ef1b8]
55+
description = "when teenth Friday is the 13th, the first day of the teenth week"
56+
57+
[dfae03ed-9610-47de-a632-655ab01e1e7c]
58+
description = "when teenth Saturday is some day in the middle of the teenth week"
59+
60+
[ec02e3e1-fc72-4a3c-872f-a53fa8ab358e]
61+
description = "when teenth Saturday is the 13th, the first day of the teenth week"
62+
63+
[d983094b-7259-4195-b84e-5d09578c89d9]
64+
description = "when teenth Saturday is the 19th, the last day of the teenth week"
65+
66+
[d84a2a2e-f745-443a-9368-30051be60c2e]
67+
description = "when teenth Sunday is the 19th, the last day of the teenth week"
68+
69+
[0e64bc53-92a3-4f61-85b2-0b7168c7ce5a]
70+
description = "when teenth Sunday is some day in the middle of the teenth week"
71+
72+
[de87652c-185e-4854-b3ae-04cf6150eead]
73+
description = "when teenth Sunday is the 13th, the first day of the teenth week"
74+
75+
[2cbfd0f5-ba3a-46da-a8cc-0fe4966d3411]
76+
description = "when first Monday is some day in the middle of the first week"
77+
78+
[a6168c7c-ed95-4bb3-8f92-c72575fc64b0]
79+
description = "when first Monday is the 1st, the first day of the first week"
80+
81+
[1bfc620f-1c54-4bbd-931f-4a1cd1036c20]
82+
description = "when first Tuesday is the 7th, the last day of the first week"
83+
84+
[12959c10-7362-4ca0-a048-50cf1c06e3e2]
85+
description = "when first Tuesday is some day in the middle of the first week"
86+
87+
[1033dc66-8d0b-48a1-90cb-270703d59d1d]
88+
description = "when first Wednesday is some day in the middle of the first week"
89+
90+
[b89185b9-2f32-46f4-a602-de20b09058f6]
91+
description = "when first Wednesday is the 7th, the last day of the first week"
92+
93+
[53aedc4d-b2c8-4dfb-abf7-a8dc9cdceed5]
94+
description = "when first Thursday is some day in the middle of the first week"
95+
96+
[b420a7e3-a94c-4226-870a-9eb3a92647f0]
97+
description = "when first Thursday is another day in the middle of the first week"
98+
99+
[61df3270-28b4-4713-bee2-566fa27302ca]
100+
description = "when first Friday is the 1st, the first day of the first week"
101+
102+
[cad33d4d-595c-412f-85cf-3874c6e07abf]
103+
description = "when first Friday is some day in the middle of the first week"
104+
105+
[a2869b52-5bba-44f0-a863-07bd1f67eadb]
106+
description = "when first Saturday is some day in the middle of the first week"
107+
108+
[3585315a-d0db-4ea1-822e-0f22e2a645f5]
109+
description = "when first Saturday is another day in the middle of the first week"
110+
111+
[c49e9bd9-8ccf-4cf2-947a-0ccd4e4f10b1]
112+
description = "when first Sunday is some day in the middle of the first week"
113+
114+
[1513328b-df53-4714-8677-df68c4f9366c]
115+
description = "when first Sunday is the 7th, the last day of the first week"
116+
117+
[49e083af-47ec-4018-b807-62ef411efed7]
118+
description = "when second Monday is some day in the middle of the second week"
119+
120+
[6cb79a73-38fe-4475-9101-9eec36cf79e5]
121+
description = "when second Monday is the 8th, the first day of the second week"
122+
123+
[4c39b594-af7e-4445-aa03-bf4f8effd9a1]
124+
description = "when second Tuesday is the 14th, the last day of the second week"
125+
126+
[41b32c34-2e39-40e3-b790-93539aaeb6dd]
127+
description = "when second Tuesday is some day in the middle of the second week"
128+
129+
[90a160c5-b5d9-4831-927f-63a78b17843d]
130+
description = "when second Wednesday is some day in the middle of the second week"
131+
132+
[23b98ce7-8dd5-41a1-9310-ef27209741cb]
133+
description = "when second Wednesday is the 14th, the last day of the second week"
134+
135+
[447f1960-27ca-4729-bc3f-f36043f43ed0]
136+
description = "when second Thursday is some day in the middle of the second week"
137+
138+
[c9aa2687-300c-4e79-86ca-077849a81bde]
139+
description = "when second Thursday is another day in the middle of the second week"
140+
141+
[a7e11ef3-6625-4134-acda-3e7195421c09]
142+
description = "when second Friday is the 8th, the first day of the second week"
143+
144+
[8b420e5f-9290-4106-b5ae-022f3e2a3e41]
145+
description = "when second Friday is some day in the middle of the second week"
146+
147+
[80631afc-fc11-4546-8b5f-c12aaeb72b4f]
148+
description = "when second Saturday is some day in the middle of the second week"
149+
150+
[e34d43ac-f470-44c2-aa5f-e97b78ecaf83]
151+
description = "when second Saturday is another day in the middle of the second week"
152+
153+
[a57d59fd-1023-47ad-b0df-a6feb21b44fc]
154+
description = "when second Sunday is some day in the middle of the second week"
155+
156+
[a829a8b0-abdd-4ad1-b66c-5560d843c91a]
157+
description = "when second Sunday is the 14th, the last day of the second week"
158+
159+
[501a8a77-6038-4fc0-b74c-33634906c29d]
160+
description = "when third Monday is some day in the middle of the third week"
161+
162+
[49e4516e-cf32-4a58-8bbc-494b7e851c92]
163+
description = "when third Monday is the 15th, the first day of the third week"
164+
165+
[4db61095-f7c7-493c-85f1-9996ad3012c7]
166+
description = "when third Tuesday is the 21st, the last day of the third week"
167+
168+
[714fc2e3-58d0-4b91-90fd-61eefd2892c0]
169+
description = "when third Tuesday is some day in the middle of the third week"
170+
171+
[b08a051a-2c80-445b-9b0e-524171a166d1]
172+
description = "when third Wednesday is some day in the middle of the third week"
173+
174+
[80bb9eff-3905-4c61-8dc9-bb03016d8ff8]
175+
description = "when third Wednesday is the 21st, the last day of the third week"
176+
177+
[fa52a299-f77f-4784-b290-ba9189fbd9c9]
178+
description = "when third Thursday is some day in the middle of the third week"
179+
180+
[f74b1bc6-cc5c-4bf1-ba69-c554a969eb38]
181+
description = "when third Thursday is another day in the middle of the third week"
182+
183+
[8900f3b0-801a-466b-a866-f42d64667abd]
184+
description = "when third Friday is the 15th, the first day of the third week"
185+
186+
[538ac405-a091-4314-9ccd-920c4e38e85e]
187+
description = "when third Friday is some day in the middle of the third week"
188+
189+
[244db35c-2716-4fa0-88ce-afd58e5cf910]
190+
description = "when third Saturday is some day in the middle of the third week"
191+
192+
[dd28544f-f8fa-4f06-9bcd-0ad46ce68e9e]
193+
description = "when third Saturday is another day in the middle of the third week"
194+
195+
[be71dcc6-00d2-4b53-a369-cbfae55b312f]
196+
description = "when third Sunday is some day in the middle of the third week"
197+
198+
[b7d2da84-4290-4ee6-a618-ee124ae78be7]
199+
description = "when third Sunday is the 21st, the last day of the third week"
200+
201+
[4276dc06-a1bd-4fc2-b6c2-625fee90bc88]
202+
description = "when fourth Monday is some day in the middle of the fourth week"
203+
204+
[ddbd7976-2deb-4250-8a38-925ac1a8e9a2]
205+
description = "when fourth Monday is the 22nd, the first day of the fourth week"
206+
207+
[eb714ef4-1656-47cc-913c-844dba4ebddd]
208+
description = "when fourth Tuesday is the 28th, the last day of the fourth week"
209+
210+
[16648435-7937-4d2d-b118-c3e38fd084bd]
211+
description = "when fourth Tuesday is some day in the middle of the fourth week"
212+
213+
[de062bdc-9484-437a-a8c5-5253c6f6785a]
214+
description = "when fourth Wednesday is some day in the middle of the fourth week"
215+
216+
[c2ce6821-169c-4832-8d37-690ef5d9514a]
217+
description = "when fourth Wednesday is the 28th, the last day of the fourth week"
218+
219+
[d462c631-2894-4391-a8e3-dbb98b7a7303]
220+
description = "when fourth Thursday is some day in the middle of the fourth week"
221+
222+
[9ff1f7b6-1b72-427d-9ee9-82b5bb08b835]
223+
description = "when fourth Thursday is another day in the middle of the fourth week"
224+
225+
[83bae8ba-1c49-49bc-b632-b7c7e1d7e35f]
226+
description = "when fourth Friday is the 22nd, the first day of the fourth week"
227+
228+
[de752d2a-a95e-48d2-835b-93363dac3710]
229+
description = "when fourth Friday is some day in the middle of the fourth week"
230+
231+
[eedd90ad-d581-45db-8312-4c6dcf9cf560]
232+
description = "when fourth Saturday is some day in the middle of the fourth week"
233+
234+
[669fedcd-912e-48c7-a0a1-228b34af91d0]
235+
description = "when fourth Saturday is another day in the middle of the fourth week"
236+
237+
[648e3849-ea49-44a5-a8a3-9f2a43b3bf1b]
238+
description = "when fourth Sunday is some day in the middle of the fourth week"
239+
240+
[f81321b3-99ab-4db6-9267-69c5da5a7823]
241+
description = "when fourth Sunday is the 28th, the last day of the fourth week"
242+
243+
[1af5e51f-5488-4548-aee8-11d7d4a730dc]
244+
description = "last Monday in a month with four Mondays"
245+
246+
[f29999f2-235e-4ec7-9dab-26f137146526]
247+
description = "last Monday in a month with five Mondays"
248+
249+
[31b097a0-508e-48ac-bf8a-f63cdcf6dc41]
250+
description = "last Tuesday in a month with four Tuesdays"
251+
252+
[8c022150-0bb5-4a1f-80f9-88b2e2abcba4]
253+
description = "last Tuesday in another month with four Tuesdays"
254+
255+
[0e762194-672a-4bdf-8a37-1e59fdacef12]
256+
description = "last Wednesday in a month with five Wednesdays"
257+
258+
[5016386a-f24e-4bd7-b439-95358f491b66]
259+
description = "last Wednesday in a month with four Wednesdays"
260+
261+
[12ead1a5-cdf9-4192-9a56-2229e93dd149]
262+
description = "last Thursday in a month with four Thursdays"
263+
264+
[7db89e11-7fbe-4e57-ae3c-0f327fbd7cc7]
265+
description = "last Thursday in a month with five Thursdays"
266+
267+
[e47a739e-b979-460d-9c8a-75c35ca2290b]
268+
description = "last Friday in a month with five Fridays"
269+
270+
[5bed5aa9-a57a-4e5d-8997-2cc796a5b0ec]
271+
description = "last Friday in a month with four Fridays"
272+
273+
[61e54cba-76f3-4772-a2b1-bf443fda2137]
274+
description = "last Saturday in a month with four Saturdays"
275+
276+
[8b6a737b-2fa9-444c-b1a2-80ce7a2ec72f]
277+
description = "last Saturday in another month with four Saturdays"
278+
279+
[0b63e682-f429-4d19-9809-4a45bd0242dc]
280+
description = "last Sunday in a month with five Sundays"
281+
282+
[5232307e-d3e3-4afc-8ba6-4084ad987c00]
283+
description = "last Sunday in a month with four Sundays"
284+
285+
[0bbd48e8-9773-4e81-8e71-b9a51711e3c5]
286+
description = "when last Wednesday in February in a leap year is the 29th"
287+
288+
[fe0936de-7eee-4a48-88dd-66c07ab1fefc]
289+
description = "last Wednesday in December that is also the last day of the year"
290+
291+
[2ccf2488-aafc-4671-a24e-2b6effe1b0e2]
292+
description = "when last Sunday in February in a non-leap year is not the 29th"
293+
294+
[00c3ce9f-cf36-4b70-90d8-92b32be6830e]
295+
description = "when first Friday is the 7th, the last day of the first week"

exercises/practice/meetup/dub.sdl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
name "meetup"
2+
buildRequirements "disallowDeprecations"

0 commit comments

Comments
 (0)