12 lines
184 B
Text
12 lines
184 B
Text
shuffle = { a |
|
|
(a.length - 1).to 1 { i |
|
|
random_index = random(0, i)
|
|
temp = a[i]
|
|
a[i] = a[random_index]
|
|
a[random_index] = temp
|
|
}
|
|
|
|
a
|
|
}
|
|
|
|
p shuffle [1 2 3 4 5 6 7]
|