Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
11
Task/Knuth-shuffle/Nim/knuth-shuffle.nim
Normal file
11
Task/Knuth-shuffle/Nim/knuth-shuffle.nim
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import math
|
||||
randomize()
|
||||
|
||||
proc shuffle[T](x: var seq[T]) =
|
||||
for i in countdown(x.high, 0):
|
||||
let j = random(i + 1)
|
||||
swap(x[i], x[j])
|
||||
|
||||
var x = @[0,1,2,3,4,5,6,7,8,9]
|
||||
shuffle(x)
|
||||
echo x
|
||||
Loading…
Add table
Add a link
Reference in a new issue