Skip to content

Commit

Permalink
[New exercise]: two-fer (#8)
Browse files Browse the repository at this point in the history
* Add two-fer

* Add author

* Fix formatting

* Fixed test file

* Change from spaces to tab

* Fix exemplar file

* Update test name
  • Loading branch information
meatball133 authored Feb 26, 2024
1 parent 4c4a76f commit a457ad4
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 0 deletions.
8 changes: 8 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@
"prerequisites": [],
"difficulty": 1
},
{
"uuid": "e1f3aab9-ca32-4f6f-b266-d05d82c94535",
"slug": "two-fer",
"name": "Two Fer",
"practices": [],
"prerequisites": [],
"difficulty": 1
},
{
"slug": "resistor-color-duo",
"name": "Resistor Color Duo",
Expand Down
25 changes: 25 additions & 0 deletions exercises/practice/two-fer/.docs/instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Instructions

Your task is to determine what you will say as you give away the extra cookie.

If your friend likes cookies, and is named Do-yun, then you will say:

```text
One for Do-yun, one for me.
```

If your friend doesn't like cookies, you give the cookie to the next person in line at the bakery.
Since you don't know their 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 go for the offer and (very generously) decide to give the extra cookie to a friend.
16 changes: 16 additions & 0 deletions exercises/practice/two-fer/.meta/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"authors": ["meatball133"],
"files": {
"solution": [
"two_fer.gd"
],
"test": [
"two_fer_test.gd"
],
"example": [
".meta/example.gd"
]
},
"blurb": "Create a sentence of the form \"One for X, one for me.\".",
"source_url": "https://github.com/exercism/problem-specifications/issues/757"
}
2 changes: 2 additions & 0 deletions exercises/practice/two-fer/.meta/example.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
func two_fer(name = "you"):
return "One for %s, one for me." % name
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"
2 changes: 2 additions & 0 deletions exercises/practice/two-fer/two_fer.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
func two_fer():
pass
8 changes: 8 additions & 0 deletions exercises/practice/two-fer/two_fer_test.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
func test_no_name_given(solution_script):
return [solution_script.two_fer(), "One for you, one for me."]

func test_a_name_given(solution_script):
return [solution_script.two_fer("Alice"), "One for Alice, one for me."]

func test_another_name_given(solution_script):
return [solution_script.two_fer("Bob"), "One for Bob, one for me."]

0 comments on commit a457ad4

Please sign in to comment.