-
-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sync docs with problem-specifications
- Loading branch information
1 parent
e6087dd
commit c905b1b
Showing
11 changed files
with
139 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,15 @@ | ||
# Instructions | ||
|
||
Calculate the number of grains of wheat on a chessboard given that the number | ||
on each square doubles. | ||
Calculate the number of grains of wheat on a chessboard given that the number on each square doubles. | ||
|
||
There once was a wise servant who saved the life of a prince. The king | ||
promised to pay whatever the servant could dream up. Knowing that the | ||
king loved chess, the servant told the king he would like to have grains | ||
of wheat. One grain on the first square of a chess board, with the number | ||
of grains doubling on each successive square. | ||
There once was a wise servant who saved the life of a prince. | ||
The king promised to pay whatever the servant could dream up. | ||
Knowing that the king loved chess, the servant told the king he would like to have grains of wheat. | ||
One grain on the first square of a chess board, with the number of grains doubling on each successive square. | ||
|
||
There are 64 squares on a chessboard (where square 1 has one grain, square 2 has two grains, and so on). | ||
|
||
Write code that shows: | ||
|
||
- how many grains were on a given square, and | ||
- the total number of grains on the chessboard | ||
|
||
## For bonus points | ||
|
||
Did you get the tests passing and the code clean? If you want to, these | ||
are some additional things you could try: | ||
|
||
- Optimize for speed. | ||
- Optimize for readability. | ||
|
||
Then please share your thoughts in a comment on the submission. Did this | ||
experiment make the code better? Worse? Did you learn anything from it? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
# Instructions | ||
|
||
Given a string containing brackets `[]`, braces `{}`, parentheses `()`, | ||
or any combination thereof, verify that any and all pairs are matched | ||
and nested correctly. | ||
Given a string containing brackets `[]`, braces `{}`, parentheses `()`, or any combination thereof, verify that any and all pairs are matched and nested correctly. | ||
The string may also contain other characters, which for the purposes of this exercise should be ignored. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,51 @@ | ||
# Instructions | ||
|
||
Calculate the date of meetups. | ||
Recurring monthly meetups are generally scheduled on the given weekday of a given week each month. | ||
In this exercise you will be given the recurring schedule, along with a month and year, and then asked to find the exact date of the meetup. | ||
|
||
Typically meetups happen on the same day of the week. In this exercise, you | ||
will take a description of a meetup date, and return the actual meetup date. | ||
For example a meetup might be scheduled on the _first Monday_ of every month. | ||
You might then be asked to find the date that this meetup will happen in January 2018. | ||
In other words, you need to determine the date of the first Monday of January 2018. | ||
|
||
Examples of general descriptions are: | ||
Similarly, you might be asked to find: | ||
|
||
- The first Monday of January 2017 | ||
- The third Tuesday of January 2017 | ||
- The wednesteenth of January 2017 | ||
- The last Thursday of January 2017 | ||
- the third Tuesday of August 2019 (August 20, 2019) | ||
- the teenth Wednesday of May 2020 (May 13, 2020) | ||
- the fourth Sunday of July 2021 (July 25, 2021) | ||
- the last Thursday of November 2022 (November 24, 2022) | ||
|
||
The descriptors you are expected to parse are: | ||
first, second, third, fourth, fifth, last, monteenth, tuesteenth, wednesteenth, | ||
thursteenth, friteenth, saturteenth, sunteenth | ||
The descriptors you are expected to process are: `first`, `second`, `third`, `fourth`, `last`, `teenth`. | ||
|
||
Note that "monteenth", "tuesteenth", etc are all made up words. There was a | ||
meetup whose members realized that there are exactly 7 numbered days in a month | ||
that end in '-teenth'. Therefore, one is guaranteed that each day of the week | ||
(Monday, Tuesday, ...) will have exactly one date that is named with '-teenth' | ||
in every month. | ||
Note that descriptor `teenth` is a made-up word. | ||
|
||
Given examples of a meetup dates, each containing a month, day, year, and | ||
descriptor calculate the date of the actual meetup. For example, if given | ||
"The first Monday of January 2017", the correct meetup date is 2017/1/2. | ||
It refers to the seven numbers that end in '-teen' in English: 13, 14, 15, 16, 17, 18, and 19. | ||
But general descriptions of dates use ordinal numbers, e.g. the _first_ Monday, the _third_ Tuesday. | ||
|
||
For the numbers ending in '-teen', that becomes: | ||
|
||
- 13th (thirteenth) | ||
- 14th (fourteenth) | ||
- 15th (fifteenth) | ||
- 16th (sixteenth) | ||
- 17th (seventeenth) | ||
- 18th (eighteenth) | ||
- 19th (nineteenth) | ||
|
||
So there are seven numbers ending in '-teen'. | ||
And there are also seven weekdays (Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday). | ||
Therefore, it is guaranteed that each day of the week (Monday, Tuesday, ...) will have exactly one numbered day ending with "teen" each month. | ||
|
||
If asked to find the teenth Saturday of August, 1953 (or, alternately the "Saturteenth" of August, 1953), we need to look at the calendar for August 1953: | ||
|
||
```plaintext | ||
August 1953 | ||
Su Mo Tu We Th Fr Sa | ||
1 | ||
2 3 4 5 6 7 8 | ||
9 10 11 12 13 14 15 | ||
16 17 18 19 20 21 22 | ||
23 24 25 26 27 28 29 | ||
30 31 | ||
``` | ||
|
||
The Saturday that has a number ending in '-teen' is August 15, 1953. |
Oops, something went wrong.