real column

""" Question: There are four numbers: 1, 2, 3, and 4. How many three-digit numbers can be formed without repeating numbers? How many?
Program analysis: The numbers that can be filled in the hundreds, tens, and ones are 1, 2, 3, and 4. Make up all the permutations and then remove the permutations that do not meet the conditions. """ 
#Two implementation methods

for i in range(1, 433):
    i = str(i)
    if len(i) == 3:
        if i[1] not in ['0', '5', '6', '7', '8', '9'] and i[2] not in ['0', '5', '6', '7', '8', '9']:
            if i[0] not in i[1] and i[0] not in i[2] and i[1] not in i[2]:
                print(i)


for a in range(1, 5):
    for b in range(1, 5):
        for c in range(1, 5):
            if a != b and a != c and b != c:
                print(a, b, c)

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325298134&siteId=291194637