Statistics

Problem Statement for "DominoesFinding"

Problem Statement

Dominoes is a fun game that requires 28 pieces, each representing a different pair of numbers between 0 and 6, inclusive. Since the pieces are reversible, (1,6) is the same piece as (6,1), and there is only one piece of the form (x,x) for each x.

The 28 pieces of dominoes are:

  (0,6) (0,5) (0,4) (0,3) (0,2) (0,1) (0,0)
  (1,6) (1,5) (1,4) (1,3) (1,2) (1,1)
  (2,6) (2,5) (2,4) (2,3) (2,2)
  (3,6) (3,5) (3,4) (3,3)
  (4,6) (4,5) (4,4)
  (5,6) (5,5)
  (6,6)

The problem with dominoes is that you need at least two people to play, so magazines have invented a game that you can play on your own. In a board with 7 columns and 8 rows there are numbers from 0 to 6, inclusive. The goal of the game is to divide the board into 28 2x1 rectangles in such a way that each part corresponds to one of the pieces and each piece is represented exactly once in the divided board.

When a magazine publishes an instance of the game (i.e., a board with the numbers), they want to ensure that it has a solution, and that the number of possible correct solutions is small so as to make the game more difficult.

Given the board as a String[] with each character representing a number between 0 and 6, return the number of correct solutions that board has.

Definition

Class:
DominoesFinding
Method:
getPossibilities
Parameters:
String[]
Returns:
int
Method signature:
int getPossibilities(String[] board)
(be sure your method is public)

Constraints

  • board will contain exactly 8 elements.
  • Each element of board will contain exactly 7 characters.
  • Each character of each element of board will be a domino digit ('0'-'6').

Examples

  1. {"0105142","1155456","0206156","2266563","0312163","3323625","0413242","4434465"}

    Returns: 0

  2. {"0000000", "0123456", "1111112", "1234562", "2222333", "3456345", "3444556", "6456566"}

    Returns: 60

  3. {"1111111","1111111","1111111","1111111","1111111","1111111","1111111","1111111"}

    Returns: 0

    No way!

  4. {"0054450", "6645056", "0151226", "6522303", "0246343", "6411432", "0324531", "6215131"}

    Returns: 1

    Only one way to solve this one. +---+-+---+-+-+ |0 0|5|4 4|5|0| +---+ +---+ | | |6 6|4|5 0|5|6| +---+-+-+-+-+-+ |0 1|5|1|2 2|6| +---+ | +---+ | |6 5|2|2|3|0|3| +---+-+-+ | +-+ |0 2|4|6|3|4|3| +---+ | +-+-+ | |6 4|1|1|4 3|2| +---+-+-+---+-+ |0 3|2 4|5 3|1| +---+---+---+ + |6 2|1 5|1 3|1| +---+---+---+-+

  5. {"1105142","1155456","0206156","2266563","0312163","3323625","0413242","4434465"}

    Returns: 0

  6. {"0006212","0161126","0251223","3014233","0431243","5046524","1155664","3635445"}

    Returns: 0

  7. {"0011565","0112645","0214454","3031442","0416365","5051532","0622346","6623332"}

    Returns: 33540

  8. {"3324521","6053141","4055166","4565002","3350462","0301632","4022615","1441623"}

    Returns: 24

  9. {"3324521","6053141","4055166","4565002","3354062","0301632","4022615","1441623"}

    Returns: 6

  10. {"3324521","6053141","4055166","4365002","3554062","0301632","4442615","1201632"}

    Returns: 27

  11. {"3543246","3506631","6655215","4501433","0263143","0102150","2612424","5602401"}

    Returns: 4

  12. {"6340324","5355114","6003366","2215230","5024436","5131410","2452264","0611065"}

    Returns: 1

  13. {"6240324","5355114","6003366","2215230","5024436","5131410","3452264","0611065"}

    Returns: 0

  14. {"1061030","1636426","6442351","0461042","2535622","0015134","5315230","2535464"}

    Returns: 0

  15. {"3463451","2161133","0004246","1423053","5504322","1055226","4504615","6261603"}

    Returns: 0

  16. {"1665113","5006441","3250626","0533042","6510345","5645610","2234132","3202144"}

    Returns: 0

  17. {"2511643","4201241","2000052","4530616","2261356","6651230","4534351","3046354"}

    Returns: 6

  18. {"4431314","0032632","0262354","3262261","5405651","4556510","1201341","5036064"}

    Returns: 12

  19. {"2056161","2666225","6214510","0030531","6043200","6345154","4353123","1324544"}

    Returns: 4

  20. {"6436331","0122446","0155541","2031003","1265225","4021664","4664502","3533105"}

    Returns: 2

  21. {"2142500","1505401","2330610","2256663","3126453","5504363","0524641","2461431"}

    Returns: 128

  22. {"2355203","4646233","1411216","4244132","0560603","6531145","0050015","2566243"}

    Returns: 12

  23. {"1460553","3546633","0661544","3131644","0051202","0650205","2511612","3422234"}

    Returns: 26

  24. {"2213033","5635653","3245522","4355100","1440662","1011300","5044241","6616642"}

    Returns: 172

  25. {"2312540","1330242","4106621","2234451","0051044","1016353","6456366","5523056"}

    Returns: 24

  26. {"1051326","0502061","0244001","2136324","2115444","6105665","5534536","3322346"}

    Returns: 1

  27. {"5456463","5026021","0424301","0164104","6215335","5611363","2524301","2430652"}

    Returns: 60

  28. {"0225126","0604114","6150133","5210132","3546445","1202323","6653044","5656340"}

    Returns: 20

  29. {"3414652","2002241","5060640","1435322","0435502","1534230","1113566","6166345"}

    Returns: 21

  30. {"5366302","4356531","1562031","0102341","5664124","2231624","3254406","5540001"}

    Returns: 8

  31. {"3211542","6522044","4462432","5310311","2365300","1025556","4651660","0304163"}

    Returns: 7

  32. {"6052436","3600515","3441203","5561540","3242634","1156404","1136522","6200132"}

    Returns: 2

  33. {"2405600","1611050","6644624","4531512","5334205","5431534","6633212","6302012"}

    Returns: 54

  34. {"6561520","2164522","6066135","4155034","3520344","1363040","4301142","3202165"}

    Returns: 64

  35. {"2006214","2420423","3636005","0101654","5331641","4411252","5053266","5516433"}

    Returns: 96

  36. {"0101202","0231331","3204124","3440441","5235152","0535556","6664640","1236566"}

    Returns: 14

  37. {"0112223","0010120","3333404","1242431","4450515","5555602","3466636","6512664"}

    Returns: 240

  38. {"0010112","2233130","1203424","4433041","2555245","5015663","4625016","6465663"}

    Returns: 18

  39. {"0101202","0221331","3234014","4430451","2355405","5412553","6662664","0165366"}

    Returns: 6

  40. {"0010112","2122330","3340014","2342431","4555255","4015534","6061626","6465663"}

    Returns: 82

  41. {"0112022","0013012","3323404","1443451","5235405","1542553","6066263","6416566"}

    Returns: 108

  42. {"0101222","0301012","3323441","1423043","4450515","5555602","3466263","6416566"}

    Returns: 72

  43. {"0011212","3001022","3132330","1424344","4505245","5551563","4166203","4665666"}

    Returns: 5925

  44. {"0011102","0122230","1323304","1424334","5015544","5455260","3561266","6456663"}

    Returns: 2880

  45. {"0001101","2213322","3230104","2434441","0553454","5125635","1625034","6656666"}

    Returns: 110

  46. {"0111012","0001222","2333414","3344042","5034152","3555506","5461663","4656266"}

    Returns: 3312

  47. {"0101101","0223122","2330301","3424344","4055555","4551234","6126664","0665366"}

    Returns: 648

  48. {"0011022","0031212","3133012","3423444","4505255","4551534","0166365","6662646"}

    Returns: 2415

  49. {"0030330","3440234","4242221","3121050","1411535","5251504","3646562","6156666"}

    Returns: 400

  50. {"2262444","2664620","0402506","5400555","6511410","5126133","1143026","3513333"}

    Returns: 546

  51. {"6600655","5560640","5444401","0151416","6053114","3313623","2233202","5432221"}

    Returns: 364

  52. {"4000242","4422600","2664463","2363330","3614021","6131154","5011256","5351555"}

    Returns: 204

  53. {"3030043","3443101","4041355","1451150","3606556","6564321","2662205","4261222"}

    Returns: 864

  54. {"1133153","1356365","6451653","6154444","1046030","6002135","0405226","4202222"}

    Returns: 154

  55. {"2242455","5566424","6524661","1415162","1323435","1363130","0405032","0103600"}

    Returns: 180

  56. {"6222565","6655442","4443623","5356342","3000500","3620043","1111413","6251011"}

    Returns: 216

  57. {"5545440","0003335","4335406","6606625","4223652","2402113","6102541","1612113"}

    Returns: 25

  58. {"5000222","5535502","3333666","0263502","6151121","6110443","4614504","2413446"}

    Returns: 480

  59. {"1144616","6014004","6100462","2220221","4651556","5055431","3325333","4633025"}

    Returns: 448

  60. {"3234236","3326505","0523606","5563041","0045451","1311445","1424126","0162026"}

    Returns: 140

  61. {"2211335","5265600","2134244","4402550","3264416","5463136","1615010","2600533"}

    Returns: 9

  62. {"3536130","1502336","4164421","5566451","0322564","2621044","0023251","5034016"}

    Returns: 256

  63. {"4166223","3400253","3116554","3023156","5324564","6344620","0145111","2060052"}

    Returns: 312

  64. {"2220430","5523425","3562511","0411564","4433160","6310213","5464253","6600601"}

    Returns: 19

  65. {"4340414","5200454","5550210","1333302","2311220","3551656","2462361","6646016"}

    Returns: 216

  66. {"6562141","2322003","0124663","2145043","0546301","6061251","5544634","5315023"}

    Returns: 112

  67. {"1140150","6555521","3222306","0560341","4645366","4200316","4162531","4420332"}

    Returns: 26

  68. {"5455034","6646520","3314111","5321060","6351002","2256054","4362022","3116443"}

    Returns: 276

  69. {"6662226","0200640","4240446","5205545","5516120","1451111","6332033","5331334"}

    Returns: 360

  70. {"0020224","2444050","5245550","6264566","6630233","3563334","1021411","6113115"}

    Returns: 4416

  71. {"2262662","6333243","4634442","5635455","5520060","4005003","2116134","5110111"}

    Returns: 720

  72. {"0003330","3111401","4341440","6316466","6602231","2462222","5035155","5652554"}

    Returns: 768

  73. {"4443334","3222412","3121116","6326614","6654535","1556552","4003200","0605001"}

    Returns: 864

  74. {"0020220","5255305","3253331","1251310","1140424","4314445","0626566","1646663"}

    Returns: 534

  75. {"5515115","0100650","1606664","1440465","4453130","6343333","5221206","2423222"}

    Returns: 840

  76. {"1116661","6444014","6040005","6554051","5512262","2052224","3136433","5323330"}

    Returns: 2250

  77. {"5505004","4044255","2024225","0334233","3315011","2113114","6506646","6361662"}

    Returns: 648

  78. {"0566412","3365151","3555404","3236262","4522034","0161434","0631022","0046115"}

    Returns: 72

  79. {"1651002","1312013","3452022","6314662","4424642","3304566","5303061","5455501"}

    Returns: 288

  80. {"1255442","3450350","4620634","0520634","1621503","6211232","5144036","1016653"}

    Returns: 160

  81. {"2663550","0040454","6503133","5156635","1211502","1243216","6441304","6232204"}

    Returns: 12

  82. {"0336664","0030360","4641164","3440311","1035415","1556555","0322222","2264152"}

    Returns: 864

  83. {"3115153","3313552","1226156","2523662","6315060","6000200","4454404","3142644"}

    Returns: 5508

  84. {"0224440","0020245","5450115","2551241","1023533","1334313","6246166","0665636"}

    Returns: 12636

  85. {"6112223","6616126","3235523","1336155","5002300","5610050","6143544","4424404"}

    Returns: 2160

  86. {"5112220","5515125","1205320","0003133","3562036","3616666","5424364","4140444"}

    Returns: 4320

  87. {"4552224","4454523","5234521","3331113","1450300","1002010","6623106","4566666"}

    Returns: 912

  88. {"1143435","1441331","5351030","4550405","0242202","0123522","6666026","1435666"}

    Returns: 6048

  89. {"4426661","4224264","2613231","1114363","3400000","3026130","5265355","4551505"}

    Returns: 3840

  90. {"0113335","0010130","5552222","1350135","2444444","2013524","6666666","0135246"}

    Returns: 72

  91. {"1064354","2030324","2261350","3211145","3031056","4346410","2266545","5526601"}

    Returns: 45

  92. {"3103266","6433545","3530452","1164554","0424156","1015206","6201233","2201064"}

    Returns: 2

  93. {"1125321","2632443","5402460","0302050","1401253","3445514","3606152","1653666"}

    Returns: 2

  94. {"5414320","6436623","3201421","0012034","6553534","4626510","5042616","2301155"}

    Returns: 2

  95. {"5420415","5431514","4333652","6566422","1003460","0361021","6252653","1421300"}

    Returns: 2

  96. {"1660635","1253652","1041324","2053264","4003614","1542064","0555236","1431203"}

    Returns: 55

  97. {"0033665","4254160","2201125","3112363","2350040","4351612","0445645","4152636"}

    Returns: 2

  98. {"1012426", "2316351", "2014044", "6655013", "4306033", "4554043", "2526155", "1662320"}

    Returns: 2

  99. {"2045563","2060620","1016214","1445342","4033115","6641565","6333022","4531205"}

    Returns: 1

  100. {"1312426", "2316351", "2014044", "6655013", "4306030", "4554043", "2526155", "1662320"}

    Returns: 0

  101. {"0433665", "0254160", "2201125", "3112363", "2350040", "4351612", "0445645", "4152636"}

    Returns: 1


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: