Algorithms
Easy
2769
2812
Find the Maximum Achievable Number
find-the-maximum-achievable-number
"""
You are given two integers, num and t.

An integer x is called achievable if it can become equal to num after applying the following operation no more than t times:

 * Increase or decrease x by 1, and simultaneously increase or decrease num by 1.

Return the maximum possible achievable number. It can be proven that there exists at least one achievable number.

Example 1:

Input: num = 4, t = 1
Output: 6
Explanation: The maximum achievable number is x = 6; it can become equal to num after performing this operation:
1- Decrease x by 1, and increase num by 1. Now, x = 5 and num = 5.
It can be proven that there is no achievable number larger than 6.

Example 2:

Input: num = 3, t = 2
Output: 7
Explanation: The maximum achievable number is x = 7; after performing these operations, x will equal num:
1- Decrease x by 1, and increase num by 1. Now, x = 6 and num = 4.
2- Decrease x by 1, and increase num by 1. Now, x = 5 and num = 5.
It can be proven that there is no achievable number larger than 7.


Constraints:

 * 1 <= num, t <= 50
"""
class Solution:
    def theMaximumAchievableX(self, num: int, t: int) -> int:
        
You are given two integers, num and t.

An integer x is called achievable if it can become equal to num after applying the following operation no more than t times:

 * Increase or decrease x by 1, and simultaneously increase or decrease num by 1.

Return the maximum possible achievable number. It can be proven that there exists at least one achievable number.

Example 1:

Input: num = 4, t = 1
Output: 6
Explanation: The maximum achievable number is x = 6; it can become equal to num after performing this operation:
1- Decrease x by 1, and increase num by 1. Now, x = 5 and num = 5.
It can be proven that there is no achievable number larger than 6.

Example 2:

Input: num = 3, t = 2
Output: 7
Explanation: The maximum achievable number is x = 7; after performing these operations, x will equal num:
1- Decrease x by 1, and increase num by 1. Now, x = 6 and num = 4.
2- Decrease x by 1, and increase num by 1. Now, x = 5 and num = 5.
It can be proven that there is no achievable number larger than 7.


Constraints:

 * 1 <= num, t <= 50


Please complete the code below to solve above prblem:
```python
class Solution:
    def theMaximumAchievableX(self, num: int, t: int) -> int:
        
```

my_solution = Solution()

test_input = { "num": 4, "t": 1 }
assert my_solution.theMaximumAchievableX(**test_input) == 6

test_input = { "num": 3, "t": 2 }
assert my_solution.theMaximumAchievableX(**test_input) == 7

test_input = { "num": 1, "t": 1 }
assert my_solution.theMaximumAchievableX(**test_input) == 3

test_input = { "num": 1, "t": 2 }
assert my_solution.theMaximumAchievableX(**test_input) == 5

test_input = { "num": 1, "t": 3 }
assert my_solution.theMaximumAchievableX(**test_input) == 7

test_input = { "num": 1, "t": 4 }
assert my_solution.theMaximumAchievableX(**test_input) == 9

test_input = { "num": 1, "t": 5 }
assert my_solution.theMaximumAchievableX(**test_input) == 11

test_input = { "num": 1, "t": 6 }
assert my_solution.theMaximumAchievableX(**test_input) == 13

test_input = { "num": 1, "t": 7 }
assert my_solution.theMaximumAchievableX(**test_input) == 15

test_input = { "num": 1, "t": 8 }
assert my_solution.theMaximumAchievableX(**test_input) == 17

test_input = { "num": 1, "t": 9 }
assert my_solution.theMaximumAchievableX(**test_input) == 19

test_input = { "num": 1, "t": 10 }
assert my_solution.theMaximumAchievableX(**test_input) == 21

test_input = { "num": 1, "t": 11 }
assert my_solution.theMaximumAchievableX(**test_input) == 23

test_input = { "num": 1, "t": 12 }
assert my_solution.theMaximumAchievableX(**test_input) == 25

test_input = { "num": 1, "t": 13 }
assert my_solution.theMaximumAchievableX(**test_input) == 27

test_input = { "num": 1, "t": 14 }
assert my_solution.theMaximumAchievableX(**test_input) == 29

test_input = { "num": 1, "t": 15 }
assert my_solution.theMaximumAchievableX(**test_input) == 31

test_input = { "num": 1, "t": 16 }
assert my_solution.theMaximumAchievableX(**test_input) == 33

test_input = { "num": 1, "t": 17 }
assert my_solution.theMaximumAchievableX(**test_input) == 35

test_input = { "num": 1, "t": 18 }
assert my_solution.theMaximumAchievableX(**test_input) == 37

test_input = { "num": 1, "t": 19 }
assert my_solution.theMaximumAchievableX(**test_input) == 39

test_input = { "num": 1, "t": 20 }
assert my_solution.theMaximumAchievableX(**test_input) == 41

test_input = { "num": 1, "t": 21 }
assert my_solution.theMaximumAchievableX(**test_input) == 43

test_input = { "num": 1, "t": 22 }
assert my_solution.theMaximumAchievableX(**test_input) == 45

test_input = { "num": 1, "t": 23 }
assert my_solution.theMaximumAchievableX(**test_input) == 47

test_input = { "num": 1, "t": 24 }
assert my_solution.theMaximumAchievableX(**test_input) == 49

test_input = { "num": 1, "t": 25 }
assert my_solution.theMaximumAchievableX(**test_input) == 51

test_input = { "num": 1, "t": 26 }
assert my_solution.theMaximumAchievableX(**test_input) == 53

test_input = { "num": 1, "t": 27 }
assert my_solution.theMaximumAchievableX(**test_input) == 55

test_input = { "num": 1, "t": 28 }
assert my_solution.theMaximumAchievableX(**test_input) == 57

test_input = { "num": 1, "t": 29 }
assert my_solution.theMaximumAchievableX(**test_input) == 59

test_input = { "num": 1, "t": 30 }
assert my_solution.theMaximumAchievableX(**test_input) == 61

test_input = { "num": 1, "t": 31 }
assert my_solution.theMaximumAchievableX(**test_input) == 63

test_input = { "num": 1, "t": 32 }
assert my_solution.theMaximumAchievableX(**test_input) == 65

test_input = { "num": 1, "t": 33 }
assert my_solution.theMaximumAchievableX(**test_input) == 67

test_input = { "num": 1, "t": 34 }
assert my_solution.theMaximumAchievableX(**test_input) == 69

test_input = { "num": 1, "t": 35 }
assert my_solution.theMaximumAchievableX(**test_input) == 71

test_input = { "num": 1, "t": 36 }
assert my_solution.theMaximumAchievableX(**test_input) == 73

test_input = { "num": 1, "t": 37 }
assert my_solution.theMaximumAchievableX(**test_input) == 75

test_input = { "num": 1, "t": 38 }
assert my_solution.theMaximumAchievableX(**test_input) == 77

test_input = { "num": 1, "t": 39 }
assert my_solution.theMaximumAchievableX(**test_input) == 79

test_input = { "num": 1, "t": 40 }
assert my_solution.theMaximumAchievableX(**test_input) == 81

test_input = { "num": 1, "t": 41 }
assert my_solution.theMaximumAchievableX(**test_input) == 83

test_input = { "num": 1, "t": 42 }
assert my_solution.theMaximumAchievableX(**test_input) == 85

test_input = { "num": 1, "t": 43 }
assert my_solution.theMaximumAchievableX(**test_input) == 87

test_input = { "num": 1, "t": 44 }
assert my_solution.theMaximumAchievableX(**test_input) == 89

test_input = { "num": 1, "t": 45 }
assert my_solution.theMaximumAchievableX(**test_input) == 91

test_input = { "num": 1, "t": 46 }
assert my_solution.theMaximumAchievableX(**test_input) == 93

test_input = { "num": 1, "t": 47 }
assert my_solution.theMaximumAchievableX(**test_input) == 95

test_input = { "num": 1, "t": 48 }
assert my_solution.theMaximumAchievableX(**test_input) == 97

test_input = { "num": 1, "t": 49 }
assert my_solution.theMaximumAchievableX(**test_input) == 99

test_input = { "num": 1, "t": 50 }
assert my_solution.theMaximumAchievableX(**test_input) == 101

test_input = { "num": 2, "t": 1 }
assert my_solution.theMaximumAchievableX(**test_input) == 4

test_input = { "num": 2, "t": 2 }
assert my_solution.theMaximumAchievableX(**test_input) == 6

test_input = { "num": 2, "t": 3 }
assert my_solution.theMaximumAchievableX(**test_input) == 8

test_input = { "num": 2, "t": 4 }
assert my_solution.theMaximumAchievableX(**test_input) == 10

test_input = { "num": 2, "t": 5 }
assert my_solution.theMaximumAchievableX(**test_input) == 12

test_input = { "num": 2, "t": 6 }
assert my_solution.theMaximumAchievableX(**test_input) == 14

test_input = { "num": 2, "t": 7 }
assert my_solution.theMaximumAchievableX(**test_input) == 16

test_input = { "num": 2, "t": 8 }
assert my_solution.theMaximumAchievableX(**test_input) == 18

test_input = { "num": 2, "t": 9 }
assert my_solution.theMaximumAchievableX(**test_input) == 20

test_input = { "num": 2, "t": 10 }
assert my_solution.theMaximumAchievableX(**test_input) == 22

test_input = { "num": 2, "t": 11 }
assert my_solution.theMaximumAchievableX(**test_input) == 24

test_input = { "num": 2, "t": 12 }
assert my_solution.theMaximumAchievableX(**test_input) == 26

test_input = { "num": 2, "t": 13 }
assert my_solution.theMaximumAchievableX(**test_input) == 28

test_input = { "num": 2, "t": 14 }
assert my_solution.theMaximumAchievableX(**test_input) == 30

test_input = { "num": 2, "t": 15 }
assert my_solution.theMaximumAchievableX(**test_input) == 32

test_input = { "num": 2, "t": 16 }
assert my_solution.theMaximumAchievableX(**test_input) == 34

test_input = { "num": 2, "t": 17 }
assert my_solution.theMaximumAchievableX(**test_input) == 36

test_input = { "num": 2, "t": 18 }
assert my_solution.theMaximumAchievableX(**test_input) == 38

test_input = { "num": 2, "t": 19 }
assert my_solution.theMaximumAchievableX(**test_input) == 40

test_input = { "num": 2, "t": 20 }
assert my_solution.theMaximumAchievableX(**test_input) == 42

test_input = { "num": 2, "t": 21 }
assert my_solution.theMaximumAchievableX(**test_input) == 44

test_input = { "num": 2, "t": 22 }
assert my_solution.theMaximumAchievableX(**test_input) == 46

test_input = { "num": 2, "t": 23 }
assert my_solution.theMaximumAchievableX(**test_input) == 48

test_input = { "num": 2, "t": 24 }
assert my_solution.theMaximumAchievableX(**test_input) == 50

test_input = { "num": 2, "t": 25 }
assert my_solution.theMaximumAchievableX(**test_input) == 52

test_input = { "num": 2, "t": 26 }
assert my_solution.theMaximumAchievableX(**test_input) == 54

test_input = { "num": 2, "t": 27 }
assert my_solution.theMaximumAchievableX(**test_input) == 56

test_input = { "num": 2, "t": 28 }
assert my_solution.theMaximumAchievableX(**test_input) == 58

test_input = { "num": 2, "t": 29 }
assert my_solution.theMaximumAchievableX(**test_input) == 60

test_input = { "num": 2, "t": 30 }
assert my_solution.theMaximumAchievableX(**test_input) == 62

test_input = { "num": 2, "t": 31 }
assert my_solution.theMaximumAchievableX(**test_input) == 64

test_input = { "num": 2, "t": 32 }
assert my_solution.theMaximumAchievableX(**test_input) == 66

test_input = { "num": 2, "t": 33 }
assert my_solution.theMaximumAchievableX(**test_input) == 68

test_input = { "num": 2, "t": 34 }
assert my_solution.theMaximumAchievableX(**test_input) == 70

test_input = { "num": 2, "t": 35 }
assert my_solution.theMaximumAchievableX(**test_input) == 72

test_input = { "num": 2, "t": 36 }
assert my_solution.theMaximumAchievableX(**test_input) == 74

test_input = { "num": 2, "t": 37 }
assert my_solution.theMaximumAchievableX(**test_input) == 76

test_input = { "num": 2, "t": 38 }
assert my_solution.theMaximumAchievableX(**test_input) == 78

test_input = { "num": 2, "t": 39 }
assert my_solution.theMaximumAchievableX(**test_input) == 80

test_input = { "num": 2, "t": 40 }
assert my_solution.theMaximumAchievableX(**test_input) == 82

test_input = { "num": 2, "t": 41 }
assert my_solution.theMaximumAchievableX(**test_input) == 84

test_input = { "num": 2, "t": 42 }
assert my_solution.theMaximumAchievableX(**test_input) == 86

test_input = { "num": 2, "t": 43 }
assert my_solution.theMaximumAchievableX(**test_input) == 88

test_input = { "num": 2, "t": 44 }
assert my_solution.theMaximumAchievableX(**test_input) == 90

test_input = { "num": 2, "t": 45 }
assert my_solution.theMaximumAchievableX(**test_input) == 92

test_input = { "num": 2, "t": 46 }
assert my_solution.theMaximumAchievableX(**test_input) == 94

test_input = { "num": 2, "t": 47 }
assert my_solution.theMaximumAchievableX(**test_input) == 96

test_input = { "num": 2, "t": 48 }
assert my_solution.theMaximumAchievableX(**test_input) == 98