You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Guides/Permutations.md
+25Lines changed: 25 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -60,6 +60,31 @@ for perm in numbers2.permutations() {
60
60
// [10, 10, 20]
61
61
```
62
62
63
+
Given a range, the `permutations(ofCount:)` method returns a sequence of all the different permutations of the given sizes of a collection’s elements in increasing order of size.
64
+
65
+
```swift
66
+
let numbers = [10, 20, 30]
67
+
for perm in numbers.permutations(ofCount: 0...) {
68
+
print(perm)
69
+
}
70
+
// []
71
+
// [10]
72
+
// [20]
73
+
// [30]
74
+
// [10, 20]
75
+
// [10, 30]
76
+
// [20, 10]
77
+
// [20, 30]
78
+
// [30, 10]
79
+
// [30, 20]
80
+
// [10, 20, 30]
81
+
// [10, 30, 20]
82
+
// [20, 10, 30]
83
+
// [20, 30, 10]
84
+
// [30, 10, 20]
85
+
// [30, 20, 10]
86
+
```
87
+
63
88
## Detailed Design
64
89
65
90
The `permutations(ofCount:)` method is declared as a `Collection` extension,
0 commit comments