Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA You are given seven hexagon tiles. Each tile has 6 colored segments. Colored segments can be any color from the following, R ed, B

JAVA

You are given seven hexagon tiles. Each tile has 6 colored segments.

image text in transcribed

Colored segments can be any color from the following, Red, Blue, Yellow, Green, Orange, Purple. Colors may also repeat on the same hexagon tile. The tiles themselves are also labeled 1 - 7.

You need to place the 7 hexagon tiles on a board such that the first hexagon is placed in the center, and the remaining 6 are placed going around the first. The trick is that adjacent segments of the hexagons must have the same color in order for the placement to be valid. Your program must use recursion to find a possible solution.

The program must read in a description of seven hexagons from a text file. Use a FileChooser the allow to user to select the input file. Each line of the file contains the hexagon tile number, followed by the colors of each segment. The colors are listed in clockwise order.

For example, the following would be an example of the user input for each hexagon in the above solution:

1 PPBGOY 2 GGGGGG 3 PPPPPP 4 ROYGBP 5 PROYGB 6 GOGYGB 7 BGPPOR

--------------

for example file read this

1 YBGROG 2 BRPRYO 3 ROPGPG 4 BBGBPG 5 YPGORP 6 GRBYOY 7 YGOBRR 

adn the solution would be

Solutions:

Solution Number: 1 Position 1: BRPRYO Position 2: PGBBGB Position 3: YOYGRB Position 4: GPGROP Position 5: ROGYBG Position 6: RYGOBR Position 7: PGORPY

Solution Number: 2 Position 1: OBRPRY Position 2: YPGORP Position 3: BPGBBG Position 4: BYOYGR Position 5: PGPGRO Position 6: GROGYB Position 7: RRYGOB

Solution Number: 3 Position 1: YOBRPR Position 2: BRRYGO Position 3: PYPGOR Position 4: GBPGBB Position 5: RBYOYG Position 6: OPGPGR Position 7: BGROGY

Solution Number: 4 Position 1: RYOBRP Position 2: YBGROG Position 3: OBRRYG Position 4: RPYPGO Position 5: BGBPGB Position 6: GRBYOY Position 7: ROPGPG

Solution Number: 5 Position 1: PRYOBR Position 2: GROPGP Position 3: GYBGRO Position 4: GOBRRY Position 5: ORPYPG Position 6: BBGBPG Position 7: YGRBYO

Solution Number: 6 Position 1: RPRYOB Position 2: OYGRBY Position 3: PGROPG Position 4: OGYBGR Position 5: YGOBRR Position 6: GORPYP Position 7: GBBGBP

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Databases With Application To GIS

Authors: Philippe Rigaux, Michel Scholl, Agnès Voisard

1st Edition

1558605886, 978-1558605886

More Books

Students also viewed these Databases questions

Question

Explain the function and purpose of the Job Level Table.

Answered: 1 week ago