Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
@mmangiamusardo please mark your post as having spoiler content next time.
This comment is hidden because it contains spoiler information about the solution
.Length returns the total length of the string starting from 1. We need to access the index which begins at 0. If we wanted to access the last index of the original string it would be Length-1. Since we want to cut the last character off, we use -2. Hope that helps
The first character is the other of the two.
The solution is taking a substring starting from the second character and a number of charachers after that equal to the length of the full string minus two.
Example:
You want
234
, which is three characters long. You tell it to skip the first character and then take the three characters after the first one. Therefore it is the length of the full string minus two.I understand that this solution is 100% correct, but I don't understand why we subtract s.Length by 2 instead of 1, wouldn't subtracting by 2 remove the last two characters instead of just the last character? ChatGPT kept talking in circles and broke trying to clarify this for me.
Note. Method "Length" does not account for surrogate pairs. Use StringInfo.LengthInTextElements.
My decision - https://www.codewars.com/kata/reviews/56c3ad3d66d466969a000012/groups/643e422012fc770001fcae79
Not an issue
more test cases
"blurb" added.
Ah, cool, makes sense. Might be nice, not necessary, to include a little blurb about tr being a watered down version of the Unix command to spread some knowledge.
In fact, my idea was rather to evoke the Unix command (https://en.wikipedia.org/wiki/Tr_%28Unix%29) of the same name.
I don't think tr is a good name for this method. Makes me think of html
tag. What about naming the method "trans" or "translate"?Nice! can't wait. I just put this request in via the feed back dialogue. Loving the site.