The input should be a series of pairs of integers with one pair of integers per line. Each pair forms a range that is used to make several calculations and outputs a single integer, along with the two initial integers. The two integers in the input should be separated by a single space. The following code only takes a single line of input.
What changes should I make to have it take multiple lines of input and print out multiple lines of output? The code is written in python3
i,j = input().split(" ")
max_count = 0
n = int(i)
if int(i) >= int(j):
for n in range(int(j), int(i)):
count = 2
while n > 1:
if count > max_count:
max_count = count
if n == 1:
count = 1
elif n % 2 != 0:
n = (3 * n) + 1
count += 1
if n % 2 == 0:
n = n / 2
count += 1
if j > i:
for n in range(int(i), int(j)):
count = 2
while n > 1:
if count > max_count:
max_count = count
if n == 1:
count = 1
elif n % 2 != 0:
n = (3 * n) + 1
count += 1
if n % 2 == 0:
n = n / 2
count += 1
print(i, j, max_count)
Here is a link to the problem I’m attempting to solve: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=29&page=show_problem&problem=36