Skip to content

Instantly share code, notes, and snippets.

@EdgarOrtegaRamirez
Created August 19, 2016 04:16
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 EdgarOrtegaRamirez/3c60b696d0e9a67a59c156a037cdbfd0 to your computer and use it in GitHub Desktop.
Save EdgarOrtegaRamirez/3c60b696d0e9a67a59c156a037cdbfd0 to your computer and use it in GitHub Desktop.
def gen(nums, digit)
result = []
nums.each_with_index do |num, i|
slice = nums[i, digit]
tmp = slice.concat(nums[i + digit])
result.push(tmp)
end
result
end
gen([0,1,2],1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment