diff --git a/config.json b/config.json index 15c2adc..bbb6ada 100644 --- a/config.json +++ b/config.json @@ -41,6 +41,14 @@ "practices": [], "prerequisites": [], "difficulty": 2 + }, + { + "slug": "two-fer", + "name": "Two Fer", + "uuid": "ca6ddfe1-0355-4316-be0f-fefed9943636", + "practices": [], + "prerequisites": [], + "difficulty": 2 } ] }, diff --git a/exercises/practice/two-fer/.docs/instructions.md b/exercises/practice/two-fer/.docs/instructions.md new file mode 100644 index 0000000..adc5348 --- /dev/null +++ b/exercises/practice/two-fer/.docs/instructions.md @@ -0,0 +1,24 @@ +# Instructions + +Your task is to determine what you will say as you give away the extra cookie. + +If you know the person's name (e.g. if they're named Do-yun), then you will say: + +```text +One for Do-yun, one for me. +``` + +If you don't know the person's name, you will say _you_ instead. + +```text +One for you, one for me. +``` + +Here are some examples: + +| Name | Dialogue | +| :----- | :-------------------------- | +| Alice | One for Alice, one for me. | +| Bohdan | One for Bohdan, one for me. | +| | One for you, one for me. | +| Zaphod | One for Zaphod, one for me. | diff --git a/exercises/practice/two-fer/.docs/introduction.md b/exercises/practice/two-fer/.docs/introduction.md new file mode 100644 index 0000000..5947a22 --- /dev/null +++ b/exercises/practice/two-fer/.docs/introduction.md @@ -0,0 +1,8 @@ +# Introduction + +In some English accents, when you say "two for" quickly, it sounds like "two fer". +Two-for-one is a way of saying that if you buy one, you also get one for free. +So the phrase "two-fer" often implies a two-for-one offer. + +Imagine a bakery that has a holiday offer where you can buy two cookies for the price of one ("two-fer one!"). +You take the offer and (very generously) decide to give the extra cookie to someone else in the queue. diff --git a/exercises/practice/two-fer/.meta/config.json b/exercises/practice/two-fer/.meta/config.json new file mode 100644 index 0000000..5f69aed --- /dev/null +++ b/exercises/practice/two-fer/.meta/config.json @@ -0,0 +1,19 @@ +{ + "authors": [ + "BNAndras" + ], + "files": { + "solution": [ + "src/two-fer.art" + ], + "test": [ + "tests/test-two-fer.art", + "tester.art" + ], + "example": [ + ".meta/src/example.art" + ] + }, + "blurb": "Create a sentence of the form \"One for X, one for me.\".", + "source_url": "https://github.com/exercism/problem-specifications/issues/757" +} diff --git a/exercises/practice/two-fer/.meta/src/example.art b/exercises/practice/two-fer/.meta/src/example.art new file mode 100644 index 0000000..530182a --- /dev/null +++ b/exercises/practice/two-fer/.meta/src/example.art @@ -0,0 +1,6 @@ +twoFer: function [ + name +][ + switch name="" -> twoFer "you" + -> "One for " ++ name ++ ", one for me." +] diff --git a/exercises/practice/two-fer/.meta/tests.toml b/exercises/practice/two-fer/.meta/tests.toml new file mode 100644 index 0000000..d0e3857 --- /dev/null +++ b/exercises/practice/two-fer/.meta/tests.toml @@ -0,0 +1,19 @@ +# This is an auto-generated file. +# +# Regenerating this file via `configlet sync` will: +# - Recreate every `description` key/value pair +# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications +# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) +# - Preserve any other key/value pair +# +# As user-added comments (using the # character) will be removed when this file +# is regenerated, comments can be added via a `comment` key. + +[1cf3e15a-a3d7-4a87-aeb3-ba1b43bc8dce] +description = "no name given" + +[b4c6dbb8-b4fb-42c2-bafd-10785abe7709] +description = "a name given" + +[3549048d-1a6e-4653-9a79-b0bda163e8d5] +description = "another name given" diff --git a/exercises/practice/two-fer/src/two-fer.art b/exercises/practice/two-fer/src/two-fer.art new file mode 100644 index 0000000..37f17df --- /dev/null +++ b/exercises/practice/two-fer/src/two-fer.art @@ -0,0 +1,3 @@ +twoFer: function [name][ + panic "Please implement the twoFer function" +] diff --git a/exercises/practice/two-fer/tester.art b/exercises/practice/two-fer/tester.art new file mode 100644 index 0000000..c54193f --- /dev/null +++ b/exercises/practice/two-fer/tester.art @@ -0,0 +1,3 @@ +import {unitt}! + +runTests.failFast findTests "tests" \ No newline at end of file diff --git a/exercises/practice/two-fer/tests/test-two-fer.art b/exercises/practice/two-fer/tests/test-two-fer.art new file mode 100644 index 0000000..dba81f1 --- /dev/null +++ b/exercises/practice/two-fer/tests/test-two-fer.art @@ -0,0 +1,19 @@ +import {unitt}! +import {src/two-fer}! + +suite "Two Fer" [ + test "no name given" [ + result: twoFer "" + assert -> "One for you, one for me." = result + ] + + test.skip "a name given" [ + result: twoFer "Alice" + assert -> "One for Alice, one for me." = result + ] + + test.skip "another name given" [ + result: twoFer "Bob" + assert -> "One for Bob, one for me." = result + ] +]