Created
January 3, 2021 07:39
-
-
Save gogvale/65446823b4b0e5cb7d1040892f0f54ed to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'prime' | |
class Array | |
def zip_shift | |
a = self.zip(self.drop(1)) | |
a.pop | |
a | |
end | |
end | |
def gap(g, m, n) | |
(m..n).select{|i| Prime.prime? i }.zip_shift.select{|i| i.reduce(:-) == -g}.first | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://www.codewars.com/kata/561e9c843a2ef5a40c0000a4/train/ruby
The code times out