Created
May 14, 2020 21:42
-
-
Save Rotwang/62a6740280bc844b19e583ee9abdbcac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let x = 1930; | |
let len = (x as f64).log10().floor() as u32 + 1; | |
let mut digits = (0..len) | |
.map(|i| (x / 10u64.pow(i)) % 10) | |
.collect::<Vec<u64>>(); | |
digits.sort_unstable(); | |
let mut answer: u64 = 0; | |
for (i, v) in digits.iter().enumerate() { | |
answer += v * 10u64.pow(i as u32); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment