中亿丰数字
DTCloud 第1天
题目:有四个字母:a、b、c、d,能组成多少个互不相同且无重复数字的三个字母的组合?各是多少?
代码:
# coding = utf-8
start = ord('a')
end = ord('e')
for i in range(start, end):
for j in range(start, end):
for k in range(start, end):
if (i != k) and (i != j) and (j != k):
print(chr(i) + chr(j) + chr(k))
输出结果:
abc
abd
acb
acd
adb
adc
bac
bad
bca
bcd
bda
bdc
cab
cad
cba
cbd
cda
cdb
dab
dac
dba
dbc
dca
dcb