Ad
  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    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.

  • Default User Avatar

    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.

  • Default User Avatar

    It's not clever, it's a basic ternary operation!

  • Default User Avatar

    Define a method that takes an array of numbers and returns the sum of its squares.

  • Default User Avatar

    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"].

  • Default User Avatar

    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.

  • Default User Avatar

    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.