Python 22
[Python 100] Python 100
a,b,cx,y,zaxcx,z
#!/usr/bin/python
# -*- coding: UTF-8 -*-
for i in range(ord('x'),ord('z') + 1):
for j in range(ord('x'),ord('z') + 1):
if i != j:
for k in range(ord('x'),ord('z') + 1):
if (i != k) and (j != k):
if (i != ord('x')) and (k != ord('x')) and (k != ord('z')):
print ('order is a -- %s\t b -- %s\tc--%s' % (chr(i),chr(j),chr(k)))
order is a -- z b -- x c--y
[Python 100] Python 100
596***[email protected]
#!/usr/bin/python # -*- coding: UTF-8 -*- for a in ['x','y','z']: for b in ['x', 'y', 'z']: for c in ['x', 'y', 'z']: if(a!=b)and(b!=c)and(c!=a) and (a!='x') and (c!='x') and (c!='z'): print 'a%sb%sc%s' %(a,b,c)596***[email protected]
Kunz
sun***[email protected]
#!/usr/bin/python # -*- coding: UTF-8 -*- n=['a','b','c'] m=[] for i in range(3): if n[i]!='a' and n[i]!='c': m.insert(i,'x') elif n[i]!='c': m.insert(i,'z') else: m.insert(i,'y') print 'a--%s, b--%s, c--%s' %(m[0], m[1], m[2])Kunz
sun***[email protected]
maq***[email protected]
#coding:UTF-8 n=['a','b','c'] m=['x','y','z'] L=[] for i in range(0,3): for j in range(0,3): L.append(n[i]+m[j]) L.remove('ax') L.remove('ay') L.remove('by') L.remove('bz') L.remove('cx') L.remove('cz') print(L)maq***[email protected]
qia***[email protected]
Python2.x Python3.x
#!/usr/bin/python # -*- coding: UTF-8 -*- import itertools A = ["a", "b", "c"] B = ["x", "y", "z"] team = [] # rankB = [list(each) for each in itertools.permutations(B)] # while True: flag = 0 team = list(zip(A, B)) # print(team) for each in team: if (("a" in each) and ("x" in each)) or (("c" in each) and (("x" in each) or ("z" in each))): # flag = 1 # break if flag: B = rankB.pop() # else: break for v1, v2 in team: print("%s %s" % (v1, v2))qia***[email protected]