T.T.T.24: Chinese surname (《百家姓》)
Description:
Story
Chinese people have a lot of surnames. In ancient China, there is a children's book, called 《百家姓》(Hundred Family Surnames). Of course, this book contains not just one hundred surnames, but a total of 504 surnames, which are the most common surnames in China.
In ancient times, Chinese children learn by reciting the book. They recite the book like a poem:
赵钱孙李,周吴郑王。
冯陈褚卫,蒋沈韩杨。
.......
.......
Some of the children to show that they are smarter, they will recite the book in reverse:
......
......
杨韩沈蒋,卫褚陈冯。
王郑吴周,李孙钱赵。
Task
Complete the function that accepts a string surnames
which contains some surnames, you should reverse them and return a string in accordance with the following rules.
Rules
The output string should add a Chinese comma
","
in the back of the 4th Chinese characters, and adding a Chinese period"。"
in the back of the 8th Chinese characters."赵钱孙李周吴郑王" // ---reverse the order and add comma and period--- // should return "王郑吴周,李孙钱赵。"
Most of the Chinese people's surnames are 1 Chinese character, but there are a few people whose surnames are 2 Chinese characters. The surname of 2 Chinese characters should be read as a whole and not be reversed. All of these special surnames have been saved in the variable
special
(already preloaded)."万俟司马上官欧阳" // 万俟,司马,上官,欧阳 are special surnames // ---reverse the order and add comma and period--- // should return "欧阳上官,司马万俟。"
If there are multiple matches, you should group the earliest appearances of special surnames first.
If the string length is more than 8, it needs to be split into multiple lines. You can assume that all the string parameters are multiples of 8.
"赵钱孙李周吴郑王冯陈褚卫蒋沈韩杨" // ---reverse the order and add comma and period--- // should return "杨韩沈蒋,卫褚陈冯。\n王郑吴周,李孙钱赵。"
Similar Kata:
Stats:
Created | Aug 9, 2016 |
Published | Aug 9, 2016 |
Warriors Trained | 200 |
Total Skips | 2 |
Total Code Submissions | 330 |
Total Times Completed | 67 |
JavaScript Completions | 67 |
Total Stars | 9 |
% of votes with a positive feedback rating | 94% of 24 |
Total "Very Satisfied" Votes | 21 |
Total "Somewhat Satisfied" Votes | 3 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 6 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 7 kyu |