Goal
You will be given a positive integer number less than 10^20. You must convert it to Korean.
For example, if the input is 12345
, the output should be 일만이천삼백사십오
.
Technical details (Small)
Let's starts with simple numbers.
// 1 - 9
1 -> 일
2 -> 이
3 -> 삼
4 -> 사
5 -> 오
6 -> 육
7 -> 칠
8 -> 팔
9 -> 구
// 10, 100, 1000
10 -> 십
100 -> 백
1000 -> 천
You can concatenate 2
~ 9
front of 10
, 100
, 1000
.
However, you should not concatenate 1
front of 10
, 100
, 1000
.
// 20 = 2 * 10
20 -> 이십
// 300 = 3 * 100
300 -> 삼백
// 9000 = 9 * 1000
9000 -> 구천
// 1000 is just 1000
1000 -> 천
For integer less than 10000, below rule is used for pronunciation.
// 1234 = 1000 + 200 + 30 + 4
1234 -> 천이백삼십사
// 1002 = 1000 + 2
1002 -> 천이
// 2048 = 2000 + 40 + 8
2048 -> 이천사십팔
// 510 = 500 + 10
510 -> 오백십
// 13 = 10 + 3
13 -> 십삼
Technical details (Large)
Now let's go to the hard part.
First, you need to know some parts used in larger numbers:
1 0000 -> 만
1 0000 0000 -> 억
1 0000 0000 0000 -> 조
1 0000 0000 0000 0000 -> 경
When Koreans pronounce big numbers
- Cut it with width 4
- Convert each of them using methods for less than 10000
- Combine them with default form of big numbers
Here is some detailed examples. (I added some space to korean for readability)
// 12345678 = 1234 5678
// 1234 -> 천이백삼십사
// 5678 -> 오천육백칠십팔
12345678 -> 천이백삼십사 만 오천육백칠십팔
// 11122223333 = 111 2222 3333
// 111 -> 백십일
// 2222 -> 이천이백이십이
// 3333 -> 삼천삼백삼십삼
11122223333 -> 백십일 억 이천이백이십이 만 삼천삼백삼십삼
// 10900000014 = 109 0000 0014
// 109 -> 백구
// 0000 -> (None)
// 0014 -> 십사
10900000014 -> 백구 억 십사
// 100000000 -> 1 0000 0000
// 1 -> 일
// 0000 -> (None)
// 0000 -> (None)
100000000 -> 일 억
Here are some more examples.
Rule
You can make your program gets input from stdin
and output to stdout
, or make a function that gets string/integer and returns string.
This is code-golf, so answers will be scored in bytes with fewer bytes being better.
일억
is correct form of100000000
.억
is a unit that cannot used alone. \$\endgroup\$