Sino-Korean numerals

1

The Korean language has two sets of numerals, a native Korean numerals and Sino-Korean numerals.

The native Korean numerals are mostly used for numbers under 100, such as age and time.

The Sino-Korean numeral system, which is based on the Chinese numeral system as its name says, is used in most of the time.

It uses 4-digit group system rather than western 3-digit group system. For example, 123456789 can be grouped into 1, 2345, 6789 in Sino-Korean system.

All 4 digits in group have their own place names.

  • Thousands: 천
  • Hundreds: 백
  • Tens: 십
  • Ones: 일, but not used.

Also, for every 4 digits, suffixes are coming along with numbers.

  • 10^0: none, obviously.
  • 10^4: 만
  • 10^8: 억
  • 10^12: 조
  • 10^16: 경
  • 10^20: 해
  • ...

So, the number '123456789' in Sino-Korean is "일억 이천삼백사십사만 육천칠백팔십구".

Goal and Rules

Your goal is to convert given integer to Sino-Korean numeral.

  • Numbers are grouped into 4 digits from behind.
  • Whitespaces are inserted every 4 digits (from behind).

    4321 -> 사천삼백이십일
    30723231 -> 삼천칠십이만 삼천이백삼십일

  • '일'(1) is omitted except if it is last digit of its group.

    1111 -> 천백십일 (not 일천일백일십일)
    137161293 -> 일억 삼천칠백육만 이백구십삼

  • There is only one exception, 10000 is not "일만", but "만".

    18210 -> 1 8210 -> 만 팔천이백십 (not 일만 팔천이백십)

  • Standard code-golf rules are applied.

Table of Sino-Korean Digits

+-------+-------------+
| Digit | Sino-Korean |
+-------+-------------+
|     0 |          영 |
|     1 |          일 |
|     2 |          이 |
|     3 |          삼 |
|     4 |          사 |
|     5 |          오 |
|     6 |          육 |
|     7 |          칠 |
|     8 |          팔 |
|     9 |          구 |
+-------+-------------+

Input and Output

Input is integer \$N, 0 \leq N < 10^{24}\$

Output is UTF-8 formatted Sino-Korean numeral.

Examples

  • (Input) -> (Output)
  • 0 -> 영
  • 1 -> 일
  • 10 -> 십
  • 101 -> 백일
  • 301821 -> 삼십만 천팔백이십일
  • 10282714472 -> 백이억 팔천이백칠십일만 사천사백칠십이
  • 999999999999999999999999 -> 구천구백구십구해 구천구백구십구경 구천구백구십구조 구천구백구십구억 구천구백구십구만 구천구백구십구

This is code-golf, so shortest code in bytes wins.

cobaltp

Posted 2018-12-14T05:26:02.967

Reputation: 401

Question was closed 2018-12-14T05:43:22.887

1111 -> 천백십일 (not 일천일백일십일) but Firefox show the second one for 1111 codepen – tsh – 2018-12-14T05:51:38.357

@tsh Forms like "일천일백일십일" can be used but only in special areas like finance for prevent counterfeit. It is omitted in daily life usage. – cobaltp – 2018-12-14T05:59:57.520

No answers