Given a fraction in the format m/n
(where m and n are coprime integers), output the corresponding Unicode fraction. Your program/function will not be expected to take in any input that does not correspond to a Unicode character. Arrays, e.g. [2, 3]
as opposed to 2/3
, are accepted. m / n
as opposed to m/n
is also fine. Two separate inputs m
and n
are also valid.
The Unicode fractions that must be handled are as follows:
½, ⅓, ⅔, ¼, ¾, ⅕, ⅖, ⅗, ⅘, ⅙, ⅚, ⅐, ⅛, ⅜, ⅝, ⅞, ⅑, ⅒
Thus, the possible inputs are as follows:
1/2, 1/3, 2/3, 1/4, 3/4, 1/5, 2/5, 3/5, 4/5, 1/6, 5/6, 1/7, 1/8, 3/8, 5/8, 7/8, 1/9, 1/10
The Unicode codepoints of the characters are as follows:
188 ¼
189 ½
190 ¾
8528 ⅐
8529 ⅑
8530 ⅒
8531 ⅓
8532 ⅔
8533 ⅕
8534 ⅖
8535 ⅗
8536 ⅘
8537 ⅙
8538 ⅚
8539 ⅛
8540 ⅜
8541 ⅝
8542 ⅞
Test Cases
1/2 -> ½
1/3 -> ⅓
2/3 -> ⅔
1/4 -> ¼
3/4 -> ¾
3/8 -> ⅜
1/10 -> ⅒
Make your code as short as possible; this is code golf.
188 ¼, 189 ½, 190 ¾, 8528 ⅐, 8529 ⅑, 8530 ⅒, 8531 ⅓, 8532 ⅔, 8533 ⅕, 8534 ⅖, 8535 ⅗, 8536 ⅘, 8537 ⅙, 8538 ⅚, 8539 ⅛, 8540 ⅜, 8541 ⅝, 8542 ⅞
\$\endgroup\$