Skip to content

Commit

Permalink
Optimize p37
Browse files Browse the repository at this point in the history
  • Loading branch information
LivInTheLookingGlass committed Aug 27, 2024
1 parent 122741a commit c8e1f58
Showing 1 changed file with 16 additions and 22 deletions.
38 changes: 16 additions & 22 deletions rust/src/p0037.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,25 @@ pub fn p0037() -> Answer {
if count == 11 {
break;
}
else if p < 10 {
if p < 10 {
continue;
}
else {
let mut left = p;
let mut right = p;
while is_prime(right) {
right /= 10;
}
if right != 0 {
continue;
}
while is_prime(left) {
let mut x = 10;
while x < left {
x *= 10;
}
left %= x / 10;
}
if left != 0 {
continue;
}
answer += p;
count += 1;
let mut left = p;
let mut right = p;
while is_prime(right) {
right /= 10;
}
if right != 0 {
continue;
}
while is_prime(left) {
left %= 10u64.pow(left.ilog10());
}
if left != 0 {
continue;
}
answer += p;
count += 1;
}
return Answer::Int(answer.into());
}

0 comments on commit c8e1f58

Please sign in to comment.