diff --git a/config/exercise_readme.go.tmpl b/config/exercise_readme.go.tmpl new file mode 100644 index 00000000..2b26f494 --- /dev/null +++ b/config/exercise_readme.go.tmpl @@ -0,0 +1,16 @@ +# {{ .Spec.Name }} + +{{ .Spec.Description -}} +{{- with .Hints }} +{{ . }} +{{ end }} +{{- with .TrackInsert }} +{{ . }} +{{ end }} +{{- with .Spec.Credits -}} +## Source + +{{ . }} +{{ end }} +## Submitting Incomplete Solutions +It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/anagram/README.md b/exercises/anagram/README.md new file mode 100644 index 00000000..76816672 --- /dev/null +++ b/exercises/anagram/README.md @@ -0,0 +1,18 @@ +# Anagram + +Given a word and a list of possible anagrams, select the correct sublist. + +Given `"listen"` and a list of candidates like `"enlists" "google" +"inlets" "banana"` the program should return a list containing +`"inlets"`. + +Run the tests with: + + bats whatever_test.sh + +## Source + +Inspired by the Extreme Startup game [https://github.com/rchatley/extreme_startup](https://github.com/rchatley/extreme_startup) + +## Submitting Incomplete Solutions +It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/bob/README.md b/exercises/bob/README.md new file mode 100644 index 00000000..79acb649 --- /dev/null +++ b/exercises/bob/README.md @@ -0,0 +1,23 @@ +# Bob + +Bob is a lackadaisical teenager. In conversation, his responses are very limited. + +Bob answers 'Sure.' if you ask him a question. + +He answers 'Whoa, chill out!' if you yell at him. + +He says 'Fine. Be that way!' if you address him without actually saying +anything. + +He answers 'Whatever.' to anything else. + +Run the tests with: + + bats whatever_test.sh + +## Source + +Inspired by the 'Deaf Grandma' exercise in Chris Pine's Learn to Program tutorial. [http://pine.fm/LearnToProgram/?Chapter=06](http://pine.fm/LearnToProgram/?Chapter=06) + +## Submitting Incomplete Solutions +It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/difference-of-squares/README.md b/exercises/difference-of-squares/README.md new file mode 100644 index 00000000..b1150ae3 --- /dev/null +++ b/exercises/difference-of-squares/README.md @@ -0,0 +1,24 @@ +# Difference Of Squares + +Find the difference between the square of the sum and the sum of the squares of the first N natural numbers. + +The square of the sum of the first ten natural numbers is +(1 + 2 + ... + 10)² = 55² = 3025. + +The sum of the squares of the first ten natural numbers is +1² + 2² + ... + 10² = 385. + +Hence the difference between the square of the sum of the first +ten natural numbers and the sum of the squares of the first ten +natural numbers is 3025 - 385 = 2640. + +Run the tests with: + + bats whatever_test.sh + +## Source + +Problem 6 at Project Euler [http://projecteuler.net/problem=6](http://projecteuler.net/problem=6) + +## Submitting Incomplete Solutions +It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/gigasecond/README.md b/exercises/gigasecond/README.md new file mode 100644 index 00000000..447fae12 --- /dev/null +++ b/exercises/gigasecond/README.md @@ -0,0 +1,16 @@ +# Gigasecond + +Calculate the moment when someone has lived for 10^9 seconds. + +A gigasecond is 10^9 (1,000,000,000) seconds. + +Run the tests with: + + bats whatever_test.sh + +## Source + +Chapter 9 in Chris Pine's online Learn to Program tutorial. [http://pine.fm/LearnToProgram/?Chapter=09](http://pine.fm/LearnToProgram/?Chapter=09) + +## Submitting Incomplete Solutions +It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/hamming/README.md b/exercises/hamming/README.md new file mode 100644 index 00000000..d0639561 --- /dev/null +++ b/exercises/hamming/README.md @@ -0,0 +1,47 @@ +# Hamming + +Calculate the Hamming difference between two DNA strands. + +A mutation is simply a mistake that occurs during the creation or +copying of a nucleic acid, in particular DNA. Because nucleic acids are +vital to cellular functions, mutations tend to cause a ripple effect +throughout the cell. Although mutations are technically mistakes, a very +rare mutation may equip the cell with a beneficial attribute. In fact, +the macro effects of evolution are attributable by the accumulated +result of beneficial microscopic mutations over many generations. + +The simplest and most common type of nucleic acid mutation is a point +mutation, which replaces one base with another at a single nucleotide. + +By counting the number of differences between two homologous DNA strands +taken from different genomes with a common ancestor, we get a measure of +the minimum number of point mutations that could have occurred on the +evolutionary path between the two strands. + +This is called the 'Hamming distance'. + +It is found by comparing two DNA strands and counting how many of the +nucleotides are different from their equivalent in the other string. + + GAGCCTACTAACGGGAT + CATCGTAATGACGGCCT + ^ ^ ^ ^ ^ ^^ + +The Hamming distance between these two DNA strands is 7. + +# Implementation notes + +The Hamming distance is only defined for sequences of equal length. This means +that based on the definition, each language could deal with getting sequences +of equal length differently. + +Run the tests with: + + bats whatever_test.sh + +## Source + +The Calculating Point Mutations problem at Rosalind [http://rosalind.info/problems/hamm/](http://rosalind.info/problems/hamm/) + +## Submitting Incomplete Solutions +It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/hello-world/README.md b/exercises/hello-world/README.md new file mode 100644 index 00000000..f857f144 --- /dev/null +++ b/exercises/hello-world/README.md @@ -0,0 +1,66 @@ +# 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. + +The objectives are simple: + +- Write a function that returns 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. + +# Welcome to Bash! + +Unlike many other languages here, bash is a bit of a special snowflake. +If you are on a Mac or other unix-y platform, you almost definitely +already have bash. In fact, anything you type into the terminal is +likely going through bash. + +The downside to this is that there isn't much of a development +ecosystem around bash like there is for other languages, and there are +multiple verions of bash that can be frustratingly incompatible. Luckily +we shouldn't hit those differences for these basic examples, and if you +can get the tests to pass on your machine, we are doing great. + +## Installation + +As I said above, if you are on a unix-like OS (Mac OS X, Linux, Solaris, +etc), you probably already have bash. + +## Testing + +As there isn't much of a bash ecosystem, there also isn't really a de +facto leader in the bash testing area. For these examples we are using +[bats](https://github.com/sstephenson/bats). You should be able to +install it from your favorite package manager, on OS X with homebrew +this would look something like this: + +``` +$ brew install bats +==> Downloading +https://github.com/sstephenson/bats/archive/v0.4.0.tar.gz +==> Downloading from +https://codeload.github.com/sstephenson/bats/tar.gz/v0.4.0 +######################################################################## +100.0% +==> ./install.sh /opt/boxen/homebrew/Cellar/bats/0.4.0 +🍺 /opt/boxen/homebrew/Cellar/bats/0.4.0: 10 files, 60K, built in 2 +seconds +``` + + +Run the tests with: + + bats whatever_test.sh + +## Source + +This is an exercise to introduce users to using Exercism [http://en.wikipedia.org/wiki/%22Hello,_world!%22_program](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program) + +## Submitting Incomplete Solutions +It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/leap/README.md b/exercises/leap/README.md new file mode 100644 index 00000000..56de989a --- /dev/null +++ b/exercises/leap/README.md @@ -0,0 +1,38 @@ +# Leap + +Given a year, report if it is a leap year. + +The tricky thing here is that a leap year in the Gregorian calendar occurs: + +```plain +on every year that is evenly divisible by 4 + except every year that is evenly divisible by 100 + unless the year is also evenly divisible by 400 +``` + +For example, 1997 is not a leap year, but 1996 is. 1900 is not a leap +year, but 2000 is. + +If your language provides a method in the standard library that does +this look-up, pretend it doesn't exist and implement it yourself. + +## Notes + +Though our exercise adopts some very simple rules, there is more to +learn! + +For a delightful, four minute explanation of the whole leap year +phenomenon, go watch [this youtube video][video]. + +[video]: http://www.youtube.com/watch?v=xX96xng7sAE + +Run the tests with: + + bats whatever_test.sh + +## Source + +JavaRanch Cattle Drive, exercise 3 [http://www.javaranch.com/leap.jsp](http://www.javaranch.com/leap.jsp) + +## Submitting Incomplete Solutions +It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/pangram/README.md b/exercises/pangram/README.md new file mode 100644 index 00000000..5b7adb64 --- /dev/null +++ b/exercises/pangram/README.md @@ -0,0 +1,20 @@ +# Pangram + +Determine if a sentence is a pangram. A pangram (Greek: παν γράμμα, pan gramma, +"every letter") is a sentence using every letter of the alphabet at least once. +The best known English pangram is: +> The quick brown fox jumps over the lazy dog. + +The alphabet used consists of ASCII letters `a` to `z`, inclusive, and is case +insensitive. Input will not contain non-ASCII symbols. + +Run the tests with: + + bats whatever_test.sh + +## Source + +Wikipedia [https://en.wikipedia.org/wiki/Pangram](https://en.wikipedia.org/wiki/Pangram) + +## Submitting Incomplete Solutions +It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/phone-number/README.md b/exercises/phone-number/README.md new file mode 100644 index 00000000..4482bc64 --- /dev/null +++ b/exercises/phone-number/README.md @@ -0,0 +1,39 @@ +# Phone Number + +Clean up user-entered phone numbers so that they can be sent SMS messages. + +The **North American Numbering Plan (NANP)** is a telephone numbering system used by many countries in North America like the United States, Canada or Bermuda. All NANP-countries share the same international country code: `1`. + +NANP numbers are ten-digit numbers consisting of a three-digit Numbering Plan Area code, commonly known as *area code*, followed by a seven-digit local number. The first three digits of the local number represent the *exchange code*, followed by the unique four-digit number which is the *subscriber number*. + + +The format is usually represented as +``` +(NXX)-NXX-XXXX +``` +where `N` is any digit from 2 through 9 and `X` is any digit from 0 through 9. + +Your task is to clean up differently formated telephone numbers by removing punctuation and the country code (1) if present. + +For example, the inputs +- `+1 (613)-995-0253` +- `613-995-0253` +- `1 613 995 0253` +- `613.995.0253` + +should all produce the output + +`6139950253` + +**Note:** As this exercise only deals with telephone numbers used in NANP-countries, only 1 is considered a valid country code. + +Run the tests with: + + bats whatever_test.sh + +## Source + +Event Manager by JumpstartLab [http://tutorials.jumpstartlab.com/projects/eventmanager.html](http://tutorials.jumpstartlab.com/projects/eventmanager.html) + +## Submitting Incomplete Solutions +It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/raindrops/README.md b/exercises/raindrops/README.md new file mode 100644 index 00000000..a7abc2a5 --- /dev/null +++ b/exercises/raindrops/README.md @@ -0,0 +1,29 @@ +# Raindrops + +Convert a number to a string, the contents of which depend on the number's factors. + +- If the number has 3 as a factor, output 'Pling'. +- If the number has 5 as a factor, output 'Plang'. +- If the number has 7 as a factor, output 'Plong'. +- If the number does not have 3, 5, or 7 as a factor, + just pass the number's digits straight through. + +## Examples + +- 28's factors are 1, 2, 4, **7**, 14, 28. + - In raindrop-speak, this would be a simple "Plong". +- 30's factors are 1, 2, **3**, **5**, 6, 10, 15, 30. + - In raindrop-speak, this would be a "PlingPlang". +- 34 has four factors: 1, 2, 17, and 34. + - In raindrop-speak, this would be "34". + +Run the tests with: + + bats whatever_test.sh + +## Source + +A variation on a famous interview question intended to weed out potential candidates. [http://jumpstartlab.com](http://jumpstartlab.com) + +## Submitting Incomplete Solutions +It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/rna-transcription/README.md b/exercises/rna-transcription/README.md new file mode 100644 index 00000000..086cf69e --- /dev/null +++ b/exercises/rna-transcription/README.md @@ -0,0 +1,30 @@ +# Rna Transcription + +Given a DNA strand, return its RNA complement (per RNA transcription). + +Both DNA and RNA strands are a sequence of nucleotides. + +The four nucleotides found in DNA are adenine (**A**), cytosine (**C**), +guanine (**G**) and thymine (**T**). + +The four nucleotides found in RNA are adenine (**A**), cytosine (**C**), +guanine (**G**) and uracil (**U**). + +Given a DNA strand, its transcribed RNA strand is formed by replacing +each nucleotide with its complement: + +* `G` -> `C` +* `C` -> `G` +* `T` -> `A` +* `A` -> `U` + +Run the tests with: + + bats whatever_test.sh + +## Source + +Rosalind [http://rosalind.info/problems/rna](http://rosalind.info/problems/rna) + +## Submitting Incomplete Solutions +It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/two-fer/README.md b/exercises/two-fer/README.md new file mode 100644 index 00000000..c8761a92 --- /dev/null +++ b/exercises/two-fer/README.md @@ -0,0 +1,53 @@ +# Two Fer + +`Two-fer` or `2-fer` is short for two for one. One for you and one for me. + +``` +"One for X, one for me." +``` + +When X is a name or "you". + +If the given name is "Alice", the result should be "One for Alice, one for me." +If no name is given, the result should be "One for you, one for me." + + +## Test-Driven Development + +As programmers mature, they eventually want to test their code. + +Here at Exercism we simulate [Test-Driven +Development](http://en.wikipedia.org/wiki/Test-driven_development) (TDD), where +you write your tests before writing any functionality. The simulation comes in +the form of a pre-written test suite, which will signal that you have solved +the problem. + +It will also provide you with a safety net to explore other solutions without +breaking the functionality. + +### A typical TDD workflow on Exercism: + +1. Run the test file and pick one test that's failing. +2. Write some code to fix the test you picked. +3. Re-run the tests to confirm the test is now passing. +4. Repeat from step 1. +5. Submit your solution (`exercism submit /path/to/file`) + +## Instructions + +Submissions are encouraged to be general, within reason. Having said that, it's +also important not to over-engineer a solution. + +It's important to remember that the goal is to make code as expressive and +readable as we can. + +Run the tests with: + + bats whatever_test.sh + +## Source + +This is an exercise to introduce users to basic programming constructs, just after hello World. [https://en.wikipedia.org/wiki/Two-fer](https://en.wikipedia.org/wiki/Two-fer) + +## Submitting Incomplete Solutions +It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/word-count/README.md b/exercises/word-count/README.md new file mode 100644 index 00000000..c28e7780 --- /dev/null +++ b/exercises/word-count/README.md @@ -0,0 +1,24 @@ +# Word Count + +Given a phrase, count the occurrences of each word in that phrase. + +For example for the input `"olly olly in come free"` + +```plain +olly: 2 +in: 1 +come: 1 +free: 1 +``` + + +Run the tests with: + + bats whatever_test.sh + +## Source + +This is a classic toy problem, but we were reminded of it by seeing it in the Go Tour. + +## Submitting Incomplete Solutions +It's possible to submit an incomplete solution so you can see how others have completed the exercise.