First, the require should be outside of the method; you can actually write any code you want outside of the method as mentioned in the comment (and even remove that comment, of course). I see you're making a list with all possible primes between 0 and the number, but the things is that the kata includes random testcases were number can be up to 100,000,000. So, that's where the ineffiency is, not to mention that you're calculating that array every time the method is called, which has a lot of overhead.

A quick advice (only for this particular kata) is to use a simpler way to deal with primes; try to think of other ways to express a number as the sum of two primes without needing to store a lot of numbers along the way, and sticking to the rule in the problem's description of which pair to use (as there might be various pairs (like 14 could be expressed as 3+11 or 7+7).

It works with the command:"Kate::validate". If you change the class name, it would give you that problem. leave it as "Kata".

my code passed all of tests but when I tried to submit it, I got this error;

"NoMethodError: undefined method `*' for nil:NilClass"

My test numbers are below. What am I doing wrong?

Test.assert_equals(validate(79927398713), true)

Test.assert_equals(validate(79927398710), false)

Test.assert_equals(validate(79927398711), false)

Test.assert_equals(validate(79927398712), false)

Test.assert_equals(validate(79927398714), false)

Test.assert_equals(validate(2543), true)

Test.assert_equals(validate(2741), true)

Test.assert_equals(validate(2841), false)

First, the

`require`

should be outside of the method; you can actually write any code you want outside of the method as mentioned in the comment (and even remove that comment, of course). I see you're making a list with all possible primes between 0 and the number, but the things is that the kata includes random testcases were number can be up to 100,000,000. So, that's where the ineffiency is, not to mention that you're calculating that array every time the method is called, which has a lot of overhead.A quick advice (only for this particular kata) is to use a simpler way to deal with primes; try to think of other ways to express a number as the sum of two primes without needing to store a lot of numbers along the way, and sticking to the rule in the problem's description of which pair to use (as there might be various pairs (like 14 could be expressed as 3+11 or 7+7).

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