10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/xipai/core.rb', line 10
def scrumble!(words, hashcode, items, opt = {})
seed, hashcode = spinkle_hashcode_bytes(generate_seed(words), hashcode, opt)
random = seed == 0 ? Random.new : Random.new(seed)
normalized_items = normalize_items(items)
shuffled =
normalized_items.shuffle!(
random: Random.new(JSON.generate(
normalized_items.shuffle!(random: random)
).bytes.reduce(:+) + seed.to_i
))
return {
hashcode: hashcode,
shuffled: shuffled
}
end
|