Skip to content

Instantly share code, notes, and snippets.

@icub3d
Created December 14, 2025 02:26
Show Gist options
  • Select an option

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

Select an option

Save icub3d/85dcbda48e120c698c3ee119a33c7355 to your computer and use it in GitHub Desktop.
Kattis oddgnome
use std::io::{Read, stdin};
fn main() {
let mut s = String::new();
stdin().read_to_string(&mut s).unwrap();
for m in s.lines().skip(1) {
let mut vv = m
.split_whitespace()
.skip(1)
.map(|v| v.parse::<usize>().unwrap());
let mut cur = vv.next().unwrap();
let mut n = 2;
// && after let Some() new feature.
while let Some(next) = vv.next()
&& next == cur + 1
{
n += 1;
cur = next;
}
println!("{}", n);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment