A higher resolution is required to access the IDE
- 52
Statement
Goal
Mahjong is a tabletop game played using tiles. It features three "number" suits (pins, sous, mans, represented ashttps://user-images.githubusercontent.com/5595067/33491135-4ac4b4e6-d6f4-11e7-8df6-038f113fcef9.png
To complete a hand and win, the 13 tiles in your hand are combined with 1 newly drawn tile and must result in one of the following winning configurations:
• 4 sets and 1 pair, self-explanatory
• seven pairs, where all pairs are distinct (twice the same pair wouldn't qualify)
• kokushi musou: one of each of the
A pair is any of the two same tiles:
A set consists of 3 tiles of the same suit. It can either be a run: 3 number tiles (
So honor tiles (non-numbers, represented by
A single tile can only be counted as part of one set or pair: there is no sharing or reusing.
Given a sorted hand of
Input
Line 1: A sequence of numbers and letters, Space , a tile of a number and a letter
In the notation, the numeric value of every tile in a suit comes first, then the suit's letter. Tiles are grouped per suit, so each letters is written at most once. The three numbers suits are ordered fromm to p to s and consist of ranks 1 to 9 . The honor suit orders last, is represented as z and consists of seven tiles from 1 to 7 .
As you may have gathered from the statement, in this puzzle the honor suit's tiles are represented as digits for ease of parsing and distinction, but they do not behave like numbers.
In the notation, the numeric value of every tile in a suit comes first, then the suit's letter. Tiles are grouped per suit, so each letters is written at most once. The three numbers suits are ordered from
As you may have gathered from the statement, in this puzzle the honor suit's tiles are represented as digits for ease of parsing and distinction, but they do not behave like numbers.
Output
Line 1: TRUE if and only if it is a match, otherwise FALSE .
Constraints
14 ≤ length of sequence ≤ 17
length of tile = 2
length of tile = 2
Example
Input
222888m444p2277z 7z
Output
TRUE
A higher resolution is required to access the IDE