add more code for 31 (WIP)

This commit is contained in:
Dr. Matthias Ratajczak
2022-08-17 18:02:04 +02:00
parent af703a3271
commit 90f8804085
+9 -10
View File
@@ -45,24 +45,18 @@ impl Node {
println!();
println!();
println!();
for combination in divided {
let mut new_vec;
if let Some(inner) = previous {
new_vec = inner.clone();
} else {
new_vec = self.values.clone();
};
for (j, combination) in divided.iter().enumerate() {
let mut new_vec = self.values.clone();
println!();
println!("{}", i + offset);
println!("{}", i);
println!("{new_vec:#?}");
println!("{combination:#?}");
new_vec.splice(i + offset..i + offset + 1, combination.clone());
new_vec.splice(i..i + 1, combination.clone());
println!("{new_vec:#?}");
previous = Some(new_vec.clone());
debug_assert_eq!(new_vec.iter().sum::<u8>(), VALUE);
self.nodes.push(Node::new_vec(new_vec));
offset += combination.len() - 1;
}
}
}
@@ -125,5 +119,10 @@ mod test {
tree.iter();
tree.iter();
assert_eq!(tree.nodes[0][0][0].values, vec![20, 20, 10, 50, 100]);
assert_eq!(tree.nodes[0][0][1].values, vec![20, 10, 10, 10, 50, 100]);
assert_eq!(
tree.nodes[0][0][2].values,
vec![10, 10, 10, 10, 10, 50, 100]
);
}
}