There are four numbers: 1, 2, 3, 4, how many three digits can be made up of each other without repeating numbers? What's the number?
Turn the numbers into characters and put the characters together:
#!/usr/bin/env python#-*-coding:utf-8-*-x =0 forIinchRange (1,5): forJinchRange (1,5): forKinchRange (1,5): if(i!= J) and(i! = k) and(J! =k): Num="'. Join (Map (str,[i,j,k)) x+ = 1Print 'Section'+STR (x) +'the number is:'+NumPrint 'Total'+STR (x) +'The number satisfies the condition. '
Magical bit operations:
# !/usr/bin/env python # -*-coding:utf-8-*- # coding:utf-8 # from 00 01 10 to £ º for num in Range (6,58 = num >> 4 & 3 b = num >> 2 & 3 c = num & 3 if (a^b) and (b^c) and (C^a)) : # xor print a+1,b+1,c+1
num = 6 000110
000000 & 000011 = 000000 0
000001 & 000011 = 000001 1
000110 & 000011 = 000010 2
000001:1 000011:3 000010:2
The
num = 7 000111
000000 & 000011 = 000000 0
000001 & 000011 = 000001 1
000111 & 000011 = 000011 3
000001:1 000010:2 000011:3
True
1,2,4
Python Mania-1