diff --git a/config.json b/config.json index 13ddc4b5..b3348c4f 100644 --- a/config.json +++ b/config.json @@ -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" diff --git a/exercises/hello-world/example.rkt b/exercises/hello-world/example.rkt index d19f9a8c..eb5c01d1 100644 --- a/exercises/hello-world/example.rkt +++ b/exercises/hello-world/example.rkt @@ -2,5 +2,5 @@ (provide hello) -(define (hello [name "World"]) - (string-append "Hello, " name "!")) +(define (hello) + "Hello, World!") diff --git a/exercises/hello-world/hello-world-test.rkt b/exercises/hello-world/hello-world-test.rkt index 968e3cf6..dc037d3b 100644 --- a/exercises/hello-world/hello-world-test.rkt +++ b/exercises/hello-world/hello-world-test.rkt @@ -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)) diff --git a/exercises/two-fer/README.md b/exercises/two-fer/README.md new file mode 100644 index 00000000..0f47ad43 --- /dev/null +++ b/exercises/two-fer/README.md @@ -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. diff --git a/exercises/two-fer/example.rkt b/exercises/two-fer/example.rkt new file mode 100644 index 00000000..fb054828 --- /dev/null +++ b/exercises/two-fer/example.rkt @@ -0,0 +1,6 @@ +#lang racket + +(provide two-fer) + +(define (two-fer [name "you"]) + (string-append "One for " name ", one for me.")) diff --git a/exercises/two-fer/two-fer-test.rkt b/exercises/two-fer/two-fer-test.rkt new file mode 100644 index 00000000..fa602076 --- /dev/null +++ b/exercises/two-fer/two-fer-test.rkt @@ -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)) diff --git a/exercises/two-fer/two-fer.rkt b/exercises/two-fer/two-fer.rkt new file mode 100644 index 00000000..fa408241 --- /dev/null +++ b/exercises/two-fer/two-fer.rkt @@ -0,0 +1,3 @@ +#lang racket + +(provide two-fer)