Skip to content

Instantly share code, notes, and snippets.

@icub3d
Created January 29, 2026 20:09
Show Gist options
  • Select an option

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

Select an option

Save icub3d/1e0f8fd0b24180d9a1c4c1a015d97b47 to your computer and use it in GitHub Desktop.
Kattis battlesimulation
use std::io::{Read, stdin};
fn main() {
let mut s = String::new();
stdin().read_to_string(&mut s).unwrap();
let s = s.trim().as_bytes();
let mut i = 0;
while i < s.len() {
if i + 2 < s.len() && (s[i] != s[i + 1] && s[i + 1] != s[i + 2] && s[i] != s[i + 2]) {
print!("C");
i += 3;
} else {
print!(
"{}",
match s[i] {
b'R' => 'S',
b'B' => 'K',
_ => 'H',
}
);
i += 1;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment