## ~janbaudisch/euler-rs

7a765466fd40b8481f46d4242ad42325e85bbc9b — Jan Baudisch 5 years ago
```problem 4 use palindrome check from common
```
```1 files changed, 3 insertions(+), 15 deletions(-)

M problem_004/src/main.rs
```
`M problem_004/src/main.rs => problem_004/src/main.rs +3 -15`
```@@ 1,17 1,4 @@
-fn check_palindrome(input: u32) -> bool {
-    let digits = input.to_string().chars().collect::<Vec<char>>();
-
-    let (left, right) = if &digits.len() % 2 == 0 {
-        digits.split_at(digits.len() / 2)
-    } else {
-        digits.split_at((digits.len() - 1) / 2)
-    };
-
-    let mut right = right.to_vec();
-    right.reverse();
-
-    left == right.as_slice()
-}
+use common::math::IsPalindrome;

fn main() {
let mut largest: u32 = 0;

@@ 19,7 6,8 @@ fn main() {
for x in 100..1000 {
for y in 100..1000 {
let current = x * y;
-            if check_palindrome(current) && current > largest {
+
+            if current.is_palindrome() && current > largest {
largest = current;
}
}

```