-
-
Notifications
You must be signed in to change notification settings - Fork 553
reverse-string: Add new exercise #960
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
Changes from 19 commits
8f3e2b2
ad599ed
7accf3c
64f23a3
6ed698d
300a3e0
4decbde
531587e
4c926c4
b10dcb9
4807fe1
57f7581
5eac807
1f4da26
1d08667
fcdb93b
8303c96
6595854
a32e42a
1433c14
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"exercise": "reverse-string", | ||
"version": "1.0.0", | ||
"comments": [ | ||
"If property based testing tools are available, a good property to test is reversing a string twice: reverse(reverse(string)) == string" | ||
], | ||
"cases": [ | ||
{ | ||
"description": "empty string", | ||
"property": "reverse", | ||
"input": "", | ||
"expected": "" | ||
}, | ||
{ | ||
"description": "a word", | ||
"property": "reverse", | ||
"input": "robot", | ||
"expected": "tobor" | ||
}, | ||
{ | ||
"description": "a capitalized word", | ||
"property": "reverse", | ||
"input": "Ramen", | ||
"expected": "nemaR" | ||
}, | ||
{ | ||
"description": "a sentence with punctuation", | ||
"property": "reverse", | ||
"input": "I'm hungry!", | ||
"expected": "!yrgnuh m'I" | ||
}, | ||
{ | ||
"description": "a string that reads the same backward as forward (i.e. palindrome)", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Continuing discussion from: #960 (comment) It is helpful for descriptions to be short and to the point, so either "a string that reads the same backwards and forwards" but not both. My preference is for "a palindrome", because that is the briefest description of what it is. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To give a concrete example of why concision is useful, consider the output of programs which generate tests based on the canonical data. Which is best:
Depending on which option gets merged, the Rust test generator will create one of the above. IMO, the shortest is the best. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok I'm convinced. I added just "a palindrome" for description to latest commit. Please review @Insti. Thanks. |
||
"property": "reverse", | ||
"input": "racecar", | ||
"expected": "racecar" | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Reverse a string | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Short description is good 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree, short and to the point! |
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This description contains too many instructions. It would be fine to include some background on what a 'string' is. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This is hard in a language agnostic way… I think the most agnostic way were to say "its an ordered sequence of characters". But even this description might fail if you accept BEAMs io-lists as strings… There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I agree, which makes me think even including the word "string" is a bad idea. maybe 'text' or 'words' or 'snippet' or 'sentence' or something else..? |
||
For example: | ||
input: "cool" | ||
output: "looc" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
blurb: "Reverse a string" | ||
title: "reverse-string" | ||
source: "Introductory challenge to reverse an input string" | ||
source_url: "https://medium.freecodecamp.org/how-to-reverse-a-string-in-javascript-in-3-different-ways-75e4763c68cb" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you defining palindrome here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think everybody knows what a palindrome is, and personally, I'd rather have it defined here than have to google it. If you feel strongly we don't need to define it, please state why you think everybody knows this. Perhaps wording can change some.