fork download
  1. def findEmpty(firstList):
  2. newList = []
  3. a = 1
  4. while a < len(firstList):
  5. newList.append(firstList[a])
  6. a += 1
  7. empty = []
  8. fullList = range(1, 26)
  9. b = 0
  10. while b < 25:
  11. if fullList[b] not in newList:
  12. empty.append(fullList[b])
  13. b += 1
  14. return empty
  15.  
  16. def optionOne(empty):
  17. try:
  18. return empty[0]
  19. except:
  20. return "NONE"
  21.  
  22. def optionTwo(empty):
  23. a = 0
  24. b = range(20, 26)
  25. while a < len(empty):
  26. if empty[a] + 5 in empty and empty[a] not in b:
  27. return empty[a]
  28. a += 1
  29. return "NONE"
  30.  
  31. def optionThree(empty):
  32. a = 1
  33. b = []
  34. while a <= 5:
  35. b.append(5 * a)
  36. a += 1
  37. c = 0
  38. while c < len(empty):
  39. if empty[c] + 1 in empty and empty[c] not in b:
  40. return empty[c]
  41. c += 1
  42. return "NONE"
  43.  
  44. def main():
  45. firstList = list(input())
  46. empty = findEmpty(firstList)
  47. listOfInputs = []
  48. a = 0
  49. while a < 5:
  50. listOfInputs.append(input())
  51. if listOfInputs[a] == 1:
  52. space = optionOne(empty)
  53. if space == "NONE":
  54. pass
  55. else:
  56. firstList.append(space)
  57. elif listOfInputs[a] == 2:
  58. space = optionTwo(empty)
  59. if space == "NONE":
  60. pass
  61. else:
  62. firstList.append(space)
  63. firstList.append(space + 5)
  64. elif listOfInputs[a] == 3:
  65. space = optionThree(empty)
  66. if space == "NONE":
  67. pass
  68. else:
  69. firstList.append(space)
  70. firstList.append(space + 1)
  71. empty = findEmpty(firstList)
  72. print space
  73. a += 1
  74.  
  75. main()
Success #stdin #stdout 0.01s 7856KB
stdin
8, 1, 3, 5, 6, 7, 8, 10, 13
1
1
2
3
2
stdout
2
4
9
11
15