Skip to content

Commit

Permalink
Update Combinatorics to match Swift 4 API
Browse files Browse the repository at this point in the history
  • Loading branch information
minuscorp authored Apr 11, 2018
1 parent 2a5e031 commit 6bf3a16
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions Combinatorics/README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,17 @@ Here's a recursive algorithm by Niklaus Wirth:

```swift
func permuteWirth<T>(_ a: [T], _ n: Int) {
if n == 0 {
print(a) // display the current permutation
} else {
var a = a
permuteWirth(a, n - 1)
for i in 0..<n {
swap(&a[i], &a[n])
permuteWirth(a, n - 1)
swap(&a[i], &a[n])
if n == 0 {
print(a) // display the current permutation
} else {
var a = a
permuteWirth(a, n - 1)
for i in 0..<n {
a.swapAt(i, n)
permuteWirth(a, n - 1)
a.swapAt(i, n)
}
}
}
}
```

Expand Down

0 comments on commit 6bf3a16

Please sign in to comment.