Nesting while loops

When dealing with loops, it’s possible to nest conditions in loops, loops in other loops, and virtually any construct we have learned so far as long as the syntax is correct. We can also mix for loops with while loops and conditions within a single program.
for number in range(100, 115, 2):
	print('Number:', number, end='::')
	while number > 0:
		print(number % 10, end='-')
		number //= 10
	print()
print('The End!')
Number: 100::0-0-1-
Number: 102::2-0-1-
Number: 104::4-0-1-
Number: 106::6-0-1-
Number: 108::8-0-1-
Number: 110::0-1-1-
Number: 112::2-1-1-
Number: 114::4-1-1-
The End!
So, the program iterates over even numbers ranging from 100 to 114 inclusive. It then generates the individual digits of those numbers and prints them one by one.

Challenge

Given n integers, you are asked to perform the following operations for each number:
  • Multiply each digit by 2
  • Print the resulting sequence of digits in reverse order
The first line of the input contains a single integer n. The next n lines contain integers for which you need to perform the operations. It’s guaranteed that the numbers in the input don’t end with a 0.
The program should print n lines containing the result of the operations for each integer in the sequence.
Input
Output
2 2345659 874312
18101210864 42681416
 

Constraints

Time limit: 2 seconds

Memory limit: 512 MB

Output limit: 1 MB

To check your solution you need to sign in
Sign in to continue