refactoring
This commit is contained in:
parent
1d9c848525
commit
7d0ed36699
@ -71,11 +71,11 @@ fn permutation(mut people: Vec<String>, nth: usize) -> Result<Vec<String>, Box<d
|
||||
return Err(Box::from("Out of bounds"));
|
||||
}
|
||||
let mut perm = Vec::new();
|
||||
let num_unique_locations = people.len();
|
||||
let num_unique_people = people.len();
|
||||
let mut remainder = nth - 1;
|
||||
for idx in 1..=people.len() {
|
||||
let permutations = remainder / factorial(num_unique_locations - idx);
|
||||
remainder %= factorial(num_unique_locations - idx);
|
||||
let permutations = remainder / factorial(num_unique_people - idx);
|
||||
remainder %= factorial(num_unique_people - idx);
|
||||
perm.push(people[permutations].clone());
|
||||
people.remove(permutations);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user