Statistics

Problem Statement for "Triominoes"

Problem Statement

The problem statement contains images best viewed in the applet.

Triominoes is a game similar to dominoes. The game pieces are equilateral triangles with a number between 0 and 6, inclusive, in each vertex. When pieces are played, each pair of vertices from different triangles that touch each other must contain the same number.

An important part of the game is making regular hexagons, each consisting of six pieces. In each hexagon, six vertices from six triangles meet at the center, and those six vertices contain the same number. At each vertex of the hexagon, two vertices from adjacent triangles touch each other, and those two vertices contain the same number.

You will be given a String[] pieces containing a set of triomino pieces and you must return the number of different hexagons that can be formed with that set. Each element of pieces will be formatted "XYZ" (quotes for clarity) where X, Y and Z are the numbers in the vertices of a single piece in clockwise order. Pieces can be rotated but not flipped. For example, pieces "123" and "312" are the same, but they are different from "321". Two hexagons are considered the same if one can be rotated to look exactly like the other. See examples for further clarification.

Definition

Class:
Triominoes
Method:
countHexagons
Parameters:
String[]
Returns:
int
Method signature:
int countHexagons(String[] pieces)
(be sure your method is public)

Constraints

  • pieces will contain between 1 and 50 elements, inclusive.
  • Each element of pieces will contain exactly 3 characters.
  • Each character of each element of pieces will be a digit between '0' and '6', inclusive.
  • No two elements of pieces will represent the same piece.

Examples

  1. {"613","153","354","443","663","634"}

    Returns: 1

  2. {"666"}

    Returns: 0

  3. {"012"}

    Returns: 0

  4. {"000","111","222","333","444","555","666"}

    Returns: 0

    There's no way to make two pieces fit in this case, and therefore, there is no possible way to construct a hexagon.

  5. {"000"}

    Returns: 0

  6. {"531","444","500","144","554","355","521","001","642","324","464","623","663","646","334","013","250","550","114","136","504","143","610","103","615","121","203","533","606","354","341","202","223","060","515","556","331","605","520","365","350","242","316","065","513","302","021","516","265","231"}

    Returns: 542

  7. {"013","615","061","325","542","332","502","335","151","362","221","640","611","566","032","144","550","342","564","661","433","101","123","000","412","201","042","530","360","100","453","466","164","613","121","506","200","304","165","235","313","551","546","131","224","600","514","114","143","620"}

    Returns: 307

  8. {"332","120","333","133","033","122","003","121","000","111","200","301","113","123","011","203","321","022","210","222","223","230","031","010"}

    Returns: 536

  9. {"044","444","143","042","214","201","144","411","401","221","403","230","033","041","400","341","232","110","231","334","321","423","443","121","210","032","000","010","333","244","324","402","022","111","031","331","301","300","222","241","002","113","233","242","043"}

    Returns: 4880

  10. {"201","111","230","320","304","002","214","123","130","334","210","202","004","222","412","000","034","422","443","213","234","442","414","131","110","322","014","411","324","341","444","440","332","001","024","310","300","303","112","133","143","204","041"}

    Returns: 4154

  11. {"211","311","340","040","304","424","324","312","003","322","343","044","024","203","342","434","310","000","134","420","224"}

    Returns: 139

  12. {"062","026","063","036","064","046"}

    Returns: 4

    Note that it is possible to build more than 1 hexagon with the same set of 6 pieces.

  13. {"203","312","324","230","110","331","314","213","442","423","130","001","022","421","402","140","222","141","033","020","041","430","332","443","212","403","131","241","440","210"}

    Returns: 451

  14. {"312","001","143","121","103","040","341","301","403"}

    Returns: 0

  15. {"312","034","342","110","240","301","104","120","332","111","320","420","144","232","221","400","424","444","142","222","140","131","220","330","021","430","422","313","443","243","302","310","314","114","044","020","241","030","341"}

    Returns: 2515

  16. {"301","230","444","014","400","243","300","322","210","331","443","132","032","034","002","422","311","010","332","000","342","114","441","231","222","333","404","420","110","214","303","041","121","031","431","343","022","430","341","244","241","212","201"}

    Returns: 3869

  17. {"130","634","220"}

    Returns: 0

  18. {"241","525","562","135","045","323","364","544","012","623","154","226","421","531","105","040","346","223","626","110","340","432","300","534","613","115","306","422","016","021","666","435","220","360","443","401","424","031"}

    Returns: 99

  19. {"200","565","515","220","106","305","621","433","113","412","165","042","104","601","133"}

    Returns: 0

  20. {"361","344","041","653","265","101","213","630","155","454","164","054","212","601","550","312","105","356","546","414","130","145","244","036","124","340","615","531","645","504","165","133","661","643","524","565","362","032","430","302","636","632","500"}

    Returns: 278

  21. {"520","214","320","025","533","541","332","546","303","662","641","022","265","663","346","611","035","656","354","554","433","046","410","434","124","131","165","423","413","440","431","312"}

    Returns: 22

  22. {"521","353","144","362","315","344","515","230","610","301","026","351","253","111","150","120","143","065","021","514","240","060","136","465","543","366","562","243"}

    Returns: 3

  23. {"535","655","114","333","100","023","234","265","440","645","363","614","012","133","122","051","031","042","455","266","433","622","516","004","450","366","422","605","434","513","164","145","200","211","551","436","304","352","360","530","505","350","206","335"}

    Returns: 74

  24. {"203","255","002","422","336","621","123","521","624","145","112","361","502","244","026","205","654","634","024","256","406","220","264","601","500","542","120","126","421","000","615","536","345","655"}

    Returns: 200

  25. {"616","660","332","124","345","546","046","620","113","061","201","400","646","246","000","463"}

    Returns: 0

  26. {"141","616","330","523","334","321","651","420","123","003","356","100","236","440","125","160"}

    Returns: 0

  27. {"364","203","331","042","111","422","262","264","055","350","205","062","602","253","624"}

    Returns: 2

  28. {"420","302","601","064","660","353","540","031","622","242", "112","265","424","044","004","200","421","602","445","123"}

    Returns: 6

  29. {"041","364","165","632","515","223","466","613","035","540","633","045","611","343","533","214","631","301","314","624"}

    Returns: 4

  30. {"422","143","323","020","624","551","234","521","660","133","156","665","403","613","554","161","336","055","150","223"}

    Returns: 1

  31. {"510","241","604","414","521","600","024","335","022","406","540","351","210","514","142","630","206","204","551","530"}

    Returns: 2

  32. {"446","332","445","111","040","354","631","635","550","263", "036","060","156","325","016","140","510","241","146","650"}

    Returns: 1

  33. {"341","463","502","355","252","354","226","540","120","062","555","165","434","304","662","042","105","040","111","442","521","523","060","656","551","033","245","024","503","146","231","230","542","326","046","265","113","264","102","050","106","362","641","232","450","514","044","022","301","052"}

    Returns: 552

  34. {"442","211","143","025","162","435","140","503","412","005","653","215","642","532","154","564","340","065","323","451","222","064","066","161","200","234","665","534","560","015","010","355","641","445","036","433","516","551","023","251","363","404","236"}

    Returns: 97

  35. {"540","002","116","055","234","624","634","614","605","314","364","022","556","240","162","063","366","552","443","113","664","615","454","545","336","411","564","414","501","313","350"}

    Returns: 18

  36. {"064","431","233","203","240","651","660","543","460","110","255","060","544","623","466","231","520","063","166","251","161","040","132","405","226","602","200","345","455","432","051"}

    Returns: 22

  37. {"505","412","122","623","223","021","616","115","445","450","646","432","563","121","524","013","240","002","443","403","313","555","206","113","352","314","165","515","425","660","260","342","325"}

    Returns: 22

  38. {"052","613","414","524","354","261","453","633","450","212","540","654","636","022","523","412","163","206","332","446","161","066","635","145","426","044","350","355","006","216","256","014","210","400","111","001","443","630","201","246","425","604","322","650","000","304","024","561","551","253"}

    Returns: 391

  39. {"210","206","402","333","045","454","525","332","154","636","040","355","132","622","203","051","241","155","022","440","251","261","016","353","260","204","033","542","662","545","253","654"}

    Returns: 24

  40. {"660","231","355","523","325","416","642","545","210","433","514","111","326","400","115","313","120","562","130","234","156","211","646","251","611","650","556","600","052","403","105","536","163","501","661","324","154","364","411","332","140","011","555","414","305"}

    Returns: 298

  41. {"540","002","634","362","642","633","231","513","126","222","115","566","600","561","543","203","520","165","645","401","124","353","040","130","413","424","611","443","235","303","522","345","012","142","546","653","021","430","030","051","451","340","560","425","644","666","226","212"}

    Returns: 191

  42. {"366","406","601","523","023","234","124","030","151","346","435","242","560","116","244","410","462","255","443","164","163","010","521","102","140","304","555","301","251","516","464","536","321","402","425","500","454","455","330","603","562","265","143","062","220"}

    Returns: 162

  43. {"356","414","124","135","016","121","636","253","062","653","131","301","314","631","220","302","331","321","014","632","463","250","212","004","114","514","445","462","105","210","344","422","405","233","044","036","664","322","214","166","164","413","006","564","442","611","200","626","251","236"}

    Returns: 471

  44. {"506","420","001","064","655","564","253","502","112","361","111","021","444","155","636","633","031","606","362","303","213","304","012"}

    Returns: 1

  45. {"555","111","205","461","551","452","060","311","642","254","252","122","453","054","646","560","315","562","243","044","601","521","645","251","446","341","046","003","102","622","156","403","322"}

    Returns: 27

  46. {"065","326","363","630","341","060","234","443","642","116","466","534","101","610","225","214","053","260","626","605","566","102","000","352","612","335","666","251","502","651","246","146"}

    Returns: 22

  47. {"213","424","056","614","425","506","651","644","131","155","645","341","455","062","514","230","401","441","411","053","016","031","436","500","423","043","106","350","535","054","204"}

    Returns: 46

  48. {"562","342","226","301","242","145","356","225","651","531","432","033","202","223","502","054","441","454","124","140","005","323","434","142","660","626","221","611","556","021","056","363","034","215","503","246","141","024","123","553","466","201","364","644","545","614","204","456","320","325"}

    Returns: 577

  49. {"341","611","546","543","656","335","443","033","046","016","140","120","324","025","515","166","651","501","223","151","614","346","022","542","554","603","251","021","164","522","421","500","135","060","521","532","426","204","412","530","111"}

    Returns: 85

  50. {"320","601","430","231","630","465","062","310","454","143","242","611","606","045","056","364","442","363","151","214","220","532","564","124","132","531","640","333","345","513","403","545","233","464","120","106","352","400","426","444","033","506","006"}

    Returns: 134

  51. {"651","631","341","455","033","236","030","542","014","150","544","245","531","530","302","123","326","321","232","055","641","120","346","026","543","630","243","214","444","210","116","500","032","442","010","604","202","335","105","216"}

    Returns: 158

  52. {"660","010","363","353","322","330","626","031","104","163","065","052","060","511","442","202","651","046","443","036","206","525","252","541","466","105","616","524","562","340","325","546","016","024","003","263"}

    Returns: 38

  53. {"562","322","422","221","626","222","121","325","204","432","213","025","542","236","265","201","233","245","522","052","261","442","206","352","020","342","462","021","022","552","521","162","032","512","602","023","263","142","231","226","264","402","412"}

    Returns: 12130

  54. {"422","244","042","514","404","564","243","524","466","045","446","401","154","414","461","344","604","141","425","134","444","164","534"}

    Returns: 254

  55. {"215","222","342","213","424","256","425","122","642","452","142","302","420","225","200","121","612","242","232","124","626","622"}

    Returns: 287

  56. {"232","231","103","323","030","134","023","356","136","344","243","343","035","352","643","534","333","163","430","130","463","435","536","253","303","366","263","353","336","423","135","236","320","315","113"}

    Returns: 3291

  57. {"111","112","125","154","143","113"}

    Returns: 1

    Don't count rotated triples more than once!

  58. {"133","052","303","562","203","325","653","251","200","204","113","433","410","065","600","505","541","160","233","346","513","245","355","554","501","304","161","603","144","356","255","614","234","031","266","466","540","040","443","062","350","066","312","460","654","164","063","555","215","023"}

    Returns: 446

  59. {"234","512","641","011","333","566","345","330","035","120","320","240","530","420","355","154","040","442","405","556","364","025","644","311","215","434","112","103","343","236","412","021","135"}

    Returns: 43

  60. {"600","432","223","302","621","400","265","141","250","043","111","123","163","030","136","263","061","614","315","454","401","660","121","125","130","015","503","601","100","662","414","413","200","464","212","511","434","240","245","313","340","052","405","456"}

    Returns: 187

  61. {"116","326","500","045","062","431","104","016","103","110","233","400","625","462","252","033","464","543","356","145","200","334","065","124","615","565","355","226","106","302","602","434","341","243","502","312","042","530","346","014","544","603","604","540","304","306"}

    Returns: 331

  62. {"112","642","516","061","430","612","344","530","413","456","054","410","406","505","444","160","310","323","616","620","105","463","626","605","262","462","250","663","021","123","155","350","151","263","330","131","451","425","455","445","136","650","150","140","450"}

    Returns: 458

  63. {"436","600","111","146","424","535","021","116","331","335","463","426","513","616","636","456","263","321","123","635","225","610","651","536","112","562","260","240","421","241","115","523","545","343","046","646","654","403","054","221","506","566","164","136","160","202","330","420","551","431"}

    Returns: 717

  64. {"632","012","130","653","354","261","216","502","212","312","655","323","422","202","252","313","532","661","426","154","200","024","241","620","342","125","646","001","623"}

    Returns: 63

  65. {"314","410","332","424","622","046","250","601","214","343","346","166","363","360","304","614","003","546","524","110","311","451","354","432","124","321","134","504","365","531","152","021","330","641","600","462","156","202","443","513","511"}

    Returns: 148

  66. {"650","034","325","346","230","362","550","240","522","625","320","001","460","255","052","665","231","434","030","420","051","423","441","040","306","543","041","406","644"}

    Returns: 34

  67. {"432","323","115","253","560","122","533","431","264","162","652","222","351","031","463","364","313","226","452","444","360","640","302","215","631","330","124"}

    Returns: 10

  68. {"424","320","303","325","045","035","352","322","542","224","530","400","440","420","555","524","435","022","345","552","544","055","000","545","302","003","043","002","402","025","434","432","034","052","333","234","252","335","444","005","233","343","540","222","535"}

    Returns: 4880

  69. {"015","005","010","505","555","051","551","111","110","000","115"}

    Returns: 6

  70. {"533","333","355","513","111","315","133","551","131","511","555"}

    Returns: 6

  71. {"224","545","312","212","564","663","533","144","561","616","354","164","214","263","132","246","525","614","233","432","666","513","226","152","261","433","155","611","254","131","644","512","256","313","466","655","136","265","112","165","266"}

    Returns: 678

  72. {"344","004","410","662","161","210","311","603","061","333","666","200","402","343","140","460","230","126","206","310","331","301","144","134","263","461","246","421","224","416","233","440","464","012","101","262","033","204","430","060","236","162","026","346","606","321","122","613","633","424"}

    Returns: 1559

  73. {"642","220","201","000","401","262","104","606","164","026","246","662","446","126","400","616","146","021","160","414","042","110","444","421","402","222","112","640","224","020","212","666","062","162","664","111","106","046","412","141","600","611","440","424","100"}

    Returns: 4880

  74. {"453","354","333","444","313","515","555","513","111","113","153","353","314","151","343","443","145","554","355","544","411","144","415","341"}

    Returns: 536

  75. {"150","005","555","210","250","000","520","215","151","011","002","225","055","212","551","111","100","222","022","512","211","120","105","255"}

    Returns: 536

  76. {"222","432","421","633","246","311","442","626","342","213","636","162","112","622","316","231","444","164","212","642","634","332","161","223","361","114","333","616","443","412","433","446","263","666","143","331"}

    Returns: 1008

  77. {"413","225","620","334","634","350","065","565","532","112","415","622","514","364","203","561","610","600","002","455","605","241","202","026","246","122","450","265","512","051","310","630","632","611","231","626","135","066","344","536","631","661","215","501","250","136","113","544","442","531"}

    Returns: 522

  78. {"333","013","313","063","236","520","316","646","343","464","663","356","266","360","203","443","006","066","354","624","232","061","035","616","426","410","652","364","346","640","300","330","043","625","332","461","641","340","002","666","633","535","620","353","324","000","414","424","103","134"}

    Returns: 1912

  79. {"020","532","334","506","352","455","155","413","652","053","302","056","443","335","555","035","543","043","016","454","540","365","050","032","055","300","525","364","660","251","366","666","333","556","651","000","060","323","465","363","630","026","025","534","031","033","553","046","623","563"}

    Returns: 2249

  80. {"555","552","556","323","052","503","351","600","033","252","050","034","133","320","532","516","501","333","352","365","143","131","256","120","505","031","540","112","533","140","250","151","443","510","044","545","302","300","315","215","553","435","445","200","551","433","534","312","053","324"}

    Returns: 2811

  81. {"135","232","545","212","662","132","464","654","606","215","456","344","551","426","256","164","402","165","121","255","550","242","225","326","262","214","115","254","125","543","556","265","424","523","412","236","163","222","555","452","246","332","454","520","553","123","126","253","144","502"}

    Returns: 3455

  82. {"125","222","242","253","210","240","444","411","022","030","522","233","113","433","335","431","000","250","400","511","042","010","123","140","304","432","213","153","320","214","201","523","052","124","331","322","302","423","405","245","403","110","103","033","442","414","002","130","211","221"}

    Returns: 4319

  83. {"555","333","005","122","063","511","150","111","611","311","513","502","303","552","215","010","011","515","325","002","030","031","561","160","503","120","650","061","535","056","225","055","132","053","125","230","523","223","365","121","153","635","126","222","130","062","165","655","205","105"}

    Returns: 4020

  84. {"046","202","620","664","522","060","042","602","246","524","455","561","052","020","506","045","054","500","444","565","226","140","454","451","465","552","212","211","551","216","606","154","560","402","526","502","222","564","521","254","562","261","404","512","642","055","422","566","555","244"}

    Returns: 4547

  85. {"240","054","566","554","014","164","142","145","111","441","600","415","161","252","512","110","121","141","410","124","651","456","616","000","106","604","501","551","004","246","640","126","442","156","555","550","426","044","100","115","465","065","444","454","464","521","045","051","056","102"}

    Returns: 3600


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: