input : the first line of input contains seperated integers
Outpt : The output should be a single line containing space-seperated integers with odd-digit for each number
if input 1 is :- 21 503 256 550 86 979 281
if output 1 is :- 12 503 562 550 86 979 128
if input 2 is :- 2001 463 6219 669 473 1006 77734 110 20511
if output 2 is :- 1002 346 1962 966 734 1006 77734 110 51120
# Python3 implementation of the approach
# function to return the count of digit of n
def numberofDigits(n):
cnt = 0
while n > 0:
cnt += 1
n //= 10
return cnt
# function to print the left shift numbers
def cal(num):
digit = numberofDigits(num)
powTen = pow(10, digit - 1)
for i in range(digit - 1):
firstDigit = num // powTen
# formula to calculate left shift
# from previous number
left = (num * 10 + firstDigit -
(firstDigit * powTen * 10))
print(left, end = " ")
# Update the original number
num = left
# Driver code
num = 1445
cal(num)
Comments
Leave a comment