lst = []
n, m = int(input('n = ')), int(input("m = "))
for i in range(n, m + 1):
n = str(i)
if n.count(str(i // 1000)) == 1 and n.count(str(i % 1000 // 100)) == 1 and n.count(str(i % 100 // 10)) == 1:
lst.append(i)
if lst:
print(len(lst))
else:
print(-1)
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
lst = []
n, m = int(input('n = ')), int(input("m = "))
for i in range(n, m + 1):
n = str(i)
if n.count(str(i // 1000)) == 1 and n.count(str(i % 1000 // 100)) == 1 and n.count(str(i % 100 // 10)) == 1:
lst.append(i)
if lst:
print(len(lst))
else:
print(-1)