Mahjong winning hand Validation #1: DA SI XI(大四喜)
Description:
Mahjong Knowledge
Mahjong
is based on draw-and-discard card games that were popular in 18th and 19th century China and some are still popular today.
In each deck, there are three different suits numbered 1 to 9, which are called Simple tiles. They are Circles (denoted by [1-9]p
), Bamboo (denoted by [1-9]s
), and Characters (denoted by [1-9]m
).
Circles: |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Bamboo: |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Characters: |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Moreover, there is another suit named Honor tiles. It includes Wind tiles (namely East, South, West, North, denoted by [1-4]z
) and Dragon tiles (namely Red, Green, White, denoted by [5-7]z
).
East Wind | South Wind | West Wind | North Wind |
![]() |
![]() |
![]() |
![]() |
Red Dragon | Green Dragon | White Dragon |
![]() |
![]() |
![]() |
Note that there are EXACTLY 4 identical copies of each kind of tiles in a deck.
How to win the game of mahjong
A regular winning hand consists of 4 Melds and 1 Pair. Each meld of tiles can be 3 identical or consecutive tiles of a suit. For example:
3 identical tiles | 3 consecutive tiles |
![]() ![]() ![]() |
![]() ![]() ![]() |
Note that the Honor tiles ([1-7]z
, winds and dragons) can ONLY be combined to a meld of 3 identical tiles
.
A winning combination of mahjong pieces:
![]() ![]() ![]() └────┴────┘
meld 1 |
![]() ![]() ![]() └────┴────┘
meld 2 |
![]() ![]() ![]() └────┴────┘
meld 3 |
![]() ![]() ![]() └────┴────┘
meld 4 |
![]() ![]() └───┘
pair 1 |
Task
Your task is to verify that a mahjong combination is correct. The mahjong combination is: DA SI XI(大四喜,Four wind happiness).
Rules:
The combination of mahjong pieces must contains three 1z
(east wind), three 2z
(south wind), three 3z
(west wind), three 4z
(north wind)












1z 1z 1z 2z 2z 2z 3z 3z 3z 4z 4z 4z
The rest pieces is a pair of any other pieces.


Input
- A string denoting 14 tiles to be computed.
The order of the Mahjong pieces always be:"2s 2s 1z 1z 1z 2z 2z 2z 3z 3z 3z 4z 4z 4z"
p-->s-->m-->z
and1--->9
Output
- A boolean value. If the input string is a valid winning hand of "DA SI XI", return
true
; If not, returnfalse
.
Series
Similar Kata:
Stats:
Created | Jul 9, 2016 |
Published | Jul 9, 2016 |
Warriors Trained | 198 |
Total Skips | 30 |
Total Code Submissions | 169 |
Total Times Completed | 58 |
JavaScript Completions | 54 |
Python Completions | 8 |
Total Stars | 4 |
% of votes with a positive feedback rating | 95% of 29 |
Total "Very Satisfied" Votes | 26 |
Total "Somewhat Satisfied" Votes | 3 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 4 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 7 kyu |