Add a test from problem 1
This commit is contained in:
parent
8004d6ee68
commit
4fb3360022
1 changed files with 15 additions and 5 deletions
20
src/one.rs
20
src/one.rs
|
|
@ -7,11 +7,21 @@ pub struct Args {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Problem for Args {
|
impl Problem for Args {
|
||||||
// We could derive it mathematically, ... or write a dump loop
|
type Solution = u64;
|
||||||
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);
|
|
||||||
|
|
||||||
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
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue