Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update hello-world exercise and add two-fer exercise #103

Merged
merged 3 commits into from
Oct 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@
"auto_approve": true,
"unlocked_by": null,
"difficulty": 1,
"topics": [
"strings"
]
},
{
"slug": "two-fer",
"uuid": "27ffc2d2-e950-40a1-90fa-a1f3eec4fd36",
"core": false,
"unlocked_by": null,
"difficulty": 1,
"topics": [
"optional_values",
"text_formatting"
Expand Down
4 changes: 2 additions & 2 deletions exercises/hello-world/example.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

(provide hello)

(define (hello [name "World"])
(string-append "Hello, " name "!"))
(define (hello)
"Hello, World!")
3 changes: 1 addition & 2 deletions exercises/hello-world/hello-world-test.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
(test-suite
"hello world tests"

(test-equal? "no arg returns Hello, World!" (hello) "Hello, World!")
(test-equal? "with arg returns Hello, arg!" (hello "exercism") "Hello, exercism!")))
(test-equal? "returns Hello, World!" (hello) "Hello, World!")))

(run-tests suite))
44 changes: 44 additions & 0 deletions exercises/two-fer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Two Fer

`Two-fer` or `2-fer` is short for two for one. One for you and one for me.

```text
"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."


* * * *

For installation and learning resources, refer to the
[exercism Racket page](http://exercism.io/languages/racket).

You can run the provided tests through DrRacket, or via the command line.

To run the test through DrRacket, simply open the test file and click the 'Run' button in the upper right.

To run the test from the command line, run the test from the exercise directory with the following command:

```
raco test two-fer-test.rkt
```

which will display the following:

```
raco test: (submod "two-fer-test.rkt" test)
2 success(es) 0 failure(s) 0 error(s) 2 test(s) run
0
2 tests passed
```

## Source

[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.
6 changes: 6 additions & 0 deletions exercises/two-fer/example.rkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#lang racket

(provide two-fer)

(define (two-fer [name "you"])
(string-append "One for " name ", one for me."))
22 changes: 22 additions & 0 deletions exercises/two-fer/two-fer-test.rkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#lang racket

(require "two-fer.rkt")

(module+ test
(require rackunit rackunit/text-ui)

(define suite
(test-suite
"two fer tests"

(test-equal? "no name given"
(two-fer)
"One for you, one for me.")
(test-equal? "a name given"
(two-fer "Alice")
"One for Alice, one for me.")
(test-equal? "another name given"
(two-fer "Bob")
"One for Bob, one for me.")))

(run-tests suite))
3 changes: 3 additions & 0 deletions exercises/two-fer/two-fer.rkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#lang racket

(provide two-fer)