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.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Confused by the description? Here's how I rewrote it. Language is Ruby.
Define a method that takes an array of numbers, and returns a number, such that when added to the array, the sum of the array equals a prime number. The return value must be non-negative.
When I test n = 847043, it says Expected: 87043, instead got: 87443
The maximal number that I returned is larger. I delete the zero, then create a larger number than what the unit tests returns. It appears you can move around numbers. But looking at the provided test cases, you may not move around numbers.
It's not clever, it's a basic ternary operation!
Define a method that takes an array of numbers and returns the sum of its squares.
Using Ruby, it will not use Array#count on arrays. I'm guessing this is using an old Ruby version. Error: Undefined method 'count' for ["a", "b", "b"].
Ah I see, thanks. edited version
Confused by the description? Here's how I rewrote it. Language is Ruby.
Define a method that takes an array of numbers, and returns a number, such that when added to the array, the sum of the array equals a prime number. The return value must be non-negative.
Confused by the description? Here's how I rewrote it. Language is Ruby.
Define a method that takes an array of numbers, and returns a number, such that when added to the array, the sum of the array equals a prime number. The return value must be positive.