Skip to content

Commit dff5114

Browse files
committed
Add problem 2769: Find the Maximum Achievable Number
1 parent 49a920d commit dff5114

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1962,6 +1962,7 @@ pub mod problem_2760_longest_even_odd_subarray_with_threshold;
19621962
pub mod problem_2761_prime_pairs_with_target_sum;
19631963
pub mod problem_2765_longest_alternating_subarray;
19641964
pub mod problem_2766_relocate_marbles;
1965+
pub mod problem_2769_find_the_maximum_achievable_number;
19651966

19661967
#[cfg(test)]
19671968
mod test_utilities;
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
pub struct Solution;
2+
3+
// ------------------------------------------------------ snip ------------------------------------------------------ //
4+
5+
impl Solution {
6+
pub fn the_maximum_achievable_x(num: i32, t: i32) -> i32 {
7+
num + 2 * t
8+
}
9+
}
10+
11+
// ------------------------------------------------------ snip ------------------------------------------------------ //
12+
13+
impl super::Solution for Solution {
14+
fn the_maximum_achievable_x(num: i32, t: i32) -> i32 {
15+
Self::the_maximum_achievable_x(num, t)
16+
}
17+
}
18+
19+
#[cfg(test)]
20+
mod tests {
21+
#[test]
22+
fn test_solution() {
23+
super::super::tests::run::<super::Solution>();
24+
}
25+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
pub mod mathematical;
2+
3+
pub trait Solution {
4+
fn the_maximum_achievable_x(num: i32, t: i32) -> i32;
5+
}
6+
7+
#[cfg(test)]
8+
mod tests {
9+
use super::Solution;
10+
11+
pub fn run<S: Solution>() {
12+
let test_cases = [((4, 1), 6), ((3, 2), 7)];
13+
14+
for ((num, t), expected) in test_cases {
15+
assert_eq!(S::the_maximum_achievable_x(num, t), expected);
16+
}
17+
}
18+
}

0 commit comments

Comments
 (0)