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.
Did the Java version -- ha, sneaky. May be closer to a 7kyu kata.
Agreed. It could be a valid trap teaching input validation if you also needed to handle null, empty strings, and strings without space, but then it wouldn't be 8kyu. And then the description could use a "WARNING! Some input validation may be required" thingy.
Oh damn, I'm really out of shape. I solved it, but not in the nicest way... :P
My first thought was to create a regex pattern that would handle it all for me, but I couldn't figure it out since I'm shit at regex... had to look for a different way, but even then... a lot of unnecessary stuff in my solution.
Nice kata.
I don't think this is an issue (the kata isn't broken or anything like that, it functions just fine and programmers are spec-following creatures), but you're absolutely right. If this were a real-life specification and not a kata for training, I'd start by complaining about the spec.
Imagine if you also had to write a separate function to check whether your letter summation actually happened. Whoops, too bad! You can't do that by just checking the result, because "z" is, obviously, a valid result in and of itself. "a" + "y", anyone?
Yes, in certain implementations it makes the programmer's life easier to just return "z", and, perhaps, it allows you to feel proud by doing things elegantly enough to not write a zero-check, but it's usually a really bad idea to have a null result that is also valid as a non-null result. I'm a beginner, but I'm astounded so many clearly very experienced people, including someone with 1 dan, seem to not get this.
Ignore the downvoters. Other than reporting it as an "issue" (I think that's too harsh), you're absolutely right. The return value for no arguments doesn't really have to be null, it can be literally anything that's distinct from all the other results, it could even just be an empty string (makes a lot of sense, actually), but "if there are no arguments, return "z", please" would be a terrible spec in real life.