fork download
  1. #Put your own folding sequences here:
  2. FOLD_SEQUENCES = """
  3.  
  4. 20*20R1D1R1D1R1D1R1D1
  5. 40*20R1D1R1D1R1D1R1D1
  6. 40*40R1D1R1D1R1D1R1D1
  7. 20*80R1D1R1D1R1D1R1D1
  8.  
  9. """
  10.  
  11. import re
  12.  
  13. def foldRight(grid, n):
  14. h, w = len(grid), len(grid[0])
  15. for y in range(h):
  16. for offset in range(min(n, w - n)):
  17. c1 = grid[y][n + offset]
  18. c2 = grid[y][n - offset - 1]
  19. avg = 0.5 * (c1 + c2)
  20. grid[y][n + offset] = avg
  21. grid[y][n - offset - 1] = avg
  22.  
  23. def foldDown(grid, n):
  24. h, w = len(grid), len(grid[0])
  25. for x in range(w):
  26. for offset in range(min(n, h - n)):
  27. c1 = grid[n + offset][x]
  28. c2 = grid[n - offset - 1][x]
  29. avg = 0.5 * (c1 + c2)
  30. grid[n + offset][x] = avg
  31. grid[n - offset - 1][x] = avg
  32.  
  33. def foldGrid(grid, fold):
  34. if fold[0] == 'R':
  35. foldRight(grid, fold[1])
  36. else:
  37. foldDown(grid, fold[1])
  38.  
  39. def gridAvg(grid):
  40. total = 0.0
  41. for row in grid:
  42. total += sum(row)
  43. return total / (len(grid) * len(grid[0]))
  44.  
  45. def calcScore(grid, foldSeq):
  46. avg = gridAvg(grid)
  47. for fold in foldSeq:
  48. foldGrid(grid, fold)
  49. score = 0
  50. for row in grid:
  51. for cell in row:
  52. score += abs(cell - avg)
  53. return score
  54.  
  55. def calcAllScores():
  56. grids = getGrids()
  57. foldSeqs = dict(map(parseFoldSeq, FOLD_SEQUENCES.strip().split('\n')))
  58. if len(foldSeqs) != len(grids):
  59. return None
  60. scores = {}
  61. total = 0
  62. for title in grids:
  63. score = calcScore(grids[title], foldSeqs[title])
  64. total += score
  65. scores[title] = score
  66. return scores, total
  67.  
  68. def parseFold(foldStr):
  69. return foldStr[0], int(foldStr[1:])
  70.  
  71. def parseFoldSeq(foldSeqStr):
  72. pattern = r'(\d+\*\d+)' + 8 * r'([RD]\d+)'
  73. data = re.search(pattern, foldSeqStr).groups()
  74. title = data[0]
  75. foldSeq = map(parseFold, data[1:])
  76. return title, foldSeq
  77.  
  78. def parseRow(rowStr):
  79. row = []
  80. for c in rowStr:
  81. if c == '0':
  82. row.append(0)
  83. elif c == '1':
  84. row.append(1)
  85. return row
  86.  
  87. def parseGrid(gridStr): #grids are indexed by y then x
  88. rows = gridStr.split('\n')
  89. title = rows[0]
  90. grid = map(parseRow, rows[1:])
  91. return title, grid
  92.  
  93. def getGrids():
  94. g1 = """20*20
  95. 1 1 1 0 1 1 0 0 1 0 0 1 0 1 1 0 1 0 1 1
  96. 1 1 0 0 0 1 0 1 1 0 0 0 1 0 1 1 1 0 1 1
  97. 0 1 0 0 0 1 0 1 0 1 1 1 1 0 1 0 1 0 1 0
  98. 0 0 0 1 0 1 0 0 0 0 1 1 1 0 1 1 0 0 0 1
  99. 0 1 0 1 1 0 0 0 0 0 1 0 1 1 1 0 1 0 1 0
  100. 1 0 1 1 0 1 1 1 1 1 1 0 0 1 0 1 0 1 0 1
  101. 0 1 1 1 0 0 0 1 1 0 1 0 1 1 0 0 0 0 0 0
  102. 0 0 0 0 0 0 1 1 1 1 1 0 0 0 1 1 0 0 0 0
  103. 1 1 1 0 1 0 0 1 0 1 1 1 1 1 1 0 0 0 0 1
  104. 1 1 0 0 0 1 1 1 0 1 0 1 0 0 1 1 0 0 1 0
  105. 0 1 1 0 0 0 1 1 0 1 1 1 0 1 1 1 0 1 0 1
  106. 0 1 1 1 1 0 0 1 1 0 1 0 1 1 1 1 0 1 1 0
  107. 0 0 0 1 0 0 0 1 0 1 0 0 1 0 0 0 1 0 0 1
  108. 0 0 1 1 1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1
  109. 1 1 1 1 0 1 1 0 0 0 0 1 1 1 0 0 0 0 0 1
  110. 1 0 0 1 0 0 0 0 1 0 0 1 1 0 0 0 0 0 0 0
  111. 0 1 1 1 0 0 1 1 0 0 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 1 0
  248. 0 0 0 0 0 0 0 1 0 1 0 0 0 1 1 1 1 1 1 0
  249. 0 0 1 1 1 0 1 1 0 0 1 1 0 1 0 0 1 0 1 0
  250. 1 0 1 1 1 1 1 1 1 0 0 1 0 1 0 1 0 0 1 1
  251. 1 1 0 1 0 1 0 1 0 1 1 0 0 0 0 1 1 1 1 0
  252. 0 0 0 1 0 1 0 1 1 1 0 1 0 0 1 0 0 1 0 0
  253. 0 1 1 0 0 1 0 0 0 0 0 1 0 0 0 0 1 0 1 0
  254. 1 1 0 0 1 1 0 0 1 1 0 0 0 1 0 1 1 0 1 1
  255. 1 0 1 0 0 0 1 0 0 1 1 1 0 1 0 0 0 0 0 0
  256. 1 0 1 1 0 1 1 0 0 1 1 1 0 0 1 1 0 1 1 0
  257. 0 0 1 0 1 0 0 1 1 1 0 1 0 1 1 0 1 0 0 0
  258. 0 1 0 1 1 0 1 1 1 1 0 1 1 1 1 0 1 0 0 1
  259. 1 0 1 0 1 1 0 0 1 0 0 0 1 0 0 1 0 1 0 1
  260. 0 1 0 0 1 0 1 0 1 1 1 0 0 0 1 0 1 0 1 1"""
  261.  
  262. return dict(map(parseGrid, [g1, g2, g3, g4]))
  263.  
  264. scores, total = calcAllScores()
  265. print 'Total Score:', total
  266. print 'Individual Scores:'
  267. for title in scores:
  268. print title, scores[title]
Success #stdin #stdout 0.02s 7896KB
stdin
Standard input is empty
stdout
Total Score: 2062.4575
Individual Scores:
40*40 761.4225
20*20 184.195
20*80 747.84
40*20 369.0