Commits

Shlomi Fish  committed 309a6bc

Convert to a two dimensional array first.

  • Participants
  • Parent commits 66cd5d1

Comments (0)

Files changed (1)

File kakurasu-solver/kakurasu-solver.py

     ret = lp_solve(f_vector, a_matrix, b_vector, e_vector, \
             lower_bounds_vector, upper_bounds_vector, xint_vector)
    
-    sol = ret[1]
+    flat_sol = ret[1]
+
+    sol = [[flat_sol[y*width+x] for x in range(width)] for y in range(height)]
 
     if (len(sol) == 0):
         raise "Could not find a solution for this puzzle."
 
     for y in range(0,height):
         for x in range(0,width):
-            sys.stdout.write ('█' if (sol[y*height+x] != 0) else '⨯')
+            sys.stdout.write ('█' if (sol[y][x] != 0) else '⨯')
         sys.stdout.write("\n")
 
     return 0