Insurance Solution Codechef
Chef bought car insurance. The policy of the insurance is:
- The maximum rebatable amount for any damage is Rs X lakhs.
- If the amount required for repairing the damage is ≤X lakhs, that amount is rebated in full.
Chef’s car meets an accident and required Rs Y lakhs for repairing. Determine the amount that will be rebated by the insurance company.
- The first line of input will contain a single integer T, denoting the number of test cases.
- The first and only line of each test case contains two space-separated integers X and Y.
For each test case, output the amount (in lakhs) that will be rebated by the insurance company.
Sample Input 1
4 5 3 5 8 4 4 15 12
Sample Output 1
3 5 4 12
- Test case 1: The damages require only Rs 3 lakh which is below the upper cap, so the entire Rs 3 lakh will be rebated.
- Test case 2: The damages require Rs 8 lakh which is above the upper cap, so only Rs 5 lakh will be rebated.
- Test case 3: The damages require only Rs 4 lakh which is equal to the upper cap, so the whole Rs 4 lakh will be rebated.
- Test case 4: The damages require Rs 15 lakh which is above the upper cap, so only Rs 12 lakh will be rebated.
Program: Insurance Solution in Python
for _ in range(int(input())): x,y=map(int,input().split()) if (y<=x ): print(y) else: print(x)