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
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Both are different.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Wanted to mark it as
clever
but the readability of the code won me over so marked it asBest Practices
.Explicit is better than implicit.
Do you even python? :>
This comment is hidden because it contains spoiler information about the solution