Beta
Mahjong - #3 How far from winning
Description:
Mahjong Series
(If you do not know about how to win the game, click here for reference.)
Each player is dealt a hand of random tiles at the start of each Mahjong game. Sakura gets addictive to the game. After playing a few games, she learns that it is easier to win starting with a good hand, while harder starting with a bad one. Therefore, Sakura wonders how difficult it is to win with a certain hand. Now, she turns to you, an intelligent coder, for help.
Task
Given a hand of 14 tiles, work out the minimum number of tiles required to replace, for making up a winning hand. Only regular winning hands are considered in this kata.
Input
- A string denoting 14 tiles to be computed, in the order of Circles (
[1-9]p
), Bamboo ([1-9]s
), Characters ([1-9]m
), and Honors ([1-7]z
). The tiles are space-separated.
- A string denoting 14 tiles to be computed, in the order of Circles (
Output
- An integer.
Example
"3p 5p 2s 3s 4s 5s 5s 6m 8m 3z 3z 5z 6z 7z" => 3
One possible replacement:
("5z 6z 7z" -> "4p 7m 3z")
"3p 4p 5p 5p 5p 1s 2s 2s 3s 3s 4s 4z 4z 4z" => 0
Already winning. No need to replace any of the tiles.
Games
Logic
Algorithms
Similar Kata:
Stats:
Created | Jul 4, 2016 |
Published | Jul 4, 2016 |
Warriors Trained | 56 |
Total Skips | 1 |
Total Code Submissions | 84 |
Total Times Completed | 8 |
JavaScript Completions | 8 |
Total Stars | 4 |
% of votes with a positive feedback rating | 100% of 1 |
Total "Very Satisfied" Votes | 1 |
Total "Somewhat Satisfied" Votes | 0 |
Total "Not Satisfied" Votes | 0 |