Skip to content

Commit f52c1b2

Browse files
committed
Confused pappu
1 parent 5600275 commit f52c1b2

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
"""
2+
Problem Link: https://practice.geeksforgeeks.org/problems/confused-pappu/0
3+
4+
Pappu is confused between 6 & 9 . He works in billing department of abc company and
5+
his work is to return the remaining amount to the customers. If actual remaining amount is
6+
given we need to find the maximum possible extra amount given by the pappu to the customers.
7+
For ex:- actual remaining amount = 56
8+
so, maximum possible extra amount = (59 - 56 ) = 3
9+
10+
Input
11+
The first line of the input contains a single integer T denoting the number of test cases.
12+
The first line of each test case contains N (actual remaining amount).
13+
14+
Output
15+
For each test case, output the maximum possible extra amount in newline.
16+
17+
Example
18+
19+
Input:
20+
3
21+
6
22+
66
23+
666
24+
25+
Output:
26+
3
27+
33
28+
333
29+
"""
30+
def get_real_no(n):
31+
new_no = list(n)
32+
for i in range(len(new_no)):
33+
if new_no[i] == '6':
34+
new_no[i] = '9'
35+
return int(''.join(new_no))
36+
37+
for _ in range(int(input())):
38+
n = input()
39+
new_no = get_real_no(n)
40+
print(new_no-int(n))

0 commit comments

Comments
 (0)