Skip to content

Instantly share code, notes, and snippets.

@gogvale
Created January 3, 2021 07:39
Show Gist options
  • Save gogvale/65446823b4b0e5cb7d1040892f0f54ed to your computer and use it in GitHub Desktop.
Save gogvale/65446823b4b0e5cb7d1040892f0f54ed to your computer and use it in GitHub Desktop.
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
@gogvale
Copy link
Author

gogvale commented Jan 3, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment