Skip to content

Instantly share code, notes, and snippets.

@samueltardieu
Last active February 23, 2023 11:54
Show Gist options
  • Save samueltardieu/a0fde5b0a5125fafbf7829c64cb2ae48 to your computer and use it in GitHub Desktop.
Save samueltardieu/a0fde5b0a5125fafbf7829c64cb2ae48 to your computer and use it in GitHub Desktop.
let mut freq = count_chars(&lines);
freq.sort_unstable_by_key(|&(_, n)| n);
println!("Most frequent characters:");
for (c, n) in freq.into_iter().rev().take(10) {
println!(" - '{c}': {n} occurrences");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment