File tree Expand file tree Collapse file tree 2 files changed +4
-16
lines changed Expand file tree Collapse file tree 2 files changed +4
-16
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ In code, it looks something like this:
36
36
{% sample lang="rs" %}
37
37
[ import:16-20, lang:"rust"] ( code/rust/bogosort.rs )
38
38
{% sample lang="swift" %}
39
- [ import:25-31 , lang:"swift"] ( code/swift/bogosort.swift )
39
+ [ import:13-19 , lang:"swift"] ( code/swift/bogosort.swift )
40
40
{% sample lang="php" %}
41
41
[ import:11-16, lang:"php"] ( code/php/bogo_sort.php )
42
42
{% sample lang="nim" %}
Original file line number Diff line number Diff line change @@ -6,27 +6,15 @@ func isSorted(inputArray: [Int]) -> Bool {
6
6
return false
7
7
}
8
8
}
9
-
10
- return true
11
- }
12
-
13
- func shuffle( inputArray: inout [ Int ] ) -> [ Int ] {
14
- var shuffledArray = [ Int] ( )
15
9
16
- for _ in 0 ..< inputArray. count {
17
- let rand = Int ( arc4random_uniform ( UInt32 ( inputArray. count) ) )
18
- shuffledArray. append ( inputArray [ rand] )
19
- inputArray. remove ( at: rand)
20
- }
21
-
22
- return shuffledArray
10
+ return true
23
11
}
24
12
25
13
func bogoSort( sortArray: inout [ Int ] ) -> [ Int ] {
26
14
while ( !isSorted( inputArray: sortArray) ) {
27
- sortArray = shuffle ( inputArray : & sortArray )
15
+ sortArray. shuffle ( )
28
16
}
29
-
17
+
30
18
return sortArray
31
19
}
32
20
You can’t perform that action at this time.
0 commit comments