fn flip_the_number(mut x: u64) -> u64 { let mut y = 0; while x != 0 { y = y * 10 + x % 10; x /= 10; } y }
fn flip_the_number(x: &u64) -> u64 {let mut x = *x;- fn flip_the_number(mut x: u64) -> u64 {
- let mut y = 0;
- while x != 0 {
- y = y * 10 + x % 10;
- x /= 10;
- }
- y
- }
#[test] fn test() { let nums = [ (1234, 4321), (1234567890, 987654321), (243, 342), (12, 21), (837583, 385738), (32851532, 23515823), (999999, 999999), (111, 111), (35832456789, 98765423853), (9223372036854775807, 7085774586302733229) ]; for num in nums.iter() { assert_eq!(num.1, flip_the_number(num.0)); } }
- #[test]
- fn test() {
- let nums = [
- (1234, 4321),
- (1234567890, 987654321),
- (243, 342),
- (12, 21),
- (837583, 385738),
- (32851532, 23515823),
- (999999, 999999),
- (111, 111),
- (35832456789, 98765423853),
- (9223372036854775807, 7085774586302733229)
- ];
- for num in nums.iter() {
assert_eq!(num.1, flip_the_number(&num.0));- assert_eq!(num.1, flip_the_number(num.0));
- }
- }