Problem: Which digit? A single positive integer i is given. Write a program to f
ID: 3882227 • Letter: P
Question
Problem: Which digit? A single positive integer i is given. Write a program to find the digit located in position i in the following infinite sequence of digits created by juxtaposing the increasing larger sequences of incremented integers 1,2,3, For example, the first 80 digits of the sequence are as follows: 11212312341234512345612345671234567812345678912345678910123456789101112345678910 The first line of the input (stdin/keyboard) contains a single integer n (1Sn 100), the number of test cases, followed by one line for each test case. The line for a test case contains the single integer i (1 S iExplanation / Answer
#!usr/bin/python
data =""
for i in range(1,13):
data1=""
for j in range(1,i):
data1 = data1 + str(j)
data = data + data1
print(data)
pos = int(input("Enter ith location :"))
if pos < len(data):
print(data[pos-1])
else:
print("")
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.