Answer the question
In order to leave comments, you need to log in
Where is the error in the Python code?
s = (input("Число: "))
n,k,nom = [],[], 0
for i in range(1,5):
n.append(s[i-1:i+4])
k.append(min(n[i-1][nom:i+4]))
nom = n[i-1].find(min(n[i-1]))
print(''.join(k))
Answer the question
In order to leave comments, you need to log in
def solve(sequence):
def select(shift=0):
for start in range(4):
selection = sequence[start:][shift:5]
value = min(selection)
shift += selection.index(value)
yield value
return ''.join(select())
print(solve('13321311')) # 1111
print(solve('12312321')) # 1121
print(solve('33211213')) # 1113
print(solve('12345678')) # 1234
print(solve('21221132')) # 1112
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question