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
|
|
@ -0,0 +1,23 @@
|
|||
import Darwin
|
||||
|
||||
func shuffle<T>(inout array: [T]) {
|
||||
for i in 1..<array.count {
|
||||
let j = Int(arc4random_uniform(UInt32(i)))
|
||||
(array[i], array[j]) = (array[j], array[i])
|
||||
}
|
||||
}
|
||||
|
||||
func issorted<T:Comparable>(ary: [T]) -> Bool {
|
||||
for i in 0..<(ary.count-1) {
|
||||
if ary[i] > ary[i+1] {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func bogosort<T:Comparable>(inout ary: [T]) {
|
||||
while !issorted(ary) {
|
||||
shuffle(&ary)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue