fn main() { println!("Hello, world!"); let tests = [ (121, true), (-121, false), (10, false), (1410110141, true) ]; for test in tests { println!("{} is {} should be {}", test.0, Solution::is_palindrome(test.0), test.1); } } struct Solution {} impl Solution { pub fn is_palindrome(x: i32) -> bool { if x < 0 {return false;} let len = (x as f32).log10() as usize; //println!("{} {}", len, (len+1)/2); for i in 0..(len+1)/2 { if (x as u32 / 10_u32.pow(i as u32)) % 10 != (x as u32 / 10_u32.pow((len - i) as u32)) % 10 { return false; } } true } pub fn get(x: i32, i: usize) -> u32 { (x as u32 / 10_u32.pow(i as u32)) % 10 } }