Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import itertools
- import copy
- a = [1,2,8,6]
- old_a = copy.deepcopy(a)
- pers = itertools.permutations(a,2)
- k = list(pers)
- combined = []
- for i in k:
- combined.append(int(str(i[0])+str(i[1])))
- combined.sort(reverse=True)
- print combined
- d1 = 0
- d2 = 0
- no = []
- found_d1 = False
- found_d2 = False
- while found_d1 == False or found_d2 == False:
- a = copy.deepcopy(old_a)
- pers = itertools.permutations(a,2)
- k = list(pers)
- combined = []
- for i in k:
- combined.append(int(str(i[0])+str(i[1])))
- combined.sort(reverse=True)
- old_comb = combined
- for i in combined:
- if i < 24 and i not in no:
- d1 = i
- found_d1 = True
- break
- if found_d1 == False:
- break
- a.remove(d1/10)
- a.remove(d1%10)
- pers = itertools.permutations(a,2)
- k = list(pers)
- combined = []
- for i in k:
- combined.append(int(str(i[0])+str(i[1])))
- combined.sort(reverse=True)
- for i in combined:
- if i < 60:
- d2 = i
- found_d2 = True
- break
- if found_d1 == True and found_d2 == False:
- no.append(d1)
- found_d1 = False
- if found_d1 == False or found_d2 == False:
- print "Not valid"
- else:
- print d1
- print d2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement