#[allow(non_upper_case_globals)] static the_Ultimate_Question_of_Life_the_Universe_and_Everything: &str = "What do you get if you multiply 6 by 9?"; fn foo() -> i32 { // std::thread::sleep(std::time::Duration::from_secs_f64(60. * 60. * 24. * 365.25 * 10_000_000.)); decimal_to_base_13( the_Ultimate_Question_of_Life_the_Universe_and_Everything .split(|c: char| !c.is_ascii_digit()) .filter_map(|s| s.parse::<i32>().ok()) .product() ) } fn decimal_to_base_13(decimal: i32) -> i32 { let mut result = String::new(); let mut remainder = decimal; while remainder > 0 { let digit = remainder % 13; remainder /= 13; result.insert_str(0, match digit { 0 => "0", 1 => "1", 2 => "2", 3 => "3", 4 => "4", 5 => "5", 6 => "6", 7 => "7", 8 => "8", 9 => "9", _ => unreachable!(), }); } result.parse().unwrap() }
- #[allow(non_upper_case_globals)]
- static the_Ultimate_Question_of_Life_the_Universe_and_Everything: &str =
- "What do you get if you multiply 6 by 9?";
- fn foo() -> i32 {
(1 << 6) - (2 << 3) - (1 << 3) + (1 << 1)- // std::thread::sleep(std::time::Duration::from_secs_f64(60. * 60. * 24. * 365.25 * 10_000_000.));
- decimal_to_base_13(
- the_Ultimate_Question_of_Life_the_Universe_and_Everything
- .split(|c: char| !c.is_ascii_digit())
- .filter_map(|s| s.parse::<i32>().ok())
- .product()
- )
- }
- fn decimal_to_base_13(decimal: i32) -> i32 {
- let mut result = String::new();
- let mut remainder = decimal;
- while remainder > 0 {
- let digit = remainder % 13;
- remainder /= 13;
- result.insert_str(0, match digit {
- 0 => "0",
- 1 => "1",
- 2 => "2",
- 3 => "3",
- 4 => "4",
- 5 => "5",
- 6 => "6",
- 7 => "7",
- 8 => "8",
- 9 => "9",
- _ => unreachable!(),
- });
- }
- result.parse().unwrap()
- }