27
3
Suzhou numerals (蘇州碼子; also 花碼) are Chinese decimal numerals:
0 〇
1 〡 一
2 〢 二
3 〣 三
4 〤
5 〥
6 〦
7 〧
8 〨
9 〩
They pretty much work like Arabic numerals, except that when there are consecutive digits belonging to the set {1, 2, 3}
, the digits alternate between vertical stroke notation {〡,〢,〣}
and horizontal stroke notation {一,二,三}
to avoid ambiguity. The first digit of such a consecutive group is always written with vertical stroke notation.
The task is to convert a positive integer into Suzhou numerals.
Test cases
1 〡
11 〡一
25 〢〥
50 〥〇
99 〩〩
111 〡一〡
511 〥〡一
2018 〢〇〡〨
123321 〡二〣三〢一
1234321 〡二〣〤〣二〡
9876543210 〩〨〧〦〥〤〣二〡〇
Shortest code in bytes wins.
1I've been in Suzhou 3 times for longer period of time (quite a nice city) but didn't know about Suzhou numerals. You have my +1 – Thomas Weller – 2018-12-13T12:19:40.257
2@ThomasWeller For me it's the opposite: before writing this task I knew what the numerals were, but not that they were named "Suzhou numerals". In fact I've never heard them called this name (or any name at all). I've seen them in markets and on handwritten Chinese medicine prescriptions. – for Monica – 2018-12-13T13:51:53.637
Can you take input in the form of a char array? – Embodiment of Ignorance – 2018-12-13T16:46:23.530
@EmbodimentofIgnorance Yes. Well, enough people are taking string input anyway. – for Monica – 2018-12-15T07:26:34.987