diff --git a/solutions/rust/src/bin/1807A.rs b/solutions/rust/src/bin/1807A.rs index ea39f3a..c4d5437 100644 --- a/solutions/rust/src/bin/1807A.rs +++ b/solutions/rust/src/bin/1807A.rs @@ -8,7 +8,7 @@ fn main() { let mut n = String::new(); io::stdin().read_line(&mut n).unwrap(); - let array = n.trim().split_whitespace().collect::>(); + let array = n.split_whitespace().collect::>(); let mut int_array: Vec = vec![]; for i in array { diff --git a/solutions/rust/src/bin/1881A.rs b/solutions/rust/src/bin/1881A.rs index 38452aa..527cb73 100644 --- a/solutions/rust/src/bin/1881A.rs +++ b/solutions/rust/src/bin/1881A.rs @@ -12,11 +12,7 @@ fn share_char(a: &str, b: &str) -> bool { subcheck = true; } } - if subcheck == false { - check = false; - } else { - check = true; - } + check = subcheck; } check } @@ -31,7 +27,7 @@ fn main() { let mut nm = String::new(); io::stdin().read_line(&mut nm).unwrap(); - let nm_vec: Vec<&str> = nm.trim().split_whitespace().collect(); + let nm_vec: Vec<&str> = nm.split_whitespace().collect(); let mut nm_array: [u64; 2] = [0, 0]; for i in 0..=1 { @@ -39,21 +35,21 @@ fn main() { } let mut string_vec: [String; 2] = [String::new(), String::new()]; - for i in 0..=1 { + for i in &mut string_vec { let mut string = String::new(); io::stdin().read_line(&mut string).unwrap(); - string_vec[i] = string.trim().to_string(); + *i = string.trim().to_string(); } strings.push(string_vec); } - for i in 0..strings.len() { - if !share_char(&strings[i][0], &strings[i][1]) { + for i in &mut strings { + if !share_char(&i[0], &i[1]) { println!("-1"); } else { let mut counter = 0; - while !strings[i][0].contains(&strings[i][1]) { - strings[i][0] = strings[i][0].repeat(2); + while !i[0].contains(&i[1]) { + i[0] = i[0].repeat(2); counter += 1; if counter > 25 { counter = 0; diff --git a/solutions/rust/src/bin/200B.rs b/solutions/rust/src/bin/200B.rs index c45af41..8fdd704 100644 --- a/solutions/rust/src/bin/200B.rs +++ b/solutions/rust/src/bin/200B.rs @@ -9,7 +9,7 @@ fn main() { let mut p = String::new(); io::stdin().read_line(&mut p).unwrap(); - let drinks = p.trim().split_whitespace().map(|c| c.parse::().unwrap()).collect::>(); + let drinks = p.split_whitespace().map(|c| c.parse::().unwrap()).collect::>(); let conc = drinks.iter().sum::() as f64 / n as f64; diff --git a/solutions/rust/src/bin/2044B.rs b/solutions/rust/src/bin/2044B.rs index 4dd1622..70b5a12 100644 --- a/solutions/rust/src/bin/2044B.rs +++ b/solutions/rust/src/bin/2044B.rs @@ -21,13 +21,13 @@ fn main() { for j in original { match j { 'q' => { - new.push_str("p"); + new.push('p'); }, 'p' => { - new.push_str("q"); + new.push('q'); }, _ => { - new.push_str("w"); + new.push('w'); } } } diff --git a/solutions/rust/src/bin/318A.rs b/solutions/rust/src/bin/318A.rs index 13a1719..17cb2bb 100644 --- a/solutions/rust/src/bin/318A.rs +++ b/solutions/rust/src/bin/318A.rs @@ -4,11 +4,11 @@ fn main() { let mut s = String::new(); io::stdin().read_line(&mut s).unwrap(); - let input = s.trim().split_whitespace().map(|s| s.parse::().unwrap()).collect::>(); + let input = s.split_whitespace().map(|s| s.parse::().unwrap()).collect::>(); let n = input[0]; let k = input[1]; - if k > (((n as f64/ 2.).ceil() as u64)) { + if k > ((n as f64/ 2.).ceil() as u64) { if n % 2 == 0 { println!("{}", (2*(k-(n/2)))) } else { diff --git a/solutions/rust/src/bin/337A.rs b/solutions/rust/src/bin/337A.rs index 308c491..53503a2 100644 --- a/solutions/rust/src/bin/337A.rs +++ b/solutions/rust/src/bin/337A.rs @@ -4,14 +4,14 @@ fn main() { let mut s = String::new(); io::stdin().read_line(&mut s).unwrap(); - let a = s.trim().split_whitespace().map(|s| s.parse::().unwrap()).collect::>(); + let a = s.split_whitespace().map(|s| s.parse::().unwrap()).collect::>(); let n: usize = a[0] as usize; let m: usize = a[1] as usize; let mut s = String::new(); io::stdin().read_line(&mut s).unwrap(); - let mut f = s.trim().split_whitespace().map(|s| s.parse::().unwrap()).collect::>(); + let mut f = s.split_whitespace().map(|s| s.parse::().unwrap()).collect::>(); f.sort(); diff --git a/solutions/rust/src/bin/339A.rs b/solutions/rust/src/bin/339A.rs index fa82e83..755c168 100644 --- a/solutions/rust/src/bin/339A.rs +++ b/solutions/rust/src/bin/339A.rs @@ -4,7 +4,7 @@ fn main() { let mut s = String::new(); io::stdin().read_line(&mut s).unwrap(); - let mut nums = s.trim().split('+').map(|d| String::from(d)).collect::>(); + let mut nums = s.trim().split('+').map(String::from).collect::>(); nums.sort(); diff --git a/solutions/rust/src/bin/405A.rs b/solutions/rust/src/bin/405A.rs index 2ebcb9d..b11475f 100644 --- a/solutions/rust/src/bin/405A.rs +++ b/solutions/rust/src/bin/405A.rs @@ -7,7 +7,7 @@ fn main() { let mut s = String::new(); io::stdin().read_line(&mut s).unwrap(); - let mut initial = s.trim().split_whitespace().map(|s| s.parse::().unwrap()).collect::>(); + let mut initial = s.split_whitespace().map(|s| s.parse::().unwrap()).collect::>(); initial.sort(); diff --git a/solutions/rust/src/bin/451A.rs b/solutions/rust/src/bin/451A.rs index bb7521f..58853cf 100644 --- a/solutions/rust/src/bin/451A.rs +++ b/solutions/rust/src/bin/451A.rs @@ -4,7 +4,7 @@ fn main() { let mut s = String::new(); io::stdin().read_line(&mut s).unwrap(); - let a = s.trim().split_whitespace().map(|i| i.parse::().unwrap()).collect::>(); + let a = s.split_whitespace().map(|i| i.parse::().unwrap()).collect::>(); let mut n = a[0]; let mut m = a[1]; diff --git a/solutions/rust/src/bin/580A.rs b/solutions/rust/src/bin/580A.rs index 9db6c51..e165de6 100644 --- a/solutions/rust/src/bin/580A.rs +++ b/solutions/rust/src/bin/580A.rs @@ -8,7 +8,7 @@ fn main() { let mut s = String::new(); io::stdin().read_line(&mut s).unwrap(); - let a = s.trim().split_whitespace().map(|n| n.parse::().unwrap()).collect::>(); + let a = s.split_whitespace().map(|n| n.parse::().unwrap()).collect::>(); let mut maximum = 1; let mut count = 1; diff --git a/solutions/rust/src/bin/791A.rs b/solutions/rust/src/bin/791A.rs index c423d19..c369471 100644 --- a/solutions/rust/src/bin/791A.rs +++ b/solutions/rust/src/bin/791A.rs @@ -4,7 +4,7 @@ fn main() { let mut s = String::new(); io::stdin().read_line(&mut s).unwrap(); - let a = s.trim().split_whitespace().map(|s| s.parse::().unwrap()).collect::>(); + let a = s.split_whitespace().map(|s| s.parse::().unwrap()).collect::>(); let mut l = a[0]; let mut b = a[1];