Skip to content

Commit a8ca9c5

Browse files
Add swift-scheduling exercise (#2536)
* Add `swift-scheduling` exercise * Update introduction.md Co-authored-by: Anastasios Chatzialexiou <[email protected]> * Update instructions.md Co-authored-by: Anastasios Chatzialexiou <[email protected]> * Update instructions.md Co-authored-by: Anastasios Chatzialexiou <[email protected]> * Update instructions.md Co-authored-by: Anastasios Chatzialexiou <[email protected]> * Update instructions.md Co-authored-by: Anastasios Chatzialexiou <[email protected]> * Update instructions.md Co-authored-by: Anastasios Chatzialexiou <[email protected]> * Fix formatting * Add instructions for quarter and month * Add test cases * Fix duplicate uuid * Fix HTML * Explain quarters * Minor tweak to quarters * Fix iso date * Fix data * Fix eow * Update noon to 13:00 * Add leap day test case --------- Co-authored-by: Anastasios Chatzialexiou <[email protected]>
1 parent bf0fa07 commit a8ca9c5

File tree

4 files changed

+224
-0
lines changed

4 files changed

+224
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
{
2+
"exercise": "swift-scheduling",
3+
"comments": [
4+
"The dates are formatted per ",
5+
"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.1.15.",
6+
"",
7+
"Tracks that support changing the system's current time can consider ",
8+
"setting the system's current time to the meeting start instead of ",
9+
"passing it as an argument."
10+
],
11+
"cases": [
12+
{
13+
"uuid": "1d0e6e72-f370-408c-bc64-5dafa9c6da73",
14+
"description": "NOW translates to two hours later",
15+
"property": "deliveryDate",
16+
"input": {
17+
"meetingStart": "2012-02-13T09:00:00",
18+
"description": "NOW"
19+
},
20+
"expected": "2012-02-13T11:00:00"
21+
},
22+
{
23+
"uuid": "93325e7b-677d-4d96-b017-2582af879dc2",
24+
"description": "ASAP before one in the afternoon translates to today at five in the afternoon",
25+
"property": "deliveryDate",
26+
"input": {
27+
"meetingStart": "1999-06-03T09:45:00",
28+
"description": "ASAP"
29+
},
30+
"expected": "1999-06-03T17:00:00"
31+
},
32+
{
33+
"uuid": "cb4252a3-c4c1-41f6-8b8c-e7269733cef8",
34+
"description": "ASAP at one in the afternoon translates to tomorrow at one in the afternoon",
35+
"property": "deliveryDate",
36+
"input": {
37+
"meetingStart": "2008-12-21T13:00:00",
38+
"description": "ASAP"
39+
},
40+
"expected": "2008-12-22T13:00:00"
41+
},
42+
{
43+
"uuid": "6fddc1ea-2fe9-4c60-81f7-9220d2f45537",
44+
"description": "ASAP after one in the afternoon translates to tomorrow at one in the afternoon",
45+
"property": "deliveryDate",
46+
"input": {
47+
"meetingStart": "2008-12-21T14:50:00",
48+
"description": "ASAP"
49+
},
50+
"expected": "2008-12-22T13:00:00"
51+
},
52+
{
53+
"uuid": "25f46bf9-6d2a-4e95-8edd-f62dd6bc8a6e",
54+
"description": "EOW on Monday translates to Friday at five in the afternoon",
55+
"property": "deliveryDate",
56+
"input": {
57+
"meetingStart": "2025-02-03T16:00:00",
58+
"description": "EOW"
59+
},
60+
"expected": "2025-02-07T17:00:00"
61+
},
62+
{
63+
"uuid": "0b375df5-d198-489e-acee-fd538a768616",
64+
"description": "EOW on Tuesday translates to Friday at five in the afternoon",
65+
"property": "deliveryDate",
66+
"input": {
67+
"meetingStart": "1997-04-29T10:50:00",
68+
"description": "EOW"
69+
},
70+
"expected": "1997-05-02T17:00:00"
71+
},
72+
{
73+
"uuid": "4afbb881-0b5c-46be-94e1-992cdc2a8ca4",
74+
"description": "EOW on Wednesday translates to Friday at five in the afternoon",
75+
"property": "deliveryDate",
76+
"input": {
77+
"meetingStart": "2005-09-14T11:00:00",
78+
"description": "EOW"
79+
},
80+
"expected": "2005-09-16T17:00:00"
81+
},
82+
{
83+
"uuid": "e1341c2b-5e1b-4702-a95c-a01e8e96e510",
84+
"description": "EOW on Thursday translates to Sunday at eight in the evening",
85+
"property": "deliveryDate",
86+
"input": {
87+
"meetingStart": "2011-05-19T08:30:00",
88+
"description": "EOW"
89+
},
90+
"expected": "2011-05-22T20:00:00"
91+
},
92+
{
93+
"uuid": "bbffccf7-97f7-4244-888d-bdd64348fa2e",
94+
"description": "EOW on Friday translates to Sunday at eight in the evening",
95+
"property": "deliveryDate",
96+
"input": {
97+
"meetingStart": "2022-08-05T14:00:00",
98+
"description": "EOW"
99+
},
100+
"expected": "2022-08-07T20:00:00"
101+
},
102+
{
103+
"uuid": "d651fcf4-290e-407c-8107-36b9076f39b2",
104+
"description": "EOW translates to leap day",
105+
"property": "deliveryDate",
106+
"input": {
107+
"meetingStart": "2008-02-25T10:30:00",
108+
"description": "EOW"
109+
},
110+
"expected": "2008-02-29T17:00:00"
111+
},
112+
{
113+
"uuid": "439bf09f-3a0e-44e7-bad5-b7b6d0c4505a",
114+
"description": "2M before the second month of this year translates to the first workday of the second month of this year",
115+
"property": "deliveryDate",
116+
"input": {
117+
"meetingStart": "2007-01-02T14:15:00",
118+
"description": "2M"
119+
},
120+
"expected": "2007-02-01T08:00:00"
121+
},
122+
{
123+
"uuid": "86d82e83-c481-4fb4-9264-625de7521340",
124+
"description": "11M in the eleventh month translates to the first workday of the eleventh month of next year",
125+
"property": "deliveryDate",
126+
"input": {
127+
"meetingStart": "2013-11-21T15:30:00",
128+
"description": "11M"
129+
},
130+
"expected": "2014-11-03T08:00:00"
131+
},
132+
{
133+
"uuid": "0d0b8f6a-1915-46f5-a630-1ff06af9da08",
134+
"description": "4M in the ninth month translates to the first workday of the fourth month of next year",
135+
"property": "deliveryDate",
136+
"input": {
137+
"meetingStart": "2019-11-18T15:15:00",
138+
"description": "4M"
139+
},
140+
"expected": "2020-04-01T08:00:00"
141+
},
142+
{
143+
"uuid": "06d401e3-8461-438f-afae-8d26aa0289e0",
144+
"description": "Q1 in the first quarter translates to the last workday of the first quarter of this year",
145+
"property": "deliveryDate",
146+
"input": {
147+
"meetingStart": "2003-01-01T10:45:00",
148+
"description": "Q1"
149+
},
150+
"expected": "2003-03-31T08:00:00"
151+
},
152+
{
153+
"uuid": "eebd5f32-b16d-4ecd-91a0-584b0364b7ed",
154+
"description": "Q4 in the second quarter translates to the last workday of the fourth quarter of this year",
155+
"property": "deliveryDate",
156+
"input": {
157+
"meetingStart": "2001-04-09T09:00:00",
158+
"description": "Q4"
159+
},
160+
"expected": "2001-12-31T08:00:00"
161+
},
162+
{
163+
"uuid": "c920886c-44ad-4d34-a156-dc4176186581",
164+
"description": "Q3 in the fourth quarter translates to the last workday of the third quarter of next year",
165+
"property": "deliveryDate",
166+
"input": {
167+
"meetingStart": "2022-10-06T11:00:00",
168+
"description": "Q3"
169+
},
170+
"expected": "2023-09-29T08:00:00"
171+
}
172+
]
173+
}
+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Instructions
2+
3+
Your task is to convert delivery date descriptions to _actual_ delivery dates, based on when the meeting started.
4+
5+
There are two types of delivery date descriptions:
6+
7+
1. Fixed: a predefined set of words.
8+
2. Variable: words that have a variable component, but follow a predefined set of patterns.
9+
10+
## Fixed delivery date descriptions
11+
12+
There are three fixed delivery date descriptions:
13+
14+
- `"NOW"`
15+
- `"ASAP"` (As Soon As Possible)
16+
- `"EOW"` (End Of Week)
17+
18+
The following table shows how to translate them:
19+
20+
| Description | Meeting start | Delivery date |
21+
| ----------- | ----------------------------- | ----------------------------------- |
22+
| `"NOW"` | - | Two hours after the meeting started |
23+
| `"ASAP"` | Before 13:00 | Today at 17:00 |
24+
| `"ASAP"` | After or at 13:00 | Tomorrow at 13:00 |
25+
| `"EOW"` | Monday, Tuesday, or Wednesday | Friday at 17:00 |
26+
| `"EOW"` | Thursday or Friday | Sunday at 20:00 |
27+
28+
## Variable delivery date descriptions
29+
30+
There are two variable delivery date description patterns:
31+
32+
- `"<N>M"` (N-th month)
33+
- `"Q<N>"` (N-th quarter)
34+
35+
| Description | Meeting start | Delivery date |
36+
| ----------- | -------------------------- | ----------------------------------------------------------- |
37+
| `"<N>M"` | Before N-th month | At 8:00 on the _first_ workday¹ of this year's N-th month |
38+
| `"<N>M"` | After or in N-th month | At 8:00 on the _first_ workday¹ of next year's N-th month |
39+
| `"Q<N>"` | Before or in N-th quarter² | At 8:00 on the _last_ workday¹ of this year's N-th quarter² |
40+
| `"Q<N>"` | After N-th quarter² | At 8:00 on the _last_ workday¹ of next year's N-th quarter² |
41+
42+
¹ A workday is a Monday, Tuesday, Wednesday, Thursday, or Friday.
43+
² A year has four quarters, each with three months: January/February/March, April/May/June, July/August/September, and October/November/December.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Introduction
2+
3+
This week, it is your turn to take notes in the department's planning meeting.
4+
In this meeting, your boss will set delivery dates for all open work items.
5+
Annoyingly, instead of specifying the _actual_ delivery dates, your boss will only _describe them_ in an abbreviated format.
6+
As many of your colleagues won't be familiar with this corporate lingo, you'll need to convert these delivery date descriptions to actual delivery dates.
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
title = "Swift Scheduling"
2+
blurb = "Convert delivery date descriptions to actual delivery dates."

0 commit comments

Comments
 (0)