Ad
  • Default User Avatar

    I really liked the challenge, however as a person who learned to program from Ruby, may I suggest to expand on the instruction or the tests, it took me a couple of tries to understand was it was that the challange wanted from the user. Other than than that, great challenge. Looking forward for more.

  • Custom User Avatar

    Agreed. Codewars uses Ruby 2.1.6, and this issue is not fixed until 2.2

    The random tests fail because although -3 should return false, Ruby 2.1.6
    sees it as -3.abs.prime?, where "self" is just 3.

    I filed a suggestion on this kata... IDK how much the author can do about this.

  • Custom User Avatar

    Which version of Ruby do you have locally? My Ruby 2.0.0 return false for negative numbers.

  • Custom User Avatar

    Large numbers would work with my own tests but not the tests run on submission. Issue seems to have been resolved now I think.

  • Custom User Avatar

    I think I've fixed it. The same error was also in the CoffeeScript translation. Long story short: don't use ceil or .to_f on numbers that exceed the safe range of 2^53 - 1 of IEEE 754 double values.

  • Custom User Avatar

    The ruby test uses floating point operations on large numbers, which does not yield the correct result.

  • Custom User Avatar

    I've got it. Going to file an issue, but I also try to resolve it.

  • Default User Avatar

    i get this too

  • Custom User Avatar

    Sorry, I have no experience with Ruby, and it is indeed weird that the solution produces wrong results.

    Could it be some limitation of large integers in Ruby?

    Hopefully the author of the Ruby translation could give us an answer :)

  • Custom User Avatar

    I agree. I don't see why the regulard Bignum calculations aren't "correct".

    23908490234823904833 should be 23908490234823904835 not 23908490234823905280

  • Custom User Avatar

    I think that the ruby submission tests for big numbers are broken.

    Works with big numbers
    n: 9324082039
    Test Passed: Value == 9324082040
    n: 129043509843590
    Test Passed: Value == 129043509843590
    n: 23908490234823904833
    Expected: 23908490234823905280, instead got: 23908490234823904835
    n: 9012384091234898738954729342
    Expected: 9012384091234899173918638080, instead got: 9012384091234898738954729345

  • Custom User Avatar

    This didn't work for me because many of the tests are random and Ruby's stdlib Prime will return true for negative numbers when the absolute value is prime, but the test is not expecting it.