fork download
  1. def breakdownString(s):
  2. a = 0
  3. b = []
  4. while a < 5:
  5. b.append(s[a])
  6. a += 1
  7. return b
  8.  
  9. def buildString(s):
  10. a = 0
  11. b = ""
  12. while a < 5:
  13. b += s[a]
  14. a += 1
  15. return b
  16.  
  17. def findAsterisks(s):
  18. a = 0
  19. b = []
  20. while a < 5:
  21. if s[a] == "*":
  22. b.append(a)
  23. a += 1
  24. return b
  25.  
  26. def replaceOne(s, a):
  27. b = []
  28. c = 0
  29. while c < 2:
  30. s[a[0]] = str(c)
  31. d = buildString(s)
  32. b.append(d)
  33. c += 1
  34. return b
  35.  
  36. def replaceTwo(s, a):
  37. b = replaceOne(s, a)
  38. c = 0
  39. d = []
  40. d.append(a[1])
  41. e = []
  42. while c < 2:
  43. f = 0
  44. while f < 2:
  45. e.append(replaceOne(breakdownString(b[c]), d)[f])
  46. f += 1
  47. c += 1
  48. return e
  49.  
  50. def concatenateString(l):
  51. a = 0
  52. b = ""
  53. while a < len(l) - 1:
  54. b += l[a]
  55. b += ", "
  56. a += 1
  57. b += l[len(l) - 1]
  58. return b
  59.  
  60. def main():
  61. i = []
  62. o = []
  63. l = []
  64. a = []
  65. b = 0
  66. while b < 5:
  67. i.append(raw_input())
  68. a.append(findAsterisks(i[b]))
  69. l.append(breakdownString(i[b]))
  70. if len(a[b]) == 1:
  71. o.append(replaceOne(l[b], a[b]))
  72. print concatenateString(o[b])
  73. elif len(a[b]) == 2:
  74. o.append(replaceTwo(l[b], a[b]))
  75. print concatenateString(o[b])
  76. elif len(a[b]) == 0:
  77. o.append(i[b])
  78. print o[b]
  79. b += 1
  80.  
  81. main()
Success #stdin #stdout 0.01s 7856KB
stdin
1*001
1*1*1
1**11
*1111
*111*
stdout
10001, 11001
10101, 10111, 11101, 11111
10011, 10111, 11011, 11111
01111, 11111
01110, 01111, 11110, 11111