Python 1
[Python 100] Python 100
1234
1234
#!/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)
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
[Python 100] Python 100
zavier
126***[email protected]
#!/usr/bin/python # -*- coding: UTF-8 -*- # d=[] 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 (c!=b): d.append([a,b,c]) print "", len(d) print dzavier
126***[email protected]
946***[email protected]
forif
946***[email protected]
rea***[email protected]
()
#!/usr/bin/python # -*- coding: UTF-8 -*- line=[] for i in range(123,433): a=i%10 b=(i%100)//10 c=(i%1000)//100 if a!=b and b!=c and a!=c and 0<a<5 and 0<b<5 and 0<c<5 : print (i) line.append(i) print('the total is :',len(line))rea***[email protected]
121***[email protected]
python3
#!/usr/bin/env python3 #coding:utf-8 num=[1,2,3,4] i=0 for a in num: for b in num: for c in num: if (a!=b) and (b!=c) and (c!=a): i+=1 print(a,b,c) print('',i)121***[email protected]
liu***[email protected]
#!/usr/bin/env python #-*- coding:utf-8 -*- # import pprint list_num=['1','2','3','4'] list_result=[] for i in list_num: for j in list_num: for k in list_num: if len(set(i+j+k))==3: list_result+=[int(i+j+k)] print("%d: "%len(list_result)) pprint.pprint(list_result)liu***[email protected]
Chyroc
che***[email protected]
python
#!/usr/bin/env python3 #coding:utf-8 from itertools import permutations for i in permutations([1, 2, 3, 4], 3): print(i)Chyroc
che***[email protected]
weapon
965***[email protected]
:
#!/usr/bin/env python3 # -*- coding:utf-8 -*- # from itertools import permutations for i in permutations([1, 2, 3, 4], 3): k = '' for j in range(0, len(i)): k = k + str(i[j]) print (int(k))weapon
965***[email protected]
me@***gdewen.com
# coding:utf-8 # 00 01 10 11 10 01 for num in range(6,58): a = num >> 4 & 3 b = num >> 2 & 3 c = num & 3 if( (a^b) and (b^c) and (c^a) ): print a+1,b+1,c+1me@***gdewen.com
DCGDDD
805***[email protected]
#!/usr/bin/python3 for i in range(1, 5): for j in range(1, 5): if (j==i) : continue; for k in range(1, 5): if (k==i or k==j): continue; print(i,j,k);DCGDDD
805***[email protected]
123***.com
Python3
#!/usr/bin/python3 list = [1,2,3,4] for i in list: list1 = list.copy() list1.remove(i) for j in list1: list2 = list1.copy() list2.remove(j) for k in list2: print(i, j, k)123***.com
Krystal
104***[email protected]
format
#!/usr/bin/python #-*- coding: UTF-8 -*- list_num = [1,2,3,4] list = [i*100 + j*10 + k for i in list_num for j in list_num for k in list_num if ( i != j and i != k and j != k)] d = len(list) print('1,2,3,4 %d ' % d) print(':%s' % list)Krystal
104***[email protected]
545***[email protected]
#!/usr/bin/env python3 #coding=utf-8 from itertools import permutations t = 0 for i in permutations('1234',3): print(''.join(i)) t += 1 print(":%s"%t)545***[email protected]
303***[email protected]
#encoding=utf8 #1234 d = [] for j in range(1,5): for k in range(1,5): for l in range(1,5): if l!=j!=k!=l: d.append(int(str(j)+str(k)+str(l))) print d print len(d)303***[email protected]
XMDERO
124***[email protected]
XMDERO
124***[email protected]
173***[email protected]
#coding=utf-8 print("---------- -------------") # def f01(i): if i==123: print(i) return else: if (set('567890') & set(str(i))==set()) and (len(set(str(i)))==3): print(i) f01(i-1) f01(432) print("-----------------------") # def f02(): for i in range(123,433): if (set('567890') & set(str(i))==set()) and (len(set(str(i)))==3): yield i for i in f02(): print(i)173***[email protected]
whitestonex
851***[email protected]
import itertools DataIn = list('1234') TmpList = [] for x in list(itertools.combinations(DataIn,3)): TmpList = TmpList + list(itertools.permutations(x,3)) for i in TmpList: print(''.join(i))whitestonex
851***[email protected]