File tree Expand file tree Collapse file tree 1 file changed +18
-18
lines changed
Expand file tree Collapse file tree 1 file changed +18
-18
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ runnableExamples:
99 var arr = @ [3 , 1 , 2 ]
1010 bogoSort (arr)
1111 doAssert isSorted (arr)
12-
12+
1313 var arr2 = @ [" c" , " a" , " b" ]
1414 bogoSort (arr2)
1515 doAssert isSorted (arr2)
@@ -18,24 +18,24 @@ runnableExamples:
1818import random
1919
2020func isSorted [T](arr: openArray [T]): bool =
21- for i in 0 ..< arr.len - 1 :
22- if arr[i] > arr[i + 1 ]:
23- return false
24- return true
21+ for i in 0 ..< arr.len - 1 :
22+ if arr[i] > arr[i + 1 ]:
23+ return false
24+ return true
2525
2626proc bogoSort * [T](arr: var openArray [T]) =
27- while not isSorted (arr):
28- shuffle (arr)
27+ while not isSorted (arr):
28+ shuffle (arr)
2929
3030when isMainModule :
31- import std/ unittest
32- suite " BogoSortTests" :
33- test " sort an array of integers" :
34- var arr = @ [3 , 1 , 2 ]
35- bogoSort (arr)
36- check isSorted (arr)
37-
38- test " sort an array of strings" :
39- var arr = @ [" c" , " a" , " b" ]
40- bogoSort (arr)
41- check isSorted (arr)
31+ import std/ unittest
32+ suite " BogoSortTests" :
33+ test " sort an array of integers" :
34+ var arr = @ [3 , 1 , 2 ]
35+ bogoSort (arr)
36+ check isSorted (arr)
37+
38+ test " sort an array of strings" :
39+ var arr = @ [" c" , " a" , " b" ]
40+ bogoSort (arr)
41+ check isSorted (arr)
You can’t perform that action at this time.
0 commit comments