fork(7) download
  1. def aux(x):
  2. # in h we store the pre-calculated results for small dimensions
  3. h = {18:[6,6,6], 16:[8,8], 14:[8,6], 12:[6,6], 10:[6,4], 8:[8], 6:[6], 4:[4]}
  4. res = []
  5. while x > 18:
  6. # as long as the remaining space is large, we put there tiles of size 8
  7. res.append(8)
  8. x -= 8
  9. if x not in h:
  10. print("no solution found")
  11. return []
  12.  
  13. return res + h[x]
  14.  
  15. def tiles( x, y ):
  16. ax = aux(x) # split the x-dimension into tiles
  17. ay = aux(y) # split the y-dimension into tiles
  18. res = [ [ (x,y) for x in ax ] for y in ay ]
  19. for u in res:
  20. print(u)
  21. return res
  22.  
  23.  
  24. tiles( 90, 20 )
Success #stdin #stdout 0.1s 10104KB
stdin
Standard input is empty
stdout
[(8, 8), (8, 8), (8, 8), (8, 8), (8, 8), (8, 8), (8, 8), (8, 8), (8, 8), (6, 8), (6, 8), (6, 8)]
[(8, 6), (8, 6), (8, 6), (8, 6), (8, 6), (8, 6), (8, 6), (8, 6), (8, 6), (6, 6), (6, 6), (6, 6)]
[(8, 6), (8, 6), (8, 6), (8, 6), (8, 6), (8, 6), (8, 6), (8, 6), (8, 6), (6, 6), (6, 6), (6, 6)]