Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- start = time.perf_counter()
- def con(H):
- J = []
- Q = []
- W = []
- for i in H:
- for j in range(len(i)-1):
- Cop = i[::]
- y = i[j]+i[j+1]
- del Cop[j:j+2]
- Cop.insert(j,y)
- J.append(Cop)
- for i in J:
- y =(sorted("".join(str(j) for j in i)))
- Q.append("".join(y))
- T = list(set(Q))
- for i in T:
- y = [int(j) for j in i]
- W.append(y)
- return W
- num = 5
- K = [[1 for i in range(num)]]
- count = 0
- for i in range(len(K[0])-2):
- K = con(K)
- print(K)
- count = count + len(K)
- print(count+1)
- end = time.perf_counter()
- print(end-start,"second")
- 4 + 1
- 3 + 2
- 3 + 1 + 1
- 2 + 2 + 1
- 2 + 1 + 1 + 1
- 1 + 1 + 1 + 1 + 1
- 3 + 1
- 2 + 2
- 2 + 1 + 1
- 1 + 1 + 1 + 1
- (4 + 1)
- (3 + 2)
- 3 + 1 (+ 1)
- 2 + 2 (+ 1)
- 2 + 1 + 1 (+ 1)
- 1 + 1 + 1 + 1 (+ 1)
- (3 + 1)
- (2 + 2)
- 2 + 1 (+ 1)
- 1 + 1 + 1 (+ 1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement