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

Add two-fer #5

Merged
merged 1 commit into from
May 23, 2024
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
8 changes: 8 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@
"practices": [],
"prerequisites": [],
"difficulty": 2
},
{
"slug": "two-fer",
"name": "Two Fer",
"uuid": "ca6ddfe1-0355-4316-be0f-fefed9943636",
"practices": [],
"prerequisites": [],
"difficulty": 2
}
]
},
Expand Down
24 changes: 24 additions & 0 deletions exercises/practice/two-fer/.docs/instructions.md
Original file line number Diff line number Diff line change
@@ -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. |
8 changes: 8 additions & 0 deletions exercises/practice/two-fer/.docs/introduction.md
Original file line number Diff line number Diff line change
@@ -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.
19 changes: 19 additions & 0 deletions exercises/practice/two-fer/.meta/config.json
Original file line number Diff line number Diff line change
@@ -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"
}
6 changes: 6 additions & 0 deletions exercises/practice/two-fer/.meta/src/example.art
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
twoFer: function [
name
][
switch name="" -> twoFer "you"
-> "One for " ++ name ++ ", one for me."
]
19 changes: 19 additions & 0 deletions exercises/practice/two-fer/.meta/tests.toml
Original file line number Diff line number Diff line change
@@ -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"
3 changes: 3 additions & 0 deletions exercises/practice/two-fer/src/two-fer.art
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
twoFer: function [name][
panic "Please implement the twoFer function"
]
3 changes: 3 additions & 0 deletions exercises/practice/two-fer/tester.art
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import {unitt}!

runTests.failFast findTests "tests"
19 changes: 19 additions & 0 deletions exercises/practice/two-fer/tests/test-two-fer.art
Original file line number Diff line number Diff line change
@@ -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
]
]