Skip to content

Instantly share code, notes, and snippets.

@icub3d
Created January 12, 2026 19:58
Show Gist options
  • Select an option

  • Save icub3d/a83370bd58f009ff8fb2d25235074e06 to your computer and use it in GitHub Desktop.

Select an option

Save icub3d/a83370bd58f009ff8fb2d25235074e06 to your computer and use it in GitHub Desktop.
Kattis sevenwonders
use std::io::{Read, stdin};
fn main() {
let mut s = String::new();
stdin().read_to_string(&mut s).unwrap();
let mut counts = [0; 3];
for c in s.trim().chars() {
match c {
'T' => counts[0] += 1,
'C' => counts[1] += 1,
_ => counts[2] += 1,
}
}
let mut total = counts.iter().map(|&x| x * x).sum::<usize>();
total += counts.iter().min().unwrap() * 7;
println!("{total}");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment