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.
One alternative to the magic-number-conversion would be to use
Character.digit()
. And some more nitpicking: The import forIntStream
is not necessary.Other than that I agree that this is the best solution I've seen here (after my own of course ;) ).
Yes, I really appreciate the sumDigits method. One of the first solutions I've found that doesn't explicitly convert a char to a String just to then convert to an int. Only problem here is no exception will be thrown if something other than a number character is passed in but that could be handled easily with a quick check on the "c" variable. Thanks!