Skip to content

Instantly share code, notes, and snippets.

@dean-gr
Last active January 21, 2016 07:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dean-gr/1e6ff0bf9090f4d8043e to your computer and use it in GitHub Desktop.
Save dean-gr/1e6ff0bf9090f4d8043e to your computer and use it in GitHub Desktop.
Check if given input is continuous based on a given range
set_range = (0..6).to_a
a = (1..3).to_a
b = [1, 3, 4]
def continous?(input, set_range)
range.each_cons(input.count) do |c|
p c == input
end
continous?(range, a) #=> should return true
continous?(range, b) #=> should return false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment