[2017][rust] fmt code

sorbet
Alpha Chen 7 years ago
parent d1924f5742
commit 4d7d0fc602

@ -8,8 +8,8 @@ pub fn solve(input: &str) -> Result<String, Error> {
.trim()
.lines()
.enumerate()
.map(|(i,x)| x.parse().map(|x| (i as isize, x)))
.collect::<Result<_,_>>()?;
.map(|(i, x)| x.parse().map(|x| (i as isize, x)))
.collect::<Result<_, _>>()?;
let mut pc = 0;
let mut steps = 0;
while let Entry::Occupied(mut entry) = jumps.entry(pc) {

@ -1,12 +1,19 @@
use failure::*;
pub fn solve(_: &str) -> Result<String, Error> {
let a = Generator{value: 679, factor: 16807};
let b = Generator{value: 771, factor: 48271};
let a = Generator {
value: 679,
factor: 16807,
};
let b = Generator {
value: 771,
factor: 48271,
};
let answer = a.filter(|a| a % 4 == 0).zip(b.filter(|b| b % 8 == 0))
let answer = a.filter(|a| a % 4 == 0)
.zip(b.filter(|b| b % 8 == 0))
.take(5_000_000)
.filter(|&(a,b)| a & 0b1111111111111111 == b & 0b1111111111111111)
.filter(|&(a, b)| a & 0b1111111111111111 == b & 0b1111111111111111)
.count();
Ok(answer.to_string())
}
@ -25,4 +32,3 @@ impl Iterator for Generator {
Some(self.value)
}
}

Loading…
Cancel
Save