Skip to content

Commit

Permalink
Implement new two-fer exercise
Browse files Browse the repository at this point in the history
  • Loading branch information
benreyn committed Oct 25, 2018
1 parent c08856b commit 7e349c3
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 0 deletions.
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 hello)

(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)

0 comments on commit 7e349c3

Please sign in to comment.