Series36. An integer K and K sets of nonzero integers are given. Each set contains at least two elements, the sign of its completion is the number 0. Find the number of sets whose elements increase.

Solution in Python 3:

import random

K = random.randrange(1,7)

print("K = ",K)

count_inc = 0
for i in range(0,K):
x_prev = random.randrange(1,4)
print(x_prev,end="; ")
x = random.randrange(1,4)
print(x,end="; ")
if x > x_prev:
flag = True
else:
flag = False
while True:
x_prev = x
x = random.randrange(0,4)
print(x,end="; ")
if x == 0:
break
if not (flag and x > x_prev):
flag = False
print()
if flag:
count_inc += 1
print("Number of increasing series: ",count_inc)