fork download
  1. #!/usr/bin/env python
  2.  
  3. cashiers = (2,7,3,5,2) # capabilities
  4.  
  5. def solve(data):
  6. customer = [0] * len(cashiers)
  7. processable = [9*len(data)] * len(cashiers)
  8. for d in data:
  9. cashier = customer.index(min(customer))
  10. if d in '123456789':
  11. customer[cashier] += int(d)
  12. elif d == 'x':
  13. processable[cashier] = min(customer[cashier], processable[cashier])
  14. customer[cashier] += 1
  15. elif d == '.':
  16. for cashier,capability in enumerate(cashiers):
  17. customer[cashier] -= min(customer[cashier], processable[cashier], capability)
  18. processable[cashier] -= min(processable[cashier], capability)
  19. return ','.join(map(str, customer))
  20.  
  21. def test(data, correct):
  22. answer = solve(data)
  23. print 'xo'[answer==correct], data, correct, answer
  24.  
  25. 0, test( "42873x.3.", "0,4,2,0,0" );
  26. 1, test( "1", "1,0,0,0,0" );
  27. 2, test( ".", "0,0,0,0,0" );
  28. 3, test( "x", "1,0,0,0,0" );
  29. 4, test( "31.", "1,0,0,0,0" );
  30. 5, test( "3x.", "1,1,0,0,0" );
  31. 6, test( "99569x", "9,9,6,6,9" );
  32. 7, test( "99569x33", "9,9,9,9,9" );
  33. 8, test( "99569x33.", "7,2,6,4,7" );
  34. 9, test( "99569x33..", "5,0,4,0,5" );
  35. 10, test( "12345x3333.", "4,0,3,2,3" );
  36. 11, test( "54321x3333.", "3,0,3,0,4" );
  37. 12, test( "51423x3333.", "3,4,4,0,4" );
  38. 13, test( "12x34x.", "1,0,1,0,2" );
  39. 14, test( "987x654x.32", "7,6,4,10,5" );
  40. 15, test( "99999999999x99999999.......9.", "20,10,12,5,20" );
  41. 16, test( "997", "9,9,7,0,0" );
  42. 17, test( ".3.9", "1,9,0,0,0" );
  43. 18, test( "832.6", "6,6,0,0,0" );
  44. 19, test( ".5.568", "3,5,6,8,0" );
  45. 20, test( "475..48", "4,8,0,0,0" );
  46. 21, test( "7.2..469", "1,4,6,9,0" );
  47. 22, test( "574x315.3", "3,3,1,7,1" );
  48. 23, test( "5.2893.x98", "10,9,5,4,1" );
  49. 24, test( "279.6xxx..4", "2,1,4,1,1" );
  50. 25, test( "1.1.39..93.x", "7,1,0,0,0" );
  51. 26, test( "7677749325927", "16,12,17,18,12" );
  52. 27, test( "x6235.87.56.9.", "7,2,0,0,0" );
  53. 28, test( "4.1168.6.197.6.", "0,0,3,0,0" );
  54. 29, test( "2.8.547.25..19.6", "6,2,0,0,0" );
  55. 30, test( ".5.3x82x32.1829..", "5,0,5,0,7" );
  56. 31, test( "x.1816..36.24.429.", "1,0,0,0,7" );
  57. 32, test( "79.2.6.81x..26x31.1", "1,0,2,1,1" );
  58. 33, test( "574296x6538984..5974", "14,13,10,15,14" );
  59. 34, test( "99.6244.4376636..72.6", "5,6,0,0,3" );
  60. 35, test( "1659.486x5637168278123", "17,16,16,18,17" );
  61. 36, test( ".5.17797.x626x5x9457.3.", "14,0,3,5,8" );
  62. 37, test( "..58624.85623..4.7..23.x", "1,1,0,0,0" );
  63. 38, test( "716.463.9.x.8..4.15.738x4", "7,3,5,8,1" );
  64. 39, test( "22xx.191.96469472.7232377.", "10,11,18,12,9" );
  65. 40, test( "24..4...343......4.41.6...2", "2,0,0,0,0" );
  66. 41, test( "32732.474x153.866..4x29.2573", "7,5,7,8,5" );
  67. 42, test( "786.1267x9937.17.15448.1x33.4", "4,4,8,4,10" );
  68. 43, test( "671714849.149.686852.178.895x3", "13,16,13,10,12" );
  69. 44, test( "86x.47.517..29621.61x937..xx935", "7,11,8,8,10" );
  70. 45, test( ".2233.78x.94.x59511.5.86x3.x714.", "4,6,10,8,8" );
  71. 46, test( ".793...218.687x415x13.1...x58576x", "8,11,8,6,9" );
  72. 47, test( "6.6x37.3x51x932.72x4x33.9363.x7761", "15,13,15,12,15" );
  73. 48, test( "6..4.x187..681.2x.2.713276.669x.252", "6,7,8,6,5" );
  74. 49, test( ".6.xx64..5146x897231.x.21265392x9775", "19,17,19,20,17" );
  75. 50, test( "334.85413.263314.x.6293921x3.6357647x", "14,14,12,16,10" );
  76. 51, test( "4.1..9..513.266..5999769852.2.38x79.x7", "12,10,13,6,10" );
Success #stdin #stdout 0.01s 7852KB
stdin
Standard input is empty
stdout
o 42873x.3. 0,4,2,0,0 0,4,2,0,0
o 1 1,0,0,0,0 1,0,0,0,0
o . 0,0,0,0,0 0,0,0,0,0
o x 1,0,0,0,0 1,0,0,0,0
o 31. 1,0,0,0,0 1,0,0,0,0
o 3x. 1,1,0,0,0 1,1,0,0,0
o 99569x 9,9,6,6,9 9,9,6,6,9
o 99569x33 9,9,9,9,9 9,9,9,9,9
o 99569x33. 7,2,6,4,7 7,2,6,4,7
o 99569x33.. 5,0,4,0,5 5,0,4,0,5
o 12345x3333. 4,0,3,2,3 4,0,3,2,3
o 54321x3333. 3,0,3,0,4 3,0,3,0,4
o 51423x3333. 3,4,4,0,4 3,4,4,0,4
o 12x34x. 1,0,1,0,2 1,0,1,0,2
o 987x654x.32 7,6,4,10,5 7,6,4,10,5
o 99999999999x99999999.......9. 20,10,12,5,20 20,10,12,5,20
o 997 9,9,7,0,0 9,9,7,0,0
o .3.9 1,9,0,0,0 1,9,0,0,0
o 832.6 6,6,0,0,0 6,6,0,0,0
o .5.568 3,5,6,8,0 3,5,6,8,0
o 475..48 4,8,0,0,0 4,8,0,0,0
o 7.2..469 1,4,6,9,0 1,4,6,9,0
o 574x315.3 3,3,1,7,1 3,3,1,7,1
o 5.2893.x98 10,9,5,4,1 10,9,5,4,1
o 279.6xxx..4 2,1,4,1,1 2,1,4,1,1
o 1.1.39..93.x 7,1,0,0,0 7,1,0,0,0
o 7677749325927 16,12,17,18,12 16,12,17,18,12
o x6235.87.56.9. 7,2,0,0,0 7,2,0,0,0
o 4.1168.6.197.6. 0,0,3,0,0 0,0,3,0,0
o 2.8.547.25..19.6 6,2,0,0,0 6,2,0,0,0
o .5.3x82x32.1829.. 5,0,5,0,7 5,0,5,0,7
o x.1816..36.24.429. 1,0,0,0,7 1,0,0,0,7
o 79.2.6.81x..26x31.1 1,0,2,1,1 1,0,2,1,1
o 574296x6538984..5974 14,13,10,15,14 14,13,10,15,14
o 99.6244.4376636..72.6 5,6,0,0,3 5,6,0,0,3
o 1659.486x5637168278123 17,16,16,18,17 17,16,16,18,17
o .5.17797.x626x5x9457.3. 14,0,3,5,8 14,0,3,5,8
o ..58624.85623..4.7..23.x 1,1,0,0,0 1,1,0,0,0
o 716.463.9.x.8..4.15.738x4 7,3,5,8,1 7,3,5,8,1
o 22xx.191.96469472.7232377. 10,11,18,12,9 10,11,18,12,9
o 24..4...343......4.41.6...2 2,0,0,0,0 2,0,0,0,0
o 32732.474x153.866..4x29.2573 7,5,7,8,5 7,5,7,8,5
o 786.1267x9937.17.15448.1x33.4 4,4,8,4,10 4,4,8,4,10
o 671714849.149.686852.178.895x3 13,16,13,10,12 13,16,13,10,12
o 86x.47.517..29621.61x937..xx935 7,11,8,8,10 7,11,8,8,10
o .2233.78x.94.x59511.5.86x3.x714. 4,6,10,8,8 4,6,10,8,8
o .793...218.687x415x13.1...x58576x 8,11,8,6,9 8,11,8,6,9
o 6.6x37.3x51x932.72x4x33.9363.x7761 15,13,15,12,15 15,13,15,12,15
o 6..4.x187..681.2x.2.713276.669x.252 6,7,8,6,5 6,7,8,6,5
o .6.xx64..5146x897231.x.21265392x9775 19,17,19,20,17 19,17,19,20,17
o 334.85413.263314.x.6293921x3.6357647x 14,14,12,16,10 14,14,12,16,10
o 4.1..9..513.266..5999769852.2.38x79.x7 12,10,13,6,10 12,10,13,6,10