master

Card game

You will be building a program to play a card game. The objective of the game is to form a hand of three cards that for each of three different properties are either all the same or all different.

The properties of a card are:

  1. Prefix: “+”, “-”, or “=”
  2. Letter: “A”, “B”, or “C”
  3. Number of letters: 1, 2, or 3 (e.g. A, AA, AAA)

For example, given the following set of cards

-A -B -BB +C -C -CC =CCC

there are two possible hands:

  1. +C -CC =CCC
  • prefix: +,-,= are all different
  • letter: C, C, C are all the same
  • number of letters: 1, 2, 3 are all different
  1. -A -B -C
  • Prefix: -, -, - are all the same
  • Letter: A, B, C are all different
  • Number of letters: 1, 1, 1 are all the same

Specifications:

  • You only need to find one hand
  • The cards should be read from STDIN, each card is separated by a space
  • Print the hand you find to STDOUT, space separated (trailing space is ok)
  • Cards may appear in any order in the input
  • Cards may be output in any order