7 kyu
The old switcheroo 2
1,522 of 3,369joh_pot
Loading description...
Strings
Fundamentals
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
JS fork
Merged
This comment has been hidden.
If you use lodash, it can be
_.sample(charset)
and no problems with indexing :)EDIT: fixed
JS should be updated to Node 18
Done
In JS (at least):
This solution utilizes a special character in a way such that if that char was present in the input string, the code would fail.
Complete testing should include all special characters to defeat solutions of this catagory.
fixed (see JS fork above)
It's fixed for the underscore character, but the general issue still stays that a filler character can be used and won't be detected, because detecting it would require testing of the whole character space. I would say that using a character outside of the alphabet used by the problem as padding is not incorrect. What do you think?
There is nothing stated about whether or not the input should only be English letters + spaces + ..., so any character can be used in test cases. And using
.indexOf(x)
with padding instead of.indexOf(x) + 1
in this case is incorrect, so that should be tested as well.Description should be language-agnostic
Should give example tests for capital letters
done
The given parameter name can be changed to avoid clashes with the string module in Python.
done
C translation
Thanks :)
Ruby 3.0 should be enabled, see this to learn how to do it
done
Python 3 should be enabled.
Done.
This comment has been hidden.
I disagree. This is a suggestion, not an issue.
This comment has been hidden.
I don't test for any of those letters, they're not in the English alphabet. If it returns true, I'm completely unconcerned about it because this kata simply does not care about those false positives. To be honest, the fact that some solutions can replace non English chars too is even better, the only reason why I have put in the description
English alphabet letters
is simply to reduce the amount of work people have to do.Mmh… I suddenly feel like a misunderstood pain in the neck… Forget about it :)
I'm getting the following error when trying to submit code that's running fine in https://repl.it/
ReferenceError: encode is not defined at _ at /runner/frameworks/javascript/cw-2.js:241:21 at Promise._execute at Promise._resolveFromExecutor at new Promise at Test.describe
It seems to be something to do with the underscore at the arrow function here in the test cases: describe('Initial Tests', _ => {
And this one is translated too :)
If you are so kind to post below this comment and remember me I would have to add something to the description (done later, so to avoid possible nasty merging issues!), I'd sincerely appreciate :)
Approved! Thanks for taking time out to translate it.
Hi, I've added a CoffeeScript translation, if you want to approve it, instructions for the approval process are here.
C# translation kumited