-
-
Notifications
You must be signed in to change notification settings - Fork 9
Sync and add reverse-string tests
#79
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
Merged
meatball133
merged 5 commits into
exercism:main
from
codingthat:sync-and-add-reverse-string-tests
Apr 21, 2025
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
38d8a0e
Sync `reverse-string` exercise's tests with the latest data; implemen…
codingthat aa0c37e
Rename 'str' to avoid compiler warnings.
codingthat 3237aa7
Sync `reverse-string` docs
codingthat d7a1b05
Use `create_from_string` in example (compilation result isn't checked…
codingthat 5aa87e2
Add web-visible help for `reverse-string` for advanced tests
codingthat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| func reverse(str): | ||
| var result = "" | ||
| for i in range(str.length() - 1, -1, -1): | ||
| result += str[i] | ||
| return result | ||
| func reverse(original): | ||
| var regex = RegEx.new() | ||
| regex.compile("\\X") | ||
| var clusters = regex.search_all(original).map(func(m): return m.get_string()) | ||
| clusters.reverse() | ||
| return "".join(clusters) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,34 +1,52 @@ | ||
| func test_empty_string(solution_script): | ||
| var str = "" | ||
| func test_empty_originaling(solution_script): | ||
| var original = "" | ||
| var expected = "" | ||
| return [solution_script.reverse(str), expected] | ||
| return [solution_script.reverse(original), expected] | ||
|
|
||
|
|
||
| func test_a_word(solution_script): | ||
| var str = "robot" | ||
| var original = "robot" | ||
| var expected = "tobor" | ||
| return [solution_script.reverse(str), expected] | ||
| return [solution_script.reverse(original), expected] | ||
|
|
||
|
|
||
| func test_a_capitalized_word(solution_script): | ||
| var str = "Ramen" | ||
| var original = "Ramen" | ||
| var expected = "nemaR" | ||
| return [solution_script.reverse(str), expected] | ||
| return [solution_script.reverse(original), expected] | ||
|
|
||
|
|
||
| func test_a_sentence_with_punctuation(solution_script): | ||
| var str = "I'm hungry!" | ||
| var original = "I'm hungry!" | ||
| var expected = "!yrgnuh m'I" | ||
| return [solution_script.reverse(str), expected] | ||
| return [solution_script.reverse(original), expected] | ||
|
|
||
|
|
||
| func test_a_palindrome(solution_script): | ||
| var str = "racecar" | ||
| var original = "racecar" | ||
| var expected = "racecar" | ||
| return [solution_script.reverse(str), expected] | ||
| return [solution_script.reverse(original), expected] | ||
|
|
||
|
|
||
| func test_an_even_sized_word(solution_script): | ||
| var str = "drawer" | ||
| var original = "drawer" | ||
| var expected = "reward" | ||
| return [solution_script.reverse(str), expected] | ||
| return [solution_script.reverse(original), expected] | ||
|
|
||
|
|
||
| func test_wide_characters(solution_script): | ||
| var original = "子猫" | ||
| var expected = "猫子" | ||
| return [solution_script.reverse(original), expected] | ||
|
|
||
|
|
||
| func test_grapheme_cluster_with_pre_combined_form(solution_script): | ||
| var original = "Würstchenstand" | ||
| var expected = "dnatsnehctsrüW" | ||
| return [solution_script.reverse(original), expected] | ||
|
|
||
|
|
||
| func test_grapheme_clusters(solution_script): | ||
| var original = "ผู้เขียนโปรแกรม" | ||
| var expected = "มรกแรปโนยขีเผู้" | ||
| return [solution_script.reverse(original), expected] |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Probably a good candidate to add a hints.md given the trick needed to pass the new tests.
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.
You can't see hints in the web editor for practice exercises, so I think it is better to put them in an instruction append doc if needed.
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.
Done, thanks!