[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() .trim()
.lines() .lines()
.enumerate() .enumerate()
.map(|(i,x)| x.parse().map(|x| (i as isize, x))) .map(|(i, x)| x.parse().map(|x| (i as isize, x)))
.collect::<Result<_,_>>()?; .collect::<Result<_, _>>()?;
let mut pc = 0; let mut pc = 0;
let mut steps = 0; let mut steps = 0;
while let Entry::Occupied(mut entry) = jumps.entry(pc) { while let Entry::Occupied(mut entry) = jumps.entry(pc) {

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

Loading…
Cancel
Save