From ab215e0ede8c93d419d1b3c7ff3d96c918d8f320 Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Thu, 14 Oct 2021 12:38:15 -0300 Subject: [PATCH] Two fer --- racket/two-fer/.exercism/config.json | 24 +++++++++++++ racket/two-fer/.exercism/metadata.json | 1 + racket/two-fer/HELP.md | 39 +++++++++++++++++++++ racket/two-fer/README.md | 48 ++++++++++++++++++++++++++ racket/two-fer/two-fer-test.rkt | 23 ++++++++++++ racket/two-fer/two-fer.rkt | 6 ++++ 6 files changed, 141 insertions(+) create mode 100644 racket/two-fer/.exercism/config.json create mode 100644 racket/two-fer/.exercism/metadata.json create mode 100644 racket/two-fer/HELP.md create mode 100644 racket/two-fer/README.md create mode 100644 racket/two-fer/two-fer-test.rkt create mode 100644 racket/two-fer/two-fer.rkt diff --git a/racket/two-fer/.exercism/config.json b/racket/two-fer/.exercism/config.json new file mode 100644 index 0000000..2489ccc --- /dev/null +++ b/racket/two-fer/.exercism/config.json @@ -0,0 +1,24 @@ +{ + "blurb": "Create a sentence of the form \"One for X, one for me.\"", + "authors": [ + "benreyn" + ], + "contributors": [ + "cousinitt", + "robertpostill", + "sjwarner-bp", + "timotheosh" + ], + "files": { + "solution": [ + "two-fer.rkt" + ], + "test": [ + "two-fer-test.rkt" + ], + "example": [ + ".meta/example.rkt" + ] + }, + "source_url": "https://github.com/exercism/problem-specifications/issues/757" +} diff --git a/racket/two-fer/.exercism/metadata.json b/racket/two-fer/.exercism/metadata.json new file mode 100644 index 0000000..3010361 --- /dev/null +++ b/racket/two-fer/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"racket","exercise":"two-fer","id":"62bc87053dc145deaa236c398ab91793","url":"https://exercism.org/tracks/racket/exercises/two-fer","handle":"JBiason","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/racket/two-fer/HELP.md b/racket/two-fer/HELP.md new file mode 100644 index 0000000..4b67fbc --- /dev/null +++ b/racket/two-fer/HELP.md @@ -0,0 +1,39 @@ +# Help + +## Running the tests + +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 -test.rkt +``` + +where `` should be replaced with the exercise's slug. + +## Submitting your solution + +You can submit your solution using the `exercism submit two-fer.rkt` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Racket track's documentation](https://exercism.org/docs/tracks/racket) +- [Exercism's support channel on gitter](https://gitter.im/exercism/support) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +To get help if you're having trouble, you can use one of the following resources: + +- [The Racket Reference](http://docs.racket-lang.org/reference/index.html) +- [/r/racket](https://www.reddit.com/r/racket) is the Racket subreddit. +- [StackOverflow](http://stackoverflow.com/questions/tagged/racket) can be used to search for your problem and see if it has been answered already. You can also ask and answer questions. \ No newline at end of file diff --git a/racket/two-fer/README.md b/racket/two-fer/README.md new file mode 100644 index 0000000..693cb56 --- /dev/null +++ b/racket/two-fer/README.md @@ -0,0 +1,48 @@ +# Two Fer + +Welcome to Two Fer on Exercism's Racket Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +`Two-fer` or `2-fer` is short for two for one. One for you and one for me. + +Given a name, return a string with the message: + +```text +One for name, one for me. +``` + +Where "name" is the given name. + +However, if the name is missing, return the string: + +```text +One for you, one for me. +``` + +Here are some examples: + +|Name |String to return +|:-------|:------------------ +|Alice |One for Alice, one for me. +|Bob |One for Bob, one for me. +| |One for you, one for me. +|Zaphod |One for Zaphod, one for me. + +## Source + +### Created by + +- @benreyn + +### Contributed to by + +- @cousinitt +- @robertpostill +- @sjwarner-bp +- @timotheosh + +### Based on + +https://github.com/exercism/problem-specifications/issues/757 \ No newline at end of file diff --git a/racket/two-fer/two-fer-test.rkt b/racket/two-fer/two-fer-test.rkt new file mode 100644 index 0000000..4af8cc7 --- /dev/null +++ b/racket/two-fer/two-fer-test.rkt @@ -0,0 +1,23 @@ +#lang racket + +; Tests adapted from `problem-specifications/canonical-data.json v1.2.0 +(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/racket/two-fer/two-fer.rkt b/racket/two-fer/two-fer.rkt new file mode 100644 index 0000000..bd11857 --- /dev/null +++ b/racket/two-fer/two-fer.rkt @@ -0,0 +1,6 @@ +#lang racket + +(provide two-fer) + +(define (two-fer (name "you")) + (string-append "One for " name ", one for me."))