For the best experience, increase the window size or view on a laptop or desktop device
Title | ||
|---|---|---|
Loading... | ||
For the best experience, increase the window size or view on a laptop or desktop device
Title | ||
|---|---|---|
Loading... | ||
You are provided with a set of cards characterized by suits (+, -, =), values (A, B, C), and counts of these values ranging from 1 to 3. Your goal is to identify a valid hand from the given cards. A valid hand consists of 3 cards where:
Example 1:
Input cards:
{ +AA, -AA, +AA, -C, -B, +AA, -AAA, -A, =AA }
Valid hands could be:
{ +AA, +AA, +AA }
Suit: Same [+ + +]
Value: Same [A A A]
Count: Same [2 2 2]
{ -A, -AA, -AAA }
Suit: Same [- - -]
Value: Same [A A A]
Count: Different [1 2 3]
{ -C, -B, -A }
Suit: Same [- - -]
Value: Different [C B A]
Count: Same [1 1 1]
{ +AA, -AA, =AA }
Suit: Different [+, -, =]
Value: Same [A A A]
Count: Same [2 2 2]
Example 2:
A valid hand can also be:
{ -A, +BB, =CCC }
Suit: Different [+, -, =]
Value: Different [A B C]
Count: Different [1 2 3]
Write a program to find and return the first valid hand from the provided list of cards. Input will be read from stdin.
For example, given the input:
+AA, -AA, +AA, -C, -B, +AA, -AAA, -A, =AA
Output any valid hand from this set.
You are provided with a set of cards characterized by suits (+, -, =), values (A, B, C), and counts of these values ranging from 1 to 3. Your goal is to identify a valid hand from the given cards. A valid hand consists of 3 cards where:
Example 1:
Input cards:
{ +AA, -AA, +AA, -C, -B, +AA, -AAA, -A, =AA }
Valid hands could be:
{ +AA, +AA, +AA }
Suit: Same [+ + +]
Value: Same [A A A]
Count: Same [2 2 2]
{ -A, -AA, -AAA }
Suit: Same [- - -]
Value: Same [A A A]
Count: Different [1 2 3]
{ -C, -B, -A }
Suit: Same [- - -]
Value: Different [C B A]
Count: Same [1 1 1]
{ +AA, -AA, =AA }
Suit: Different [+, -, =]
Value: Same [A A A]
Count: Same [2 2 2]
Example 2:
A valid hand can also be:
{ -A, +BB, =CCC }
Suit: Different [+, -, =]
Value: Different [A B C]
Count: Different [1 2 3]
Write a program to find and return the first valid hand from the provided list of cards. Input will be read from stdin.
For example, given the input:
+AA, -AA, +AA, -C, -B, +AA, -AAA, -A, =AA
Output any valid hand from this set.
Output