Skip to content

Instantly share code, notes, and snippets.

@abiriadev
Created February 23, 2022 07:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abiriadev/bc409f5c3cf2c787a7358b0952194d44 to your computer and use it in GitHub Desktop.
Save abiriadev/bc409f5c3cf2c787a7358b0952194d44 to your computer and use it in GitHub Desktop.
graceful and functional solution of the BOJ problem number 2355
use std::io::{self, BufRead};
fn main() {
io::stdin()
.lock()
.lines()
.filter_map(Result::ok)
.take(1)
.for_each(|line| {
let mut ab = line
.split(' ')
.map(|n| n.parse::<i32>())
.map(|n| n.unwrap())
.take(2)
.collect::<Vec<i32>>();
ab.sort();
println!(
"{}",
(ab[0] ..= ab[1])
.into_iter()
.sum::<i32>(),
);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment