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.
I don't understand why
[0]
doesn't return an optional that needs to be unwrapped?Isn't
[0]
callingsubscript(_:)
(see https://developer.apple.com/documentation/swift/dictionary/subscript(_:)-8rfqlI think there might be something wrong with this kata on JavaScript. My code is passing the basic tests. While my code fails the attempt test on codewars, I put the exact same input into repljs.com (with the same random strarr and k that the test is testing) and it passes on repljs.com.
This has to be satire. Right?
Yeah I think that should still be validated. 0 is a valid value for UInt32 so it's still a potential bug. Negative numbers don't need to be checked though since they are not valid UInt32 values.
If anyone accidentally calls divisors(0) then this will crash. There needs to be a check like:
guard n != 0 else { return 0 }
However I'm not sure what you should return. Returning 0 would technically be right. 0 has 0 divisors since 0 can't be divided.