Skip to content

Instantly share code, notes, and snippets.

@claudioacioli
Created June 5, 2021 17:31
Show Gist options
  • Save claudioacioli/417e6061c1f6baad702812dcc1915d99 to your computer and use it in GitHub Desktop.
Save claudioacioli/417e6061c1f6baad702812dcc1915d99 to your computer and use it in GitHub Desktop.
use std::io;
fn main() {
let mut input = String::new();
io::stdin().read_line(&mut input).unwrap_or(0);
let a = input.trim().parse::<u16>().unwrap_or(0);
input.clear();
io::stdin().read_line(&mut input).unwrap_or(0);
let b = input.trim().parse::<u16>().unwrap_or(0);
if a < 1 || a > 100 || b < 1 || b > 100 {
println!("Please insert numbers with 1 and 100");
return;
}
println!("{}", solve_me_first(a, b));
}
fn solve_me_first(a:u16, b:u16) -> u16 {
a + b
}
#[test]
fn test_solve_me_first() {
assert_eq!(10, solve_me_first(5, 5));
assert_eq!(10, solve_me_first(2, 8));
assert_eq!(5, solve_me_first(1, 4));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment