Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use "random"
- use "collections"
- use "itertools"
- actor Main
- let env: Env
- let hands: Array[USize]
- new create (env': Env) =>
- env = env'
- env.out.print("Creating array ...")
- let size: USize = 260_000
- hands = Iter[USize](Range(0, size)).collect(Array[USize](size))
- Rand.shuffle[USize](hands)
- try
- for i in Range(0,5) do
- env.out.print(hands(i)?.string())
- end
- end
- env.out.print("Starting insertion sort ...")
- do_sort()
- be do_sort() =>
- env.out.flush()
- try
- for i in Range(1, hands.size()) do
- let item = hands(i)?
- var j = i
- while (j > 0) and (hands(j - 1)? > item) do
- hands(j)? = hands(j - 1)?
- j = j - 1
- end
- hands(j)? = item
- end
- end
- env.out.print("Complete.")
- try
- for i in Range(0,5) do
- env.out.print(hands(i)?.string())
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement