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 exercise: luhn #177

Merged
merged 2 commits into from
Aug 29, 2023
Merged

Add exercise: luhn #177

merged 2 commits into from
Aug 29, 2023

Conversation

MatthijsBlom
Copy link
Contributor

@MatthijsBlom MatthijsBlom commented Aug 25, 2023

Add the Luhn exercise for Slimline September.

config.json Show resolved Hide resolved
Comment on lines 8 to 12
run jq -r -f luhn.jq << 'END_INPUT'
{
"value": "1"
}
END_INPUT
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd rather have

Suggested change
run jq -r -f luhn.jq << 'END_INPUT'
{
"value": "1"
}
END_INPUT
run jq -r -f luhn.jq '"1"'

but I did not spot a way to accomplish this through generate_tests.json.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I wrote generate_tests to grab the canonical-data "input" verbatim. Have a look at the generate_tests.json file, if you would prefer to simplify the bats file and omit this exercise from the test generator.

And jq -r -f luhn.jq '"1"' would give an error

jq: error: Could not open file "1": No such file or directory

You'd want one of

run jq -r -f luhn.jq <<< '"1"'
# or pass into jq as a variable
run jq -r -f luhn.jq --arg input 1

config.json Show resolved Hide resolved
Comment on lines 8 to 12
run jq -r -f luhn.jq << 'END_INPUT'
{
"value": "1"
}
END_INPUT
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I wrote generate_tests to grab the canonical-data "input" verbatim. Have a look at the generate_tests.json file, if you would prefer to simplify the bats file and omit this exercise from the test generator.

And jq -r -f luhn.jq '"1"' would give an error

jq: error: Could not open file "1": No such file or directory

You'd want one of

run jq -r -f luhn.jq <<< '"1"'
# or pass into jq as a variable
run jq -r -f luhn.jq --arg input 1

Copy link
Contributor

Choose a reason for hiding this comment

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

Very nice!
I'd put the try into the function, but I can do that in my own solution.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The try inside of parse_digit? I'm not seeing how that could work out correctly.

Copy link
Contributor

Choose a reason for hiding this comment

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

You'll just have to wait and see :)

@glennj
Copy link
Contributor

glennj commented Aug 28, 2023

This can come out of Draft status for merging, yes?

@MatthijsBlom
Copy link
Contributor Author

I'm aiming to look at the tests' formatting tomorrow, and then undraft.

@MatthijsBlom MatthijsBlom marked this pull request as ready for review August 29, 2023 15:49
@glennj
Copy link
Contributor

glennj commented Aug 29, 2023

Thank you @MatthijsBlom!

@glennj glennj merged commit 779b95b into exercism:main Aug 29, 2023
2 checks passed
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

Successfully merging this pull request may close these issues.

None yet

3 participants