daviddavis/rubeque — Issue #53: Regexes seem to not work right in sandboxing
Author: daviddavis
Created: 2012-02-08 13:28:14+00:00
State: open

I want to submit my solution for problem Sum of Primes, but, unfortunately, your system doesn't want to accept it (while I'm certainly sure that it's working solution).

Here's the solution:

# not an optimal, but works nice for small numbers and looks cool
is_prime = ->(n) { ('1' * n) !~ /^(11+?)\1+$/ }
(2..nth_prime).find_all{|n| is_prime.call(n) }.sum

I think that Rubeque eval routine messes with the given regex somehow. It returns 0 when in the normal rails console, it returns 76127.