Add a test from problem 1

This commit is contained in:
Quentin Boyer 2024-11-27 12:25:45 +01:00
parent 8004d6ee68
commit 4fb3360022

View file

@ -7,11 +7,21 @@ pub struct Args {
}
impl Problem for Args {
// We could derive it mathematically, ... or write a dump loop
fn solve(self, _: GlobalArgs) -> color_eyre::Result<()> {
let sum: u64 = (0..self.until).filter(|x| x % 3 == 0 || x % 5 == 0).sum();
println!("Sum of 0..{}: {}", self.until, sum);
type Solution = u64;
Ok(())
// We could derive it mathematically, ... or write a dump loop
fn solve(self, _: GlobalArgs) -> color_eyre::Result<u64> {
let sum = (0..self.until).filter(|x| x % 3 == 0 || x % 5 == 0).sum();
Ok(sum)
}
}
#[cfg(test)]
#[test]
fn rsp() {
assert_eq!(
Args { until: 1000 }.solve(GlobalArgs::default()).unwrap(),
233168
);
}