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

[New exercise]: two-fer #8

Merged
merged 8 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from 7 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 @@ -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 no_name_given(solution_script):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test methods need to start with test_ for the new test runner to pick them up ;)

It is also a standard in GDScript to have 2 empty lines between methods.

Other than this, I think the solution and tests look good 👍

return [solution_script.two_fer(), "One for you, one for me."]

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

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