-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
43ff153
commit 01aeee5
Showing
20 changed files
with
165 additions
and
131 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
# Instructions | ||
|
||
The classical introductory exercise. Just say "Hello, World!". | ||
The classical introductory exercise. | ||
Just say "Hello, World!". | ||
|
||
["Hello, World!"](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program) is | ||
the traditional first program for beginning programming in a new language | ||
or environment. | ||
["Hello, World!"][hello-world] is the traditional first program for beginning programming in a new language or environment. | ||
|
||
The objectives are simple: | ||
|
||
- Write a function that returns the string "Hello, World!". | ||
- Modify the provided code so that it produces the string "Hello, World!". | ||
- Run the test suite and make sure that it succeeds. | ||
- Submit your solution and check it at the website. | ||
|
||
If everything goes well, you will be ready to fetch your first real exercise. | ||
|
||
[hello-world]: https://en.wikipedia.org/wiki/%22Hello,_world!%22_program |
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,28 +1,26 @@ | ||
# Instructions | ||
|
||
Implement a doubly linked list. | ||
Your team has decided to use a doubly linked list to represent each train route in the schedule. | ||
Each station along the train's route will be represented by a node in the linked list. | ||
|
||
Like an array, a linked list is a simple linear data structure. Several | ||
common data types can be implemented using linked lists, like queues, | ||
stacks, and associative arrays. | ||
You don't need to worry about arrival and departure times at the stations. | ||
Each station will simply be represented by a number. | ||
|
||
A linked list is a collection of data elements called *nodes*. In a | ||
*singly linked list* each node holds a value and a link to the next node. | ||
In a *doubly linked list* each node also holds a link to the previous | ||
node. | ||
Routes can be extended, adding stations to the beginning or end of a route. | ||
They can also be shortened by removing stations from the beginning or the end of a route. | ||
|
||
You will write an implementation of a doubly linked list. Implement a | ||
Node to hold a value and pointers to the next and previous nodes. Then | ||
implement a List which holds references to the first and last node and | ||
offers an array-like interface for adding and removing items: | ||
Sometimes a station gets closed down, and in that case the station needs to be removed from the route, even if it is not at the beginning or end of the route. | ||
|
||
* `push` (*insert value at back*); | ||
* `pop` (*remove value at back*); | ||
* `shift` (*remove value at front*). | ||
* `unshift` (*insert value at front*); | ||
The size of a route is measured not by how far the train travels, but by how many stations it stops at. | ||
|
||
To keep your implementation simple, the tests will not cover error | ||
conditions. Specifically: `pop` or `shift` will never be called on an | ||
empty list. | ||
~~~~exercism/note | ||
The linked list is a fundamental data structure in computer science, often used in the implementation of other data structures. | ||
As the name suggests, it is a list of nodes that are linked together. | ||
It is a list of "nodes", where each node links to its neighbor or neighbors. | ||
In a **singly linked list** each node links only to the node that follows it. | ||
In a **doubly linked list** each node links to both the node that comes before, as well as the node that comes after. | ||
If you want to know more about linked lists, check [Wikipedia](https://en.wikipedia.org/wiki/Linked_list). | ||
If you want to dig deeper into linked lists, check out [this article][intro-linked-list] that explains it using nice drawings. | ||
[intro-linked-list]: https://medium.com/basecs/whats-a-linked-list-anyway-part-1-d8b7e6508b9d | ||
~~~~ |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Introduction | ||
|
||
You are working on a project to develop a train scheduling system for a busy railway network. | ||
|
||
You've been asked to develop a prototype for the train routes in the scheduling system. | ||
Each route consists of a sequence of train stations that a given train stops at. |
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,5 @@ | ||
# 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. | ||
Any other characters should be ignored. | ||
For example, `"{what is (42)}?"` is balanced and `"[text}"` is not. |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Introduction | ||
|
||
You're given the opportunity to write software for the Bracketeer™, an ancient but powerful mainframe. | ||
The software that runs on it is written in a proprietary language. | ||
Much of its syntax is familiar, but you notice _lots_ of brackets, braces and parentheses. | ||
Despite the Bracketeer™ being powerful, it lacks flexibility. | ||
If the source code has any unbalanced brackets, braces or parentheses, the Bracketeer™ crashes and must be rebooted. | ||
To avoid such a scenario, you start writing code that can verify that brackets, braces, and parentheses are balanced before attempting to run it on the Bracketeer™. |
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
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,18 +1,28 @@ | ||
# Instructions | ||
|
||
Given an age in seconds, calculate how old someone would be on: | ||
Given an age in seconds, calculate how old someone would be on a planet in our Solar System. | ||
|
||
- Mercury: orbital period 0.2408467 Earth years | ||
- Venus: orbital period 0.61519726 Earth years | ||
- Earth: orbital period 1.0 Earth years, 365.25 Earth days, or 31557600 seconds | ||
- Mars: orbital period 1.8808158 Earth years | ||
- Jupiter: orbital period 11.862615 Earth years | ||
- Saturn: orbital period 29.447498 Earth years | ||
- Uranus: orbital period 84.016846 Earth years | ||
- Neptune: orbital period 164.79132 Earth years | ||
One Earth year equals 365.25 Earth days, or 31,557,600 seconds. | ||
If you were told someone was 1,000,000,000 seconds old, their age would be 31.69 Earth-years. | ||
|
||
So if you were told someone were 1,000,000,000 seconds old, you should | ||
be able to say that they're 31.69 Earth-years old. | ||
For the other planets, you have to account for their orbital period in Earth Years: | ||
|
||
If you're wondering why Pluto didn't make the cut, go watch [this | ||
youtube video](http://www.youtube.com/watch?v=Z_2gbGXzFbs). | ||
| Planet | Orbital period in Earth Years | | ||
| ------- | ----------------------------- | | ||
| Mercury | 0.2408467 | | ||
| Venus | 0.61519726 | | ||
| Earth | 1.0 | | ||
| Mars | 1.8808158 | | ||
| Jupiter | 11.862615 | | ||
| Saturn | 29.447498 | | ||
| Uranus | 84.016846 | | ||
| Neptune | 164.79132 | | ||
|
||
~~~~exercism/note | ||
The actual length of one complete orbit of the Earth around the sun is closer to 365.256 days (1 sidereal year). | ||
The Gregorian calendar has, on average, 365.2425 days. | ||
While not entirely accurate, 365.25 is the value used in this exercise. | ||
See [Year on Wikipedia][year] for more ways to measure a year. | ||
[year]: https://en.wikipedia.org/wiki/Year#Summary | ||
~~~~ |
Oops, something went wrong.