Coding Challenge #2

In this second coding challenge, you will be attempting to solve one of the problems from TeamsCode’s Spring 2017 MIHS Programming Contest. This challenge requires you to make proper use of arrays, and while separating your code into different methods is not required, it is encouraged to help you keep your code clean and easy to read.

In a game of Texas Hold’em poker, your goal is to find the highest pair or triple you can get in a hand of seven cards. Assume that 2 is the lowest card and Ace is the highest. If you encounter a quadruple, treat it as if it is a triple.

Input:

You will be using a Scanner to read input from a text file. The first line in the text file represents how many more lines will follow. Each following line contains a sequence of seven cards, each card separated by a space. Note that the face cards will be represented by the following characters:

A - Ace
K - King
Q - Queen
J - Jack

Output:

For each hand, print to the console the highest pair, or triple, if it exists, from the seven cards.

Example Input:

2 10 10 9 9 A J K
Q 2 J Q J Q A

Example Output:

10 10
Q Q Q

Here is a link to the problem pdf. If you would like to download the input files for this problem, you can find them here.

Good luck!

Written by Alan Bi

Notice any mistakes? Please email us at [email protected] so that we can fix any inaccuracies.