Online test under Infosys Recruitment Program #Solution.

The Question Asked By Infosys Recruitment Team: 

If you have given number then find the last digit which does not remove(Remaining) when odd places digit remove one by one. the question does not exactly which is asked by Infosys but something like that I have written.


 
If you have given a Number: 9
[1,2,3,4,5,6,7,8,9] 
Remove Odd Places Digit: 
[1,2,3,4,5,6,7,8,9,2,4,6,8] 
Remove odd Places Digit: 
[1,2,3,4,5,6,7,8,9,2,4,6,8,4,8] 
Remove odd places Digit: 
[1,2,3,4,5,6,7,8,9,2,4,6,8,4,8,8] 

The Answer is : 8               Because it is remaining.

Explanation: First thing you have given a number. Find the natural number on the given Statement.
The given number is 9. Find Natural Number:[1,2,3,4,5,6,7,8]. Remove Odd Places Digit then become new list : [1,2,3,4,5,6,7,8,9,2,4,6,8] this operation can be perform N Times When we find single digit that is the Answer. See Details In the above Example.


CAUTION: The Question Is Given First Try Your Self Then Go To Answer.


 This Question is Asked by Infosys Recruitment Team:


# Infosys Asked This Question.
k=[]    #Initialize Empty List
N=9    #Given Number 
if(N==0):
    print(0)
for i in range(1,N+1):
    k.append(i)      #Append Number To List
while(len(k)!=1):    #Running Loop While Length is not equal to 1.
    k=k[1::2]        #Travel Even Places Only 
print(k[0])          #Print Last Remaining Value
#This Code Is Written By Upendra Charasiya.

     

The Solution Is Given For Only Educational Purpose: 

Comments

Popular posts from this blog

GeeksforGeeks 2 October Problem: Enemy

Computer game, This is the Problem statement given in the techgig Platform.