Players of the traditional board game Go measure their skill in a system of ranks:
- Players new to the game are ranked 30th kyū (written
30k) and progress counting down to 1st kyū (written1k). These are considered the student ranks. - A player may promote from 1st kyū to 1st dan rank (written
1d), and then progress counting up to 7th dan rank (written7d). These are the master ranks. - Exceptionally skilled players past
7dmay promote to the 1st professional dan rank1p, and progress counting up to 9th professional dan rank (written9p). This is the highest rank.
In short: ranks are ordered 30k < 29k < ··· < 1k < 1d < 2d < ··· < 7d < 1p < 2p < ··· < 9p.
Task
Given two strings among {30k, …, 1k, 1d, …, 7d, 1p, …, 9p} as input, output the higher rank of the two. (If they are equal, simply output either input.)
(As usual, I/O is flexible — your answer may be a function or a full program, reading input in any reasonable fashion and producing output in any reasonable fashion.)
This is code-golf: the objective is to minimize your code's byte count.
Test cases
(Format: input1 input2 output.)
29k 9k 9k 21k 27k 21k 6d 1p 1p 5d 17k 5d 1k 1d 1d 1d 1d 1d 1d 2d 2d 9p 1d 9p 2d 30k 2d 1p 1k 1p 1d 1p 1p 1p 2d 1p 7p 8p 8p 30k 30k 30k
4 kor4Kor so, either.) \$\endgroup\$30k,29k,1k,1det cetera, so I won't allow any variation there. \$\endgroup\$