Created
January 12, 2026 19:58
-
-
Save icub3d/a1908963fac8152e3883e7bd93f6f1a2 to your computer and use it in GitHub Desktop.
Kattis ptice
This file contains hidden or 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
| use std::io::{Read, stdin}; | |
| fn main() { | |
| let mut s = String::new(); | |
| stdin().read_to_string(&mut s).unwrap(); | |
| let quiz = s.lines().nth(1).unwrap(); | |
| let patterns = [("Adrian", "ABC"), ("Bruno", "BABC"), ("Goran", "CCAABB")]; | |
| let scores = patterns | |
| .iter() | |
| .map(|&(n, c)| { | |
| ( | |
| n, | |
| quiz.chars() | |
| .zip(c.chars().cycle()) | |
| .filter(|(a, g)| a == g) | |
| .count(), | |
| ) | |
| }) | |
| .collect::<Vec<_>>(); | |
| let max = scores.iter().max_by_key(|(_, s)| s).unwrap().1; | |
| println!("{max}"); | |
| scores | |
| .iter() | |
| .filter(|(_, s)| *s == max) | |
| .for_each(|(n, _)| println!("{n}")); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment