Created
February 23, 2022 07:55
-
-
Save abiriadev/bc409f5c3cf2c787a7358b0952194d44 to your computer and use it in GitHub Desktop.
graceful and functional solution of the BOJ problem number 2355
This file contains 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::{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