fork download
  1. def getCoordinates(location):
  2. return [int(location[0]), int(location[3])]
  3.  
  4. def getN(location):
  5. return int(location[6])
  6.  
  7. def horizontal(location, n):
  8. a = []
  9. b = location[0] + n
  10. c = location[0] - n
  11. while c <= b:
  12. x = [c, location[1]]
  13. a.append(x)
  14. c += 1
  15. return a
  16.  
  17. def vertical(location, n):
  18. a = []
  19. b = location[1] + n
  20. c = location[1] - n
  21. while c <= b:
  22. x = [location[0], c]
  23. a.append(x)
  24. c += 1
  25. return a
  26.  
  27. def diagonal(location, n):
  28. a = []
  29. b = location[0] + n
  30. c = location[0] - n
  31. while c <= b:
  32. d = location[1] + n
  33. e = location[1] - n
  34. while e <= d:
  35. x = [c, e]
  36. a.append(x)
  37. e += 1
  38. c += 1
  39. b = location[0] + n
  40. c = location[0] - n
  41. while c <= b:
  42. d = location[1] + n
  43. e = location[1] - n
  44. while d >= e:
  45. x = [c, d]
  46. a.append(x)
  47. d -= 1
  48. c += 1
  49. return a
  50.  
  51. def complement(totallist):
  52. a = []
  53. b = []
  54. c = 1
  55. while c <= 5:
  56. d = 1
  57. while d <= 5:
  58. b.append([c, d])
  59. d += 1
  60. c += 1
  61. e = 0
  62. while e < 25:
  63. if b[e] not in totallist:
  64. a.append(b[e])
  65. e += 1
  66. return a
  67.  
  68. def main():
  69. x = []
  70. y = []
  71. z = []
  72. o = []
  73. p = 0
  74. while p < 5:
  75. x.append(raw_input())
  76. y.append(getCoordinates(x[p]))
  77. z.append(getN(x[p]))
  78. a = horizontal(y[p], z[p])
  79. b = vertical(y[p], z[p])
  80. c = diagonal(y[p], z[p])
  81. d = []
  82. e = 0
  83. while e < len(a):
  84. d.append(a[e])
  85. e += 1
  86. e = 0
  87. while e < len(b):
  88. d.append(b[e])
  89. e += 1
  90. e = 0
  91. while e < len(c):
  92. d.append(c[e])
  93. e += 1
  94. f = complement(d)
  95. g = len(f)
  96. o.append(g)
  97. print o[p]
  98. p += 1
  99.  
  100. main()
Success #stdin #stdout 0.01s 7900KB
stdin
1, 1, 4
2, 4, 1
4, 2, 3
1, 3, 2
3, 2, 2
stdout
12
16
10
14
11