aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/partition.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/partition.rs b/src/partition.rs
index 46efeac..3f2837d 100644
--- a/src/partition.rs
+++ b/src/partition.rs
@@ -41,7 +41,7 @@ mod tests {
list![9]
];
- assert_eq!(partition(&|_n| 1, &ins), outs);
+ assert_eq!(partition(&|_n| 1, ins[0], &ins), outs);
}
#[test]
@@ -49,7 +49,7 @@ mod tests {
let ins = vec![1, 2, 3, 4, 5, 6, 7, 8, 9];
let outs = list![list![1, 2], list![3, 4], list![5, 6], list![7, 8], list![9]];
- assert_eq!(partition(&|_n| 2, &ins), outs);
+ assert_eq!(partition(&|_n| 2, ins[0], &ins), outs);
}
#[test]
@@ -73,7 +73,7 @@ mod tests {
list![15]
];
- assert_eq!(partition(&|_n| 1, &ins), outs);
+ assert_eq!(partition(&|_n| 1, ins[0], &ins), outs);
}
#[test]
@@ -90,7 +90,7 @@ mod tests {
list![15]
];
- assert_eq!(partition(&|_n| 2, &ins), outs);
+ assert_eq!(partition(&|_n| 2, ins[0], &ins), outs);
}
fn exp2(n: u32) -> i64 {
@@ -108,7 +108,7 @@ mod tests {
list![8, 9, 10, 11, 12, 13]
];
- assert_eq!(partition(&exp2, &ins), outs);
+ assert_eq!(partition(&exp2, ins[0], &ins), outs);
}
#[test]
@@ -132,11 +132,11 @@ mod tests {
}
}
-pub fn partition(f: &dyn Fn(u32) -> i64, v: &[i64]) -> LinkedList<LinkedList<i64>> {
+pub fn partition(f: &dyn Fn(u32) -> i64, v0: i64, v: &[i64]) -> LinkedList<LinkedList<i64>> {
let mut term: LinkedList<i64> = LinkedList::new();
let mut res: LinkedList<LinkedList<i64>> = LinkedList::new();
let mut n: u32 = 1;
- let mut a: i64 = v[0];
+ let mut a: i64 = v0;
for &i in v.iter() {
while i >= a + f(n) {
@@ -168,7 +168,7 @@ pub fn partition_days(
v.sort_unstable();
v.dedup();
- part = partition(f, &v);
+ part = partition(f, v[0], &v);
}
part.into_iter()