Skip to content

Commit

Permalink
Fix iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
europeanplaice committed Mar 17, 2022
1 parent 8cfe8d9 commit 3e432bf
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "subset_sum"
version = "0.16.1"
version = "0.16.2"
edition = "2018"
authors = ["Tomohiro Endo <[email protected]>"]
description = "Solves subset sum problem and returns a set of decomposed integers. It also can match corresponding numbers from two vectors and be used for Account reconciliation."
Expand Down
8 changes: 1 addition & 7 deletions src/dp_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,6 @@ pub mod dp {
n_candidates: usize,
) {
use itertools::Itertools;
use std::cmp::min;

if answer.len() >= n_candidates {
return;
Expand All @@ -423,15 +422,10 @@ pub mod dp {
return;
}

let mut key_candidates: Vec<Vec<usize>> = vec![vec![]];
for i in 1..min(max_key_length, keys.len())+1{
key_candidates.append(&mut (0..keys.len()).combinations(i).collect::<Vec<_>>())
}

let goldkey = keys.clone();
let goldtargets = targets.clone();
let goldgroup = group.clone();
key_candidates.iter().for_each(|i| {
(0..keys.len()).powerset().filter(|x| x.len() <= max_key_length).for_each(|i| {
*keys = goldkey.clone();
*targets = goldtargets.clone();
*group = goldgroup.clone();
Expand Down

0 comments on commit 3e432bf

Please sign in to comment.