Skip to content

Instantly share code, notes, and snippets.

@prehnRA
Created September 25, 2015 23:27
Show Gist options
  • Save prehnRA/6accbf3afdaa225d50b4 to your computer and use it in GitHub Desktop.
Save prehnRA/6accbf3afdaa225d50b4 to your computer and use it in GitHub Desktop.
class Shufflebag < Enumerator
def initialize(arr)
i = 0
super() do |y|
loop do
arr = arr.shuffle if i == 0
y << arr[i]
i = (i + 1) % arr.length
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment