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

Implement new exercise, two-fer #757

Closed
5 tasks done
kytrinyx opened this issue Apr 17, 2017 · 22 comments
Closed
5 tasks done

Implement new exercise, two-fer #757

kytrinyx opened this issue Apr 17, 2017 · 22 comments

Comments

@kytrinyx
Copy link
Member

kytrinyx commented Apr 17, 2017

In #548 we discussed a new exercise which is equivalent to the current hello-world exercise (which conditionally provides a name, or defaults to "world") in the string "hello, %s".

The conclusion was to implement a new exercise, two-fer.

  • Title: Two Fer
  • Slug: two-fer
  • Template: "One for X, one for me." where X is either a name, or it defaults to "you".

Next steps:

tejasbubane added a commit to tejasbubane/problem-specifications that referenced this issue Apr 17, 2017
This is meant to be right after hello-world introducing users to basic
programming constructs as well as TDD which will be used in all later
exercises.

Discussion regarding this is [here](exercism#548).

Closes exercism#757.
tejasbubane added a commit to tejasbubane/problem-specifications that referenced this issue Apr 18, 2017
This is meant to be right after hello-world introducing users to basic
programming constructs as well as TDD which will be used in all later
exercises.

Discussion regarding this is [here](exercism#548).

Closes exercism#757.
tejasbubane added a commit to tejasbubane/problem-specifications that referenced this issue Apr 23, 2017
This is meant to be right after hello-world introducing users to basic
programming constructs as well as TDD which will be used in all later
exercises.

Discussion regarding this is [here](exercism#548).

Closes exercism#757.
emcoding pushed a commit that referenced this issue Nov 19, 2018
pangram: Update to match changes in canonical data
@amit-rastogi
Copy link

TwoferTest.scala throws a compilation error when running sbt test
test("no name given") {
Twofer.twofer() should be ("One for you, one for me.")
}
[error] Unspecified value parameter name.
[error] Twofer.twofer() should be ("One for you, one for me.")
[error] ^
[error] one error found
[error] (Test / compileIncremental) Compilation failed

Twofer.twofer() has the name parameter missing. On adding an empty name parameter error is resolved.

test("no name given") {
Twofer.twofer(name = "") should be ("One for you, one for me.")
}

@SaschaMann
Copy link
Contributor

SaschaMann commented Apr 26, 2020

@amit-rastogi you may want to report that in the scala track repo. You're more likely to find help there because this repo is about the shared test cases, not the scala implementation, and the scala team might not notice the bug report here.

(cc @exercism/scala)

@heshamfm
Copy link

heshamfm commented Aug 1, 2020

I am not sure if this is the right place to call for help. I am new to Pharo and trying to use exercism.io to practice. However, I failed to import the example code that I downloaded from https://exercism.io/my/solutions/2c59b5cf2508431baae6a5b95c85a720 into Pharo. I checked in the community and came to understand that Pharo is using a file format called Tonel, which is not the one used in Pharo-exercism. In order to work on Pharo track exercises, one must take it into a Pharo image.

Please advise.

@NobbZ
Copy link
Member

NobbZ commented Aug 1, 2020

As far as I understand the workflow for Pharo, you need to use some prepared Pharo image that does the downloads and submissions for you.

Please refer to the Pharo instructions on the website and open a complete new issue at GitHub.com/exercism/exercism

@heshamfm
Copy link

heshamfm commented Aug 1, 2020

@NobbZ I found this repo https://github.com/exercism/pharo-smalltalk but if i understand correctly, it is for already experienced Pharo developers to contribute. I could not find instructions for freshers like myself.

@NobbZ
Copy link
Member

NobbZ commented Aug 9, 2020

You can ask your question how to work with the pharo track there, chances to find someone who can help you are highest there.

Also, have you followed instructions from https://exercism.io/tracks/pharo-smalltalk/installation, which asks you to run some magic invocation to install the exercism plugin into the Pharo IDE?

@IliasMariosG
Copy link

Hello,
in Python3 once I run the test by typing in pytest two_fer_test.py in my shell(zsh) the following is shown:

self = <two_fer_test.TwoFerTest testMethod=test_no_name_given>

    def test_no_name_given(self):
>       self.assertEqual(two_fer(), "One for you, one for me.")
E       TypeError: two_fer() missing 1 required positional argument: 'name'

two_fer_test.py:10: TypeError
======================================================================= short test summary info ========================================================================
FAILED two_fer_test.py::TwoFerTest::test_no_name_given - TypeError: two_fer() missing 1 required positional argument: 'name'

I am using pylint as well. It points to:
> self.assertEqual(two_fer(), "One for you, one for me.")

If I add an empty name, thus:
self.assertEqual(two_fer(""), "One for you, one for me.")
it passes - given that I change the conditional statement accordingly in a separate code file named two_fer.py:

if name == " ":
    return "One for you, one for me"

@coriolinus
Copy link
Member

@IliasMariosG This portion of the exercise is intended to teach you about default arguments. Almost certainly, your code is written something like

def two_fer(name):
    # implementation here

However, as the error says, this definition type only works if you pass a value which can be bound to the name parameter. The definition of the problem, however, asks that you define your two_fer function such that you can call it without a value. That would look more like this:

def two_fer(name = "default"):
    # implementation here

With that definition, anytime the caller doesn't provide a value to be bound to name, it will use the default value "default" instead. From there, it's pretty easy to get the test to pass.


Incidentally, while it's good that you've done your research to identify the source of the two-fer exercise, this isn't really the place to ask for help about the python track. Instead, you can create a new issue in exercism/python.

Harrisj22412 referenced this issue in Harrisj22412/Exercism Feb 11, 2021
# Two Fer

`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.

## Setup

Go through the setup instructions for Javascript to install the necessary
dependencies:

[https://exercism.io/tracks/javascript/installation](https://exercism.io/tracks/javascript/installation)

## Requirements

Please `cd` into exercise directory before running all below commands.

Install assignment dependencies:

```bash
$ npm install
```

## Making the test suite pass

Execute the tests with:

```bash
$ npm test
```

In the test suites all tests but the first have been skipped.

Once you get a test passing, you can enable the next one by changing `xtest` to
`test`.


## Submitting Solutions

Once you have a solution ready, you can submit it using:

```bash
exercism submit two-fer.js
```

## Submitting Incomplete Solutions

It's possible to submit an incomplete solution so you can see how others have
completed the exercise.

## Exercise Source Credits

[https://github.com/exercism/problem-specifications/issues/757](https://github.com/exercism/problem-specifications/issues/757)
@ElijahLynn
Copy link

ElijahLynn commented Jun 17, 2021

On a new checkout of this problem and running npm test I get the below error. I can run npm test fine on the Hello World exercise, fwiw.

❯ npm test

> @exercism/javascript@1.2.0 test /home/elijah/exercism/javascript/two-fer
> jest --no-cache ./*

sh: line 1: jest: command not found
npm ERR! Test failed.  See above for more details.

UPDATE: Okay, works fine, I forgot to run npm install!

@erbase
Copy link

erbase commented Jul 31, 2021

I think there is a problem in the Delphi exercise on Git.
It seems that the source of twofer.pas file is empty!
Dows anyone know something about this?

@NobbZ
Copy link
Member

NobbZ commented Jul 31, 2021

Fill it with functionality. In the current v2, this is a choice some tracks did.

@parkerbonnie
Copy link

As of Version 1.2.0, the unit tests for this exercise do not compile.

Compile error: Unspecified value parameters: name: String

The following line is missing en empty string:
Twofer.twofer() should be ("One for you, one for me.")

It should be this instead:
Twofer.twofer("") should be ("One for you, one for me.")

@axor
Copy link

axor commented Mar 4, 2022

Hello fellow developers.

I'm a total noob in python but I'm wondering why this code is not valid in your validation testing:

def two_fer(self=''):
    if self != '':
        return print(f'One for {self}, one for me.')
    else:
        return print('One for you, one for me.')

Thank you, and sorry in advance if this is not the correct channel to give you feedback regarding exercises.

@ynfle
Copy link
Contributor

ynfle commented Mar 4, 2022

@axor there is a difference between returning a value and printing a value. return is intended to pass the value to the calling function, while print is intended to print the value to the console. If you remove the print function and the parentheses it should pass the tests.

Feel free to request mentoring (and if the tests isn't passing you can submit and incomplete solution from the CLI) and someone be able to assist you.

EDIT: issues for python specifically should be in https://github.com/exercism/python

@fletheno1
Copy link

@axor there is a difference between returning a value and printing a value. return is intended to pass the value to the calling function, while print is intended to print the value to the console. If you remove the print function and the parentheses it should pass the tests.

Feel free to request mentoring (and if the tests isn't passing you can submit and incomplete solution from the CLI) and someone be able to assist you.

EDIT: issues for python specifically should be in https://github.com/exercism/python

!!! Good tip : try to return answer without print function, just compose the answer in combination with strings in parenthesis and the variable

@saveriogzz
Copy link

Hello!
I'm trying to run the following scala code (which I reckon is correct)

object Twofer {
  def twofer(name: String = ""): String = name match {
    case "" => "One for you, one for me."
    case _  => s"One for $name, one for me."
  }
}

but I receive the following error when running the tests:
image

@glennj
Copy link
Contributor

glennj commented Jun 20, 2022

@saveriogzz you'll get better response by creating an issue in the exercism/exercism repo

giridat added a commit to giridat/dart that referenced this issue Jun 21, 2022
The test file has been updated as the test was failing when the 'no name given' test was being executed. I found the answer via this exercism/problem-specifications#757 (comment)
@yuvakkrishnan

This comment was marked as off-topic.

@adithyabsk
Copy link

This exercise may be out of order in the golang exercise listing page. I was surprised by the simplicity of the exercise until I came to this page to notice that it was supposed to be equivalent to hello world.

@kytrinyx
Copy link
Member Author

@adithyabsk Would you report this in the forum? https://forum.exercism.org/ That will ensure that the right people see the discussion.

@joanmarcriera
Copy link

joanmarcriera commented Jul 16, 2023

In mac , using brew I got the following error 👍

Error: bats has been disabled because it has an archived upstream repository!

So I installed bats-core and it worked.

brew install bats-core

@IsaacG
Copy link
Member

IsaacG commented Jul 16, 2023

In mac , using brew I got the following error 👍

Error: bats has been disabled because it has an archived upstream repository!

So I installed bats-core and it worked.

brew install bats-core

That's unrelated to this issue. For support, consider using the forum or Discord.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests