Compare commits

..

No commits in common. "9fab2616c5a31b711491cb8aa68570763e8301f4" and "7a65f1431cff7d7b7c329e647e03458c7f610fde" have entirely different histories.

2 changed files with 1 additions and 43 deletions

View File

@ -16,7 +16,7 @@ pub mod d15;
pub mod d16;
pub mod d17;
pub mod d18;
pub mod d19;
// pub mod d19;
// pub mod d20;
// pub mod d21;
// pub mod d22;

View File

@ -1,42 +0,0 @@
use crate::prelude::*;
pub type I = u32;
pub type O = u32;
fn _silver (data: I) -> O {
2 * (data - (1 << (32 - data.leading_zeros() - 1))) + 1
}
fn _gold (data: I) -> O {
let mut left = D::from_iter(0..data/2);
let mut right = D::from_iter(data/2..data);
while !left.is_empty() && !right.is_empty() {
if left.len() > right.len() {
left.pop_back();
} else {
right.pop_back();
}
right.push_front(left.pop_front().unwrap());
left.push_back(right.pop_back().unwrap());
}
left[0] + 1
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn silver () {
let ans = _silver(3005290);
assert_eq!(ans, 1816277)
}
#[test]
fn gold () {
let ans = _gold(3005290);
assert_eq!(ans, 1410967)
}
}