Please note that for this grid generator it will generate any valid sudoku grid of any n^2 x n^2 size albeit limited subsets of all sizes. There can't be any repeating elements or it won't be a valid unmapped grid You must enter the input as a tuple such as this format. [1,2,3,4,5] [1,2,3,4,....] The algorthim outputs unmapped grids in linear time Here's the algorthim in python code n = 0 l = input('Enter the lower right solved box to get a correct solution') indices = [] for i in xrange(1, 1+len(l)): indices.append(n % i) n //= i indices.reverse() perm = l for index in indices: perm.append(l.pop(index)) print(perm)