(permutation: &mut Vec<Vec<i32>>, elem: i32)
| 15 | } |
| 16 | |
| 17 | pub fn permute_add(permutation: &mut Vec<Vec<i32>>, elem: i32) { |
| 18 | if permutation.len() == 0 { |
| 19 | permutation.push(vec![elem]); |
| 20 | return |
| 21 | } |
| 22 | for _ in 0..permutation.len() { |
| 23 | let base = permutation.remove(0); |
| 24 | for i in 0..base.len() + 1 { |
| 25 | let mut new_elem = base.clone(); |
| 26 | new_elem.insert(i, elem); |
| 27 | permutation.push(new_elem); |
| 28 | } |
| 29 | } |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | #[cfg(test)] |