summaryrefslogtreecommitdiff
path: root/024.py
blob: 47546a53e6d134a8eab3f8d4629b0aacd4ffa159 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

import sys

digits = [ x for x in range(0, 10) ]

limit = 1000000

count = 0

def permutate(start, end):
	global permutations, count
	if len(end) == 1:
		count += 1
		if count == limit:
			print start+end
			sys.exit(0)
		return
	for i in range(0, len(end)):
		s = start + [end[i]]
		e = end[:i] + end[i+1:]
		permutate(s, e)

permutate([], digits)