Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def ordered_permutations(array: [1,2,3], length: n)
- array = array.dup
- [].tap do |result|
- (array.count - (length - 1)).times do
- result << array[0..(length-1)]
- array.shift
- end
- end
- end
- p ordered_permutations(array: a, length: 3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement