something goofy happened(between first and last curly braces :P) when I split string str at the spaces. It seems like it added an empty value at the end of the string array x which forced me to add ""- 1" to both instances of x.Length that followed. If anyone could shed some light on why this happened or how to avoid it in the future, it would be greatly appreciated.
Yup I also think it would be nice if this kata failed for solutions which rely on behavior of object.operator==.
Understanding where the warning comes from is a nice way to learn why in C# searching for a string by comparison with operator== works if haystack is string[], but does not work if haystack is object[], but still works if needle is a string literal.
"And the award for longest and most convoluded solution goes to..."
Seriously though, after looking at some of the other answers, I am kind of embarrassed.
LMFAAAOOO
added a test to invalidate those solutions
something goofy happened(between first and last curly braces :P) when I split string str at the spaces. It seems like it added an empty value at the end of the string array x which forced me to add ""- 1" to both instances of x.Length that followed. If anyone could shed some light on why this happened or how to avoid it in the future, it would be greatly appreciated.
Then try this other kata: https://www.codewars.com/kata/569651a2d6a620b72e000059, but you can only do it (right now) in C# or Ruby.
...just in case this kata is updated to include "lizard" and "spock"...
Instructions should state that empty arrays should return '0'.
Yup I also think it would be nice if this kata failed for solutions which rely on behavior of
object.operator==
.Understanding where the warning comes from is a nice way to learn why in C# searching for a string by comparison with
operator==
works if haystack isstring[]
, but does not work if haystack isobject[]
, but still works if needle is a string literal.This comment is hidden because it contains spoiler information about the solution
"And the award for longest and most convoluded solution goes to..."
Seriously though, after looking at some of the other answers, I am kind of embarrassed.