Rust:
fn next_happy_year(year: u32) -> u32 { let mut year = year + 1; while !happy(year) { year += 1; } year } fn happy(year: u32) -> bool { let mut chars = year.to_string().chars().collect::<Vec<_>>(); chars.sort(); let len = chars.len(); chars.dedup(); chars.len() == len }
This was a strange exercise to do in Rust. Feels dirty to use conversion to string :(
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Rust:
This was a strange exercise to do in Rust. Feels dirty to use conversion to string :(