class Solution(object):


def cartesian_product(self,a,b):
l = [] #空的集合
for x in a: #x为a中所有的成员
for y in b: #y为b中所有的成员
kk=str(x)+str(y)
# print(kk)
if len(set(kk))==len(kk):
l.append(kk) #将所有可能的“有序对”加到“空集合”中
return l
def nextPermutation(self, nums):
"""
:type nums: List[int]
:rtype: None Do not return anything, modify nums in-place instead.
"""

c=self.cartesian_product(nums,nums)
c=self.cartesian_product(nums,c)
c.sort()
#print(c)
g = c.index(''.join([str(p) for p in nums]))
#print(k)
if g ==len(c)-1:
print(-------------------'')
return [int(k) for k in c[0]]
else:
#print(c[k+1])
print([int(i) for i in c[g+1]])
print('#####################################')
kk=[int(m) for m in c[g+1]]
return kk
a=[1,2,3]
c=Solution()
import time
t1=time.time()

#计算几个数之和,下面就填几
c1=c.nextPermutation( a)
print(time.time()-t1)

print(c1)