Python includes exercises 1
Title: 1,2,3,4 figures, the number of each other with no repeat of the three-digit numbers can be composed? How many are?
Program analysis: can be filled in one hundred, ten digital bits are 1,2,3,4. Arrangement does not meet the conditions of the composition of all the permutations and then removed.
Source Code:
Examples (Python 2.0+)
#! / usr / bin / python
# - * - Coding: UTF- 8 - * -
for i in range (1, 5): for j in range (1, 5): for k in range (1, 5): if ( i! = k ) and (I! = J) and (J = k!): Print i, j, k
The above example output is:
1 2 3 1 2 4 1 3 2 1 3 4 1 4 2 1 4 3 2 1 3 2 1 4 2 3 1 2 3 4 2 4 1 2 4 3 3 1 2 3 1 4 3 2 1 3 2 4 3 4 1 3 4 2 4 1 2 4 1 3 4 2 1 4 2 3 4 3 1 4 3 2