Problem Statement
For example, a card with one solid blue diamond, a card with two solid green diamonds, and a card with three solid red diamonds all form a set. The symbols on each card have the same shape and the same shading, and none of the cards has the same number or the same color. Any two cards will form a set with exactly one other card. You want to know, given two cards, what is the other card that completes the set. Create a class Matching with a method findMatch that takes two
first and second will both contain exactly four elements. The first element of each will denote the shape of the symbols on the card and will be either "CIRCLE", "SQUIGGLE", or "DIAMOND". The second element will denote the color and will be either "RED", "BLUE", or "GREEN". The third element of each will denote the shading and will be either "SOLID", "STRIPED", or "EMPTY". The fourth element of each will denote the number of symbols, and will be either "ONE", "TWO", or "THREE". The return element should contain exactly four elements, and should follow the same format as the input.
Definition
- Class:
- Matching
- Method:
- findMatch
- Parameters:
- String[], String[]
- Returns:
- String[]
- Method signature:
- String[] findMatch(String[] first, String[] second)
- (be sure your method is public)
Constraints
- first and second will both contain exactly four elements.
- The first element of first and second will be either "CIRCLE", "SQUIGGLE", or "DIAMOND".
- The second element of first and second will be either "RED", "BLUE", or "GREEN".
- The third element of first and second will be either "SOLID", "STRIPED", or "EMPTY".
- The fourth element of first and second will be either "ONE", "TWO", or "THREE".
Examples
{"DIAMOND","BLUE","SOLID","ONE"}
{"DIAMOND","GREEN","SOLID","TWO"}
Returns: { "DIAMOND", "RED", "SOLID", "THREE" }
The example from above.
{"CIRCLE","RED","SOLID","TWO"}
{"SQUIGGLE","GREEN","EMPTY","TWO"}
Returns: { "DIAMOND", "BLUE", "STRIPED", "TWO" }
{"CIRCLE","RED","STRIPED","TWO"}
{"CIRCLE","RED","EMPTY","TWO"}
Returns: { "CIRCLE", "RED", "SOLID", "TWO" }
{"DIAMOND","BLUE","SOLID","TWO"}
{"SQUIGGLE","GREEN","SOLID","TWO"}
Returns: { "CIRCLE", "RED", "SOLID", "TWO" }
{"CIRCLE","GREEN","EMPTY","TWO"}
{"CIRCLE","RED","STRIPED","TWO"}
Returns: { "CIRCLE", "BLUE", "SOLID", "TWO" }
{"CIRCLE","GREEN","EMPTY","TWO"}
{"DIAMOND","BLUE","STRIPED","ONE"}
Returns: { "SQUIGGLE", "RED", "SOLID", "THREE" }
All four characteristics are different on these two cards, so all four characteristics will be different on the third card in the set.
{"DIAMOND","BLUE","SOLID","ONE"}
{"SQUIGGLE","BLUE","EMPTY","TWO"}
Returns: { "CIRCLE", "BLUE", "STRIPED", "THREE" }
{"DIAMOND","BLUE","SOLID","ONE"}
{"SQUIGGLE","BLUE","STRIPED","TWO"}
Returns: { "CIRCLE", "BLUE", "EMPTY", "THREE" }
{"DIAMOND","BLUE","SOLID","ONE"}
{"SQUIGGLE","GREEN","STRIPED","TWO"}
Returns: { "CIRCLE", "RED", "EMPTY", "THREE" }
{"DIAMOND","BLUE","SOLID","ONE"}
{"SQUIGGLE","RED","SOLID","TWO"}
Returns: { "CIRCLE", "GREEN", "SOLID", "THREE" }
{"DIAMOND","BLUE","SOLID","TWO"}
{"SQUIGGLE","GREEN","SOLID","TWO"}
Returns: { "CIRCLE", "RED", "SOLID", "TWO" }
{"DIAMOND","GREEN","EMPTY","TWO"}
{"DIAMOND","RED","STRIPED","TWO"}
Returns: { "DIAMOND", "BLUE", "SOLID", "TWO" }
{"DIAMOND","GREEN","SOLID","TWO"}
{"SQUIGGLE","GREEN","SOLID","TWO"}
Returns: { "CIRCLE", "GREEN", "SOLID", "TWO" }
{"DIAMOND","GREEN","STRIPED","ONE"}
{"DIAMOND","RED","SOLID","TWO"}
Returns: { "DIAMOND", "BLUE", "EMPTY", "THREE" }
{"DIAMOND","RED","EMPTY","TWO"}
{"CIRCLE","RED","SOLID","TWO"}
Returns: { "SQUIGGLE", "RED", "STRIPED", "TWO" }
{"DIAMOND","RED","SOLID","ONE"}
{"SQUIGGLE","BLUE","EMPTY","ONE"}
Returns: { "CIRCLE", "GREEN", "STRIPED", "ONE" }
{"DIAMOND","RED","SOLID","ONE"}
{"SQUIGGLE","GREEN","SOLID","ONE"}
Returns: { "CIRCLE", "BLUE", "SOLID", "ONE" }
{"DIAMOND","RED","SOLID","TWO"}
{"DIAMOND","BLUE","EMPTY","ONE"}
Returns: { "DIAMOND", "GREEN", "STRIPED", "THREE" }
{"DIAMOND","RED","SOLID","ONE"}
{"SQUIGGLE","BLUE","SOLID","TWO"}
Returns: { "CIRCLE", "GREEN", "SOLID", "THREE" }
The only characteristic that is the same for all the cards in this set is that they are all solid.
{"DIAMOND","RED","STRIPED","ONE"}
{"SQUIGGLE","BLUE","STRIPED","TWO"}
Returns: { "CIRCLE", "GREEN", "STRIPED", "THREE" }
{"SQUIGGLE","BLUE","SOLID","TWO"}
{"SQUIGGLE","GREEN","SOLID","TWO"}
Returns: { "SQUIGGLE", "RED", "SOLID", "TWO" }
{"SQUIGGLE","BLUE","STRIPED","TWO"}
{"DIAMOND","RED","EMPTY","ONE"}
Returns: { "CIRCLE", "GREEN", "SOLID", "THREE" }
{"SQUIGGLE","RED","SOLID","TWO"}
{"DIAMOND","BLUE","STRIPED","ONE"}
Returns: { "CIRCLE", "GREEN", "EMPTY", "THREE" }
{"SQUIGGLE","RED","STRIPED","ONE"}
{"SQUIGGLE","RED","STRIPED","ONE"}
Returns: { "SQUIGGLE", "RED", "STRIPED", "ONE" }
{ "SQUIGGLE", "RED", "STRIPED", "ONE" }
{ "SQUIGGLE", "RED", "STRIPED", "ONE" }
Returns: { "SQUIGGLE", "RED", "STRIPED", "ONE" }
{ "CIRCLE", "GREEN", "EMPTY", "TWO" }
{ "DIAMOND", "BLUE", "STRIPED", "ONE" }
Returns: { "SQUIGGLE", "RED", "SOLID", "THREE" }
{ "DIAMOND", "BLUE", "SOLID", "ONE" }
{ "DIAMOND", "GREEN", "SOLID", "TWO" }
Returns: { "DIAMOND", "RED", "SOLID", "THREE" }
{ "DIAMOND", "GREEN", "SOLID", "ONE" }
{ "DIAMOND", "BLUE", "SOLID", "TWO" }
Returns: { "DIAMOND", "RED", "SOLID", "THREE" }
{ "SQUIGGLE", "BLUE", "STRIPED", "TWO" }
{ "SQUIGGLE", "BLUE", "SOLID", "TWO" }
Returns: { "SQUIGGLE", "BLUE", "EMPTY", "TWO" }