diff --git a/docs/index.rst b/docs/index.rst index 417c579c..15b58dc4 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -142,7 +142,7 @@ Problems Solved +-----------+------------+------------+------------+------------+------------+------------+------------+ |:prob:`34` |:c-d:`0034` |:cp-d:`0034`|:cs-d:`0034`|:ja-d:`0034`|:js-d:`0034`|:py-d:`0034`|:rs-d:`0034`| +-----------+------------+------------+------------+------------+------------+------------+------------+ -|:prob:`35` | | | | |:js-d:`0035`|:py-d:`0035`|:rs-d:`0035`| +|:prob:`35` | | | | |:js-d:`0035`|:py-d:`0035`|:rs-s:`0035`| +-----------+------------+------------+------------+------------+------------+------------+------------+ |:prob:`36` | | | | | |:py-d:`0036`|:rs-d:`0036`| +-----------+------------+------------+------------+------------+------------+------------+------------+ diff --git a/rust/src/include/problems.rs b/rust/src/include/problems.rs index e228c24d..c05409e8 100644 --- a/rust/src/include/problems.rs +++ b/rust/src/include/problems.rs @@ -37,7 +37,7 @@ seq!(N in 0001..=0020 { 24 => Some(( &24, p0024, false)), 27 => Some(( &27, p0027, true)), 34 => Some(( &34, p0034, false)), - 35 => Some(( &35, p0035, false)), + 35 => Some(( &35, p0035, true)), 36 => Some(( &36, p0036, false)), 37 => Some(( &37, p0037, true)), 41 => Some(( &41, p0041, false)), diff --git a/rust/src/p0035.rs b/rust/src/p0035.rs index 287a36d7..4cd0d059 100644 --- a/rust/src/p0035.rs +++ b/rust/src/p0035.rs @@ -15,7 +15,7 @@ use crate::include::primes::is_prime; use crate::include::utils::Answer; pub fn p0035() -> Answer { - let mut answer: u64 = 0; + let mut answer: u32 = 0; for x in 0..1000000 { if Rotations::new(x).all(is_prime) { answer += 1; @@ -27,23 +27,29 @@ pub fn p0035() -> Answer { struct Rotations { x: String, i: usize, + n: u32, } impl Rotations { - pub fn new(x: u64) -> Self { + pub fn new(x: u32) -> Self { return Rotations{ x: x.to_string(), i: 0, + n: x, }; } } impl Iterator for Rotations { - type Item = u64; + type Item = u32; fn next(&mut self) -> Option { + if self.i == 0 { + self.i += 1; + return Some(self.n); + } if self.i < self.x.len() { - let result = (self.x[self.i..].to_owned() + &self.x[..self.i]).parse::().unwrap(); + let result = format!("{}{}", &self.x[self.i..], &self.x[..self.i]).parse::().unwrap(); self.i += 1; return Some(result); }