def solution2array(solution):
    """ rewrites an solution of the form  {(1,1): [4], (1,2): [5] , .... (9,9) : [1]} to an 2dimensional array.
        this is useful if we want to output it in a human readable form.
        this is also used as intermediate step for rewriting the sudoku back to the original format.
    """
    sudoku_array = []
    for i in range(9):
        sudoku_array.append([])
        for j in range(9):
            sudoku_array[i].append(0)
    for variable, assignment in solution.iteritems():
        if len(assignment) == 1:
            sudoku_array[variable[0] -1][variable[1] - 1] = assignment[0]
    return sudoku_array