Sha256: aebe631e808d7a8b59eab0bc92e9bc8df5a81fa246d9f49bc68683d7855e6161
Contents?: true
Size: 345 Bytes
Versions: 44
Compression:
Stored size: 345 Bytes
Contents
require 'enumerator' class Array def chunk(pieces) q, r = length.divmod(pieces) (0..pieces).map { |i| i * q + [r, i].min }.enum_cons(2) \ .map { |a, b| slice(a...b) } end def shuffle sort_by { rand } end def shuffle! self.replace shuffle end def random idx = Kernel.rand(size) at(idx) end end
Version data entries
44 entries across 44 versions & 3 rubygems