Convert to Suzhou numerals
up vote
22
down vote
favorite
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.
code-golf number unicode
add a comment |
up vote
22
down vote
favorite
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.
code-golf number unicode
I'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
18 hours ago
1
@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.
– lastresort
16 hours ago
Can you take input in the form of a char array?
– Embodiment of Ignorance
13 hours ago
add a comment |
up vote
22
down vote
favorite
up vote
22
down vote
favorite
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.
code-golf number unicode
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.
code-golf number unicode
code-golf number unicode
edited yesterday
qwr
5,59952556
5,59952556
asked yesterday
lastresort
885313
885313
I'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
18 hours ago
1
@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.
– lastresort
16 hours ago
Can you take input in the form of a char array?
– Embodiment of Ignorance
13 hours ago
add a comment |
I'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
18 hours ago
1
@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.
– lastresort
16 hours ago
Can you take input in the form of a char array?
– Embodiment of Ignorance
13 hours ago
I'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
18 hours ago
I'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
18 hours ago
1
1
@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.
– lastresort
16 hours ago
@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.
– lastresort
16 hours ago
Can you take input in the form of a char array?
– Embodiment of Ignorance
13 hours ago
Can you take input in the form of a char array?
– Embodiment of Ignorance
13 hours ago
add a comment |
16 Answers
16
active
oldest
votes
up vote
6
down vote
Retina, 46 bytes
/[1-3]{2}|./_T`d`〇〡-〩`^.
T`123`一二三
Try it online! Link includes test cases. Explanation:
/[1-3]{2}|./
Match either two digits 1-3 or any other digit.
_T`d`〇〡-〩`^.
Replace the first character of each match with its Suzhou.
T`123`一二三
Replace any remaining digits with horizontal Suzhou.
51 bytes in Retina 0.8.2:
M!`[1-3]{2}|.
mT`d`〇〡-〩`^.
T`¶123`_一二三
Try it online! Link includes test cases. Explanation:
M!`[1-3]{2}|.
Split the input into individual digits or pairs of digits if they are both 1-3.
mT`d`〇〡-〩`^.
Replace the first character of each line with its Suzhou.
T`¶123`_一二三
Join the lines back together and replace any remaining digits with horizontal Suzhou.
add a comment |
up vote
5
down vote
JavaScript, 81 bytes
s=>s.replace(/./g,c=>(p=14>>c&!p)|c>3?eval(`"\u302${c}"`):'〇一二三'[c],p=0)
Try it online!
Using 14>>c
saves 3 bytes. Thanks to Arnauld.
p=c>0&c<4&!p
can be turned intop=14>>c&!p
– Arnauld
16 hours ago
add a comment |
up vote
4
down vote
JavaScript (ES6), 95 89 88 bytes
Saved 6 bytes thanks to @ShieruAsakoto
Takes input as a string.
s=>s.replace(i=/./g,c=>'三二一〇〡〢〣〤〥〦〧〨〩'[i=112>>i&c<4?3-c:+c+3])
Try it online!
89 bytes
– Shieru Asakoto
yesterday
@ShieruAsakoto That's much better! Thanks a lot!
– Arnauld
yesterday
add a comment |
up vote
3
down vote
Clean, 181 165 bytes
All octal escapes can be replaced by the equivalent single-byte characters (and are counted as one byte each), but used for readability and because otherwise it breaks TIO and SE with invalid UTF-8.
import StdEnv
u=mapc={'343','200',c}
?s=((!!)["〇":s++u['244245246247250']])o digitToInt
$=
$[h:t]=[?(u['241242243'])h:if(h-'1'<'03')f$t]
f=
f[h:t]=[?["一","二","三"]h: $t]
Try it online!
An encoding-unaware compiler is both a blessing and a curse.
add a comment |
up vote
3
down vote
Java (JDK), 120 bytes
s->{for(int i=0,p=0,c;i<s.length;)s[i]+=(p>0&p<4&(c=s[i++]-48)>0&c<4)?"A䷏乚䷖".charAt(c+(p=0)):(p=c)<1?12247:12272;}
Try it online!
Credits
- -3 bytes thanks to Kevin Cruijssen
1
c=s[i]-48;if(p>0&p<4&c>0&c<4)
can beif(p>0&p<4&(c=s[i]-48)>0&c<4)
, and then you can also drop the brackets around the loop. Also,else{p=c;s[i]+=c<1?12247:12272;}
can beelse s[i]+=(p=c)<1?12247:12272;
– Kevin Cruijssen
20 hours ago
1
@KevinCruijssen Thank you! I was still golfing this answer, but it helped me nonetheless ^^ Now I think I'm done golfing it.
– Olivier Grégoire
19 hours ago
add a comment |
up vote
3
down vote
Perl 5 -pl -Mutf8
, 53 46 bytes
-7 bytes thanks to Grimy
s/[123]{2}|./OS&$&/ge;y//〇〡-〰一二三/c
Try it online!
Explanation
# Binary AND two consecutive digits 1-3 (ASCII 0x31-0x33)
# or any other single digit (ASCII 0x30-0x39) with string "OS"
# (ASCII 0x4F 0x53). This converts the first digit to 0x00-0x09
# and the second digit, if present, to 0x11-0x13.
s/[123]{2}|./OS&$&/ge;
# Translate empty complemented searchlist (0x00-0x13) to
# respective Unicode characters.
y//〇〡-〰一二三/c
-3 bytes withs/[123]K[123]/$&^$;/ge;y/--</一二三〇〡-〩/
(TIO)
– Grimy
16 hours ago
49:s/[123]{2}/$&^v0.28/ge;y/--</一二三〇〡-〩/
(TIO). 48:s/[123]{2}/$&^"34"/ge;y/--</一二三〇〡-〩/
(requires using literal control characters instead of34
, idk how to do this on TIO)
– Grimy
16 hours ago
46:s/[123]{2}|./OS&$&/ge;y//〇〡-〰一二三/c
(TIO)
– Grimy
15 hours ago
add a comment |
up vote
2
down vote
Perl 6 -p
, 85 61 bytes
-13 bytes thanks to Jo King
s:g[(1|2|3)<((1|2|3)]=chr $/+57;tr/0..</〇〡..〩一二三/
Try it online!
add a comment |
up vote
2
down vote
Red, 198 171 bytes
func[n][s: charset"〡〢〣"forall n[n/1: either n/1 >#"0"[to-char 12272 + n/1][#"〇"]]parse
n[any[[s change copy t s(pick"一二三"do(to-char t)- 12320)fail]| skip]]n]
Try it online!
add a comment |
up vote
2
down vote
R, 138 bytes
I'll bet there's an easier way to do this. Use gsub
to get the alternating numeric positions.
function(x,r=-48+~x)Reduce(paste0,ifelse(58<~gsub("[123]{2}","0a",x),"123"["一二三",r],'0-9'["〇〡-〩",r]))
"~"=utf8ToInt
"["=chartr
Try it online!
add a comment |
up vote
2
down vote
Python 3, 102 bytes
f=0
for i in input():f=i in'123'and 9-f;print(end='〇一二三〤〥〦〧〨〩〡〢〣'[int(i)+f])
Try it online!
mypetlion reminded me of a trivial golf. -4 bytes.
add a comment |
up vote
1
down vote
Ruby -p
, 71 bytes
$_=gsub(/[1-3]K[1-3]/){|x|(x.ord+9).chr}.tr"0-<","〇〡-〩一二三"
Try it online!
add a comment |
up vote
1
down vote
K (ngn/k), 67 bytes
{,/(0N 3#"〇一二三〤〥〦〧〨〩〡〢〣")x+9*<x&x<4}@10
Try it online!
10
get list of decimal digits
{
}@
apply the following function
x&x<4
boolean (0/1) list of where the argument is less than 4 and non-zero
<
scan with less-than. this turns runs of consecutive 1s into alternating 1s and 0s
x+9*
multiply by 9 and add x
juxtaposition is indexing, so use this as indices in...
0N 3#"〇一二三〤〥〦〧〨〩〡〢〣"
the given string, split into a list of 3-byte strings. k is not unicode aware, so it sees only bytes
,/
concatenate
add a comment |
up vote
0
down vote
C#, 127 bytes
n=>Regex.Replace(n+"",@"[4-90]|[1-3]{1,2}",x=>"〇〡〢〣〤〥〦〧〨〩"[x.Value[0]-'0']+""+(x.Value.Length>1?"一二三"[x.Value[1]-'0'-1]+"":""))
Try it online!
add a comment |
up vote
0
down vote
Jelly, 38 bytes
9Rż“øƓ“œ%“øƈ’;-25+⁽-EỌœị@DżD<4«Ɗ‘×¥ƊƊ
Try it online!
add a comment |
up vote
0
down vote
Jelly, 35 bytes
9Ḷ;-26ż“/Ẉ8‘+⁽ȷc¤ṃ@ɓD_2ỊŒgÄFị"+⁽-FỌ
Try it online!
add a comment |
up vote
0
down vote
Wolfram Language (Mathematica), 117 bytes
FromCharacterCode[12320+(IntegerDigits@#/. 0->-25//.MapIndexed[{a___,c=#2[[1]],c,b___}->{a,c,#,b}&,{0,140,9}+7648])]&
Try it online!
Note that on TIO this outputs the result in escaped form. In the normal Wolfram front end, it will look like this:
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
});
});
}, "mathjax-editing");
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "200"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f177517%2fconvert-to-suzhou-numerals%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
16 Answers
16
active
oldest
votes
16 Answers
16
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
6
down vote
Retina, 46 bytes
/[1-3]{2}|./_T`d`〇〡-〩`^.
T`123`一二三
Try it online! Link includes test cases. Explanation:
/[1-3]{2}|./
Match either two digits 1-3 or any other digit.
_T`d`〇〡-〩`^.
Replace the first character of each match with its Suzhou.
T`123`一二三
Replace any remaining digits with horizontal Suzhou.
51 bytes in Retina 0.8.2:
M!`[1-3]{2}|.
mT`d`〇〡-〩`^.
T`¶123`_一二三
Try it online! Link includes test cases. Explanation:
M!`[1-3]{2}|.
Split the input into individual digits or pairs of digits if they are both 1-3.
mT`d`〇〡-〩`^.
Replace the first character of each line with its Suzhou.
T`¶123`_一二三
Join the lines back together and replace any remaining digits with horizontal Suzhou.
add a comment |
up vote
6
down vote
Retina, 46 bytes
/[1-3]{2}|./_T`d`〇〡-〩`^.
T`123`一二三
Try it online! Link includes test cases. Explanation:
/[1-3]{2}|./
Match either two digits 1-3 or any other digit.
_T`d`〇〡-〩`^.
Replace the first character of each match with its Suzhou.
T`123`一二三
Replace any remaining digits with horizontal Suzhou.
51 bytes in Retina 0.8.2:
M!`[1-3]{2}|.
mT`d`〇〡-〩`^.
T`¶123`_一二三
Try it online! Link includes test cases. Explanation:
M!`[1-3]{2}|.
Split the input into individual digits or pairs of digits if they are both 1-3.
mT`d`〇〡-〩`^.
Replace the first character of each line with its Suzhou.
T`¶123`_一二三
Join the lines back together and replace any remaining digits with horizontal Suzhou.
add a comment |
up vote
6
down vote
up vote
6
down vote
Retina, 46 bytes
/[1-3]{2}|./_T`d`〇〡-〩`^.
T`123`一二三
Try it online! Link includes test cases. Explanation:
/[1-3]{2}|./
Match either two digits 1-3 or any other digit.
_T`d`〇〡-〩`^.
Replace the first character of each match with its Suzhou.
T`123`一二三
Replace any remaining digits with horizontal Suzhou.
51 bytes in Retina 0.8.2:
M!`[1-3]{2}|.
mT`d`〇〡-〩`^.
T`¶123`_一二三
Try it online! Link includes test cases. Explanation:
M!`[1-3]{2}|.
Split the input into individual digits or pairs of digits if they are both 1-3.
mT`d`〇〡-〩`^.
Replace the first character of each line with its Suzhou.
T`¶123`_一二三
Join the lines back together and replace any remaining digits with horizontal Suzhou.
Retina, 46 bytes
/[1-3]{2}|./_T`d`〇〡-〩`^.
T`123`一二三
Try it online! Link includes test cases. Explanation:
/[1-3]{2}|./
Match either two digits 1-3 or any other digit.
_T`d`〇〡-〩`^.
Replace the first character of each match with its Suzhou.
T`123`一二三
Replace any remaining digits with horizontal Suzhou.
51 bytes in Retina 0.8.2:
M!`[1-3]{2}|.
mT`d`〇〡-〩`^.
T`¶123`_一二三
Try it online! Link includes test cases. Explanation:
M!`[1-3]{2}|.
Split the input into individual digits or pairs of digits if they are both 1-3.
mT`d`〇〡-〩`^.
Replace the first character of each line with its Suzhou.
T`¶123`_一二三
Join the lines back together and replace any remaining digits with horizontal Suzhou.
answered yesterday
Neil
78.8k744175
78.8k744175
add a comment |
add a comment |
up vote
5
down vote
JavaScript, 81 bytes
s=>s.replace(/./g,c=>(p=14>>c&!p)|c>3?eval(`"\u302${c}"`):'〇一二三'[c],p=0)
Try it online!
Using 14>>c
saves 3 bytes. Thanks to Arnauld.
p=c>0&c<4&!p
can be turned intop=14>>c&!p
– Arnauld
16 hours ago
add a comment |
up vote
5
down vote
JavaScript, 81 bytes
s=>s.replace(/./g,c=>(p=14>>c&!p)|c>3?eval(`"\u302${c}"`):'〇一二三'[c],p=0)
Try it online!
Using 14>>c
saves 3 bytes. Thanks to Arnauld.
p=c>0&c<4&!p
can be turned intop=14>>c&!p
– Arnauld
16 hours ago
add a comment |
up vote
5
down vote
up vote
5
down vote
JavaScript, 81 bytes
s=>s.replace(/./g,c=>(p=14>>c&!p)|c>3?eval(`"\u302${c}"`):'〇一二三'[c],p=0)
Try it online!
Using 14>>c
saves 3 bytes. Thanks to Arnauld.
JavaScript, 81 bytes
s=>s.replace(/./g,c=>(p=14>>c&!p)|c>3?eval(`"\u302${c}"`):'〇一二三'[c],p=0)
Try it online!
Using 14>>c
saves 3 bytes. Thanks to Arnauld.
edited 5 hours ago
answered 21 hours ago
tsh
8,25511546
8,25511546
p=c>0&c<4&!p
can be turned intop=14>>c&!p
– Arnauld
16 hours ago
add a comment |
p=c>0&c<4&!p
can be turned intop=14>>c&!p
– Arnauld
16 hours ago
p=c>0&c<4&!p
can be turned into p=14>>c&!p
– Arnauld
16 hours ago
p=c>0&c<4&!p
can be turned into p=14>>c&!p
– Arnauld
16 hours ago
add a comment |
up vote
4
down vote
JavaScript (ES6), 95 89 88 bytes
Saved 6 bytes thanks to @ShieruAsakoto
Takes input as a string.
s=>s.replace(i=/./g,c=>'三二一〇〡〢〣〤〥〦〧〨〩'[i=112>>i&c<4?3-c:+c+3])
Try it online!
89 bytes
– Shieru Asakoto
yesterday
@ShieruAsakoto That's much better! Thanks a lot!
– Arnauld
yesterday
add a comment |
up vote
4
down vote
JavaScript (ES6), 95 89 88 bytes
Saved 6 bytes thanks to @ShieruAsakoto
Takes input as a string.
s=>s.replace(i=/./g,c=>'三二一〇〡〢〣〤〥〦〧〨〩'[i=112>>i&c<4?3-c:+c+3])
Try it online!
89 bytes
– Shieru Asakoto
yesterday
@ShieruAsakoto That's much better! Thanks a lot!
– Arnauld
yesterday
add a comment |
up vote
4
down vote
up vote
4
down vote
JavaScript (ES6), 95 89 88 bytes
Saved 6 bytes thanks to @ShieruAsakoto
Takes input as a string.
s=>s.replace(i=/./g,c=>'三二一〇〡〢〣〤〥〦〧〨〩'[i=112>>i&c<4?3-c:+c+3])
Try it online!
JavaScript (ES6), 95 89 88 bytes
Saved 6 bytes thanks to @ShieruAsakoto
Takes input as a string.
s=>s.replace(i=/./g,c=>'三二一〇〡〢〣〤〥〦〧〨〩'[i=112>>i&c<4?3-c:+c+3])
Try it online!
edited 16 hours ago
answered yesterday
Arnauld
71.5k688299
71.5k688299
89 bytes
– Shieru Asakoto
yesterday
@ShieruAsakoto That's much better! Thanks a lot!
– Arnauld
yesterday
add a comment |
89 bytes
– Shieru Asakoto
yesterday
@ShieruAsakoto That's much better! Thanks a lot!
– Arnauld
yesterday
89 bytes
– Shieru Asakoto
yesterday
89 bytes
– Shieru Asakoto
yesterday
@ShieruAsakoto That's much better! Thanks a lot!
– Arnauld
yesterday
@ShieruAsakoto That's much better! Thanks a lot!
– Arnauld
yesterday
add a comment |
up vote
3
down vote
Clean, 181 165 bytes
All octal escapes can be replaced by the equivalent single-byte characters (and are counted as one byte each), but used for readability and because otherwise it breaks TIO and SE with invalid UTF-8.
import StdEnv
u=mapc={'343','200',c}
?s=((!!)["〇":s++u['244245246247250']])o digitToInt
$=
$[h:t]=[?(u['241242243'])h:if(h-'1'<'03')f$t]
f=
f[h:t]=[?["一","二","三"]h: $t]
Try it online!
An encoding-unaware compiler is both a blessing and a curse.
add a comment |
up vote
3
down vote
Clean, 181 165 bytes
All octal escapes can be replaced by the equivalent single-byte characters (and are counted as one byte each), but used for readability and because otherwise it breaks TIO and SE with invalid UTF-8.
import StdEnv
u=mapc={'343','200',c}
?s=((!!)["〇":s++u['244245246247250']])o digitToInt
$=
$[h:t]=[?(u['241242243'])h:if(h-'1'<'03')f$t]
f=
f[h:t]=[?["一","二","三"]h: $t]
Try it online!
An encoding-unaware compiler is both a blessing and a curse.
add a comment |
up vote
3
down vote
up vote
3
down vote
Clean, 181 165 bytes
All octal escapes can be replaced by the equivalent single-byte characters (and are counted as one byte each), but used for readability and because otherwise it breaks TIO and SE with invalid UTF-8.
import StdEnv
u=mapc={'343','200',c}
?s=((!!)["〇":s++u['244245246247250']])o digitToInt
$=
$[h:t]=[?(u['241242243'])h:if(h-'1'<'03')f$t]
f=
f[h:t]=[?["一","二","三"]h: $t]
Try it online!
An encoding-unaware compiler is both a blessing and a curse.
Clean, 181 165 bytes
All octal escapes can be replaced by the equivalent single-byte characters (and are counted as one byte each), but used for readability and because otherwise it breaks TIO and SE with invalid UTF-8.
import StdEnv
u=mapc={'343','200',c}
?s=((!!)["〇":s++u['244245246247250']])o digitToInt
$=
$[h:t]=[?(u['241242243'])h:if(h-'1'<'03')f$t]
f=
f[h:t]=[?["一","二","三"]h: $t]
Try it online!
An encoding-unaware compiler is both a blessing and a curse.
edited yesterday
answered yesterday
Οurous
6,26811032
6,26811032
add a comment |
add a comment |
up vote
3
down vote
Java (JDK), 120 bytes
s->{for(int i=0,p=0,c;i<s.length;)s[i]+=(p>0&p<4&(c=s[i++]-48)>0&c<4)?"A䷏乚䷖".charAt(c+(p=0)):(p=c)<1?12247:12272;}
Try it online!
Credits
- -3 bytes thanks to Kevin Cruijssen
1
c=s[i]-48;if(p>0&p<4&c>0&c<4)
can beif(p>0&p<4&(c=s[i]-48)>0&c<4)
, and then you can also drop the brackets around the loop. Also,else{p=c;s[i]+=c<1?12247:12272;}
can beelse s[i]+=(p=c)<1?12247:12272;
– Kevin Cruijssen
20 hours ago
1
@KevinCruijssen Thank you! I was still golfing this answer, but it helped me nonetheless ^^ Now I think I'm done golfing it.
– Olivier Grégoire
19 hours ago
add a comment |
up vote
3
down vote
Java (JDK), 120 bytes
s->{for(int i=0,p=0,c;i<s.length;)s[i]+=(p>0&p<4&(c=s[i++]-48)>0&c<4)?"A䷏乚䷖".charAt(c+(p=0)):(p=c)<1?12247:12272;}
Try it online!
Credits
- -3 bytes thanks to Kevin Cruijssen
1
c=s[i]-48;if(p>0&p<4&c>0&c<4)
can beif(p>0&p<4&(c=s[i]-48)>0&c<4)
, and then you can also drop the brackets around the loop. Also,else{p=c;s[i]+=c<1?12247:12272;}
can beelse s[i]+=(p=c)<1?12247:12272;
– Kevin Cruijssen
20 hours ago
1
@KevinCruijssen Thank you! I was still golfing this answer, but it helped me nonetheless ^^ Now I think I'm done golfing it.
– Olivier Grégoire
19 hours ago
add a comment |
up vote
3
down vote
up vote
3
down vote
Java (JDK), 120 bytes
s->{for(int i=0,p=0,c;i<s.length;)s[i]+=(p>0&p<4&(c=s[i++]-48)>0&c<4)?"A䷏乚䷖".charAt(c+(p=0)):(p=c)<1?12247:12272;}
Try it online!
Credits
- -3 bytes thanks to Kevin Cruijssen
Java (JDK), 120 bytes
s->{for(int i=0,p=0,c;i<s.length;)s[i]+=(p>0&p<4&(c=s[i++]-48)>0&c<4)?"A䷏乚䷖".charAt(c+(p=0)):(p=c)<1?12247:12272;}
Try it online!
Credits
- -3 bytes thanks to Kevin Cruijssen
edited 19 hours ago
answered 20 hours ago
Olivier Grégoire
8,68711843
8,68711843
1
c=s[i]-48;if(p>0&p<4&c>0&c<4)
can beif(p>0&p<4&(c=s[i]-48)>0&c<4)
, and then you can also drop the brackets around the loop. Also,else{p=c;s[i]+=c<1?12247:12272;}
can beelse s[i]+=(p=c)<1?12247:12272;
– Kevin Cruijssen
20 hours ago
1
@KevinCruijssen Thank you! I was still golfing this answer, but it helped me nonetheless ^^ Now I think I'm done golfing it.
– Olivier Grégoire
19 hours ago
add a comment |
1
c=s[i]-48;if(p>0&p<4&c>0&c<4)
can beif(p>0&p<4&(c=s[i]-48)>0&c<4)
, and then you can also drop the brackets around the loop. Also,else{p=c;s[i]+=c<1?12247:12272;}
can beelse s[i]+=(p=c)<1?12247:12272;
– Kevin Cruijssen
20 hours ago
1
@KevinCruijssen Thank you! I was still golfing this answer, but it helped me nonetheless ^^ Now I think I'm done golfing it.
– Olivier Grégoire
19 hours ago
1
1
c=s[i]-48;if(p>0&p<4&c>0&c<4)
can be if(p>0&p<4&(c=s[i]-48)>0&c<4)
, and then you can also drop the brackets around the loop. Also, else{p=c;s[i]+=c<1?12247:12272;}
can be else s[i]+=(p=c)<1?12247:12272;
– Kevin Cruijssen
20 hours ago
c=s[i]-48;if(p>0&p<4&c>0&c<4)
can be if(p>0&p<4&(c=s[i]-48)>0&c<4)
, and then you can also drop the brackets around the loop. Also, else{p=c;s[i]+=c<1?12247:12272;}
can be else s[i]+=(p=c)<1?12247:12272;
– Kevin Cruijssen
20 hours ago
1
1
@KevinCruijssen Thank you! I was still golfing this answer, but it helped me nonetheless ^^ Now I think I'm done golfing it.
– Olivier Grégoire
19 hours ago
@KevinCruijssen Thank you! I was still golfing this answer, but it helped me nonetheless ^^ Now I think I'm done golfing it.
– Olivier Grégoire
19 hours ago
add a comment |
up vote
3
down vote
Perl 5 -pl -Mutf8
, 53 46 bytes
-7 bytes thanks to Grimy
s/[123]{2}|./OS&$&/ge;y//〇〡-〰一二三/c
Try it online!
Explanation
# Binary AND two consecutive digits 1-3 (ASCII 0x31-0x33)
# or any other single digit (ASCII 0x30-0x39) with string "OS"
# (ASCII 0x4F 0x53). This converts the first digit to 0x00-0x09
# and the second digit, if present, to 0x11-0x13.
s/[123]{2}|./OS&$&/ge;
# Translate empty complemented searchlist (0x00-0x13) to
# respective Unicode characters.
y//〇〡-〰一二三/c
-3 bytes withs/[123]K[123]/$&^$;/ge;y/--</一二三〇〡-〩/
(TIO)
– Grimy
16 hours ago
49:s/[123]{2}/$&^v0.28/ge;y/--</一二三〇〡-〩/
(TIO). 48:s/[123]{2}/$&^"34"/ge;y/--</一二三〇〡-〩/
(requires using literal control characters instead of34
, idk how to do this on TIO)
– Grimy
16 hours ago
46:s/[123]{2}|./OS&$&/ge;y//〇〡-〰一二三/c
(TIO)
– Grimy
15 hours ago
add a comment |
up vote
3
down vote
Perl 5 -pl -Mutf8
, 53 46 bytes
-7 bytes thanks to Grimy
s/[123]{2}|./OS&$&/ge;y//〇〡-〰一二三/c
Try it online!
Explanation
# Binary AND two consecutive digits 1-3 (ASCII 0x31-0x33)
# or any other single digit (ASCII 0x30-0x39) with string "OS"
# (ASCII 0x4F 0x53). This converts the first digit to 0x00-0x09
# and the second digit, if present, to 0x11-0x13.
s/[123]{2}|./OS&$&/ge;
# Translate empty complemented searchlist (0x00-0x13) to
# respective Unicode characters.
y//〇〡-〰一二三/c
-3 bytes withs/[123]K[123]/$&^$;/ge;y/--</一二三〇〡-〩/
(TIO)
– Grimy
16 hours ago
49:s/[123]{2}/$&^v0.28/ge;y/--</一二三〇〡-〩/
(TIO). 48:s/[123]{2}/$&^"34"/ge;y/--</一二三〇〡-〩/
(requires using literal control characters instead of34
, idk how to do this on TIO)
– Grimy
16 hours ago
46:s/[123]{2}|./OS&$&/ge;y//〇〡-〰一二三/c
(TIO)
– Grimy
15 hours ago
add a comment |
up vote
3
down vote
up vote
3
down vote
Perl 5 -pl -Mutf8
, 53 46 bytes
-7 bytes thanks to Grimy
s/[123]{2}|./OS&$&/ge;y//〇〡-〰一二三/c
Try it online!
Explanation
# Binary AND two consecutive digits 1-3 (ASCII 0x31-0x33)
# or any other single digit (ASCII 0x30-0x39) with string "OS"
# (ASCII 0x4F 0x53). This converts the first digit to 0x00-0x09
# and the second digit, if present, to 0x11-0x13.
s/[123]{2}|./OS&$&/ge;
# Translate empty complemented searchlist (0x00-0x13) to
# respective Unicode characters.
y//〇〡-〰一二三/c
Perl 5 -pl -Mutf8
, 53 46 bytes
-7 bytes thanks to Grimy
s/[123]{2}|./OS&$&/ge;y//〇〡-〰一二三/c
Try it online!
Explanation
# Binary AND two consecutive digits 1-3 (ASCII 0x31-0x33)
# or any other single digit (ASCII 0x30-0x39) with string "OS"
# (ASCII 0x4F 0x53). This converts the first digit to 0x00-0x09
# and the second digit, if present, to 0x11-0x13.
s/[123]{2}|./OS&$&/ge;
# Translate empty complemented searchlist (0x00-0x13) to
# respective Unicode characters.
y//〇〡-〰一二三/c
edited 15 hours ago
answered yesterday
nwellnhof
6,4431125
6,4431125
-3 bytes withs/[123]K[123]/$&^$;/ge;y/--</一二三〇〡-〩/
(TIO)
– Grimy
16 hours ago
49:s/[123]{2}/$&^v0.28/ge;y/--</一二三〇〡-〩/
(TIO). 48:s/[123]{2}/$&^"34"/ge;y/--</一二三〇〡-〩/
(requires using literal control characters instead of34
, idk how to do this on TIO)
– Grimy
16 hours ago
46:s/[123]{2}|./OS&$&/ge;y//〇〡-〰一二三/c
(TIO)
– Grimy
15 hours ago
add a comment |
-3 bytes withs/[123]K[123]/$&^$;/ge;y/--</一二三〇〡-〩/
(TIO)
– Grimy
16 hours ago
49:s/[123]{2}/$&^v0.28/ge;y/--</一二三〇〡-〩/
(TIO). 48:s/[123]{2}/$&^"34"/ge;y/--</一二三〇〡-〩/
(requires using literal control characters instead of34
, idk how to do this on TIO)
– Grimy
16 hours ago
46:s/[123]{2}|./OS&$&/ge;y//〇〡-〰一二三/c
(TIO)
– Grimy
15 hours ago
-3 bytes with
s/[123]K[123]/$&^$;/ge;y/--</一二三〇〡-〩/
(TIO)– Grimy
16 hours ago
-3 bytes with
s/[123]K[123]/$&^$;/ge;y/--</一二三〇〡-〩/
(TIO)– Grimy
16 hours ago
49:
s/[123]{2}/$&^v0.28/ge;y/--</一二三〇〡-〩/
(TIO). 48: s/[123]{2}/$&^"34"/ge;y/--</一二三〇〡-〩/
(requires using literal control characters instead of 34
, idk how to do this on TIO)– Grimy
16 hours ago
49:
s/[123]{2}/$&^v0.28/ge;y/--</一二三〇〡-〩/
(TIO). 48: s/[123]{2}/$&^"34"/ge;y/--</一二三〇〡-〩/
(requires using literal control characters instead of 34
, idk how to do this on TIO)– Grimy
16 hours ago
46:
s/[123]{2}|./OS&$&/ge;y//〇〡-〰一二三/c
(TIO)– Grimy
15 hours ago
46:
s/[123]{2}|./OS&$&/ge;y//〇〡-〰一二三/c
(TIO)– Grimy
15 hours ago
add a comment |
up vote
2
down vote
Perl 6 -p
, 85 61 bytes
-13 bytes thanks to Jo King
s:g[(1|2|3)<((1|2|3)]=chr $/+57;tr/0..</〇〡..〩一二三/
Try it online!
add a comment |
up vote
2
down vote
Perl 6 -p
, 85 61 bytes
-13 bytes thanks to Jo King
s:g[(1|2|3)<((1|2|3)]=chr $/+57;tr/0..</〇〡..〩一二三/
Try it online!
add a comment |
up vote
2
down vote
up vote
2
down vote
Perl 6 -p
, 85 61 bytes
-13 bytes thanks to Jo King
s:g[(1|2|3)<((1|2|3)]=chr $/+57;tr/0..</〇〡..〩一二三/
Try it online!
Perl 6 -p
, 85 61 bytes
-13 bytes thanks to Jo King
s:g[(1|2|3)<((1|2|3)]=chr $/+57;tr/0..</〇〡..〩一二三/
Try it online!
edited yesterday
answered yesterday
nwellnhof
6,4431125
6,4431125
add a comment |
add a comment |
up vote
2
down vote
Red, 198 171 bytes
func[n][s: charset"〡〢〣"forall n[n/1: either n/1 >#"0"[to-char 12272 + n/1][#"〇"]]parse
n[any[[s change copy t s(pick"一二三"do(to-char t)- 12320)fail]| skip]]n]
Try it online!
add a comment |
up vote
2
down vote
Red, 198 171 bytes
func[n][s: charset"〡〢〣"forall n[n/1: either n/1 >#"0"[to-char 12272 + n/1][#"〇"]]parse
n[any[[s change copy t s(pick"一二三"do(to-char t)- 12320)fail]| skip]]n]
Try it online!
add a comment |
up vote
2
down vote
up vote
2
down vote
Red, 198 171 bytes
func[n][s: charset"〡〢〣"forall n[n/1: either n/1 >#"0"[to-char 12272 + n/1][#"〇"]]parse
n[any[[s change copy t s(pick"一二三"do(to-char t)- 12320)fail]| skip]]n]
Try it online!
Red, 198 171 bytes
func[n][s: charset"〡〢〣"forall n[n/1: either n/1 >#"0"[to-char 12272 + n/1][#"〇"]]parse
n[any[[s change copy t s(pick"一二三"do(to-char t)- 12320)fail]| skip]]n]
Try it online!
edited 19 hours ago
answered 20 hours ago
Galen Ivanov
6,15211032
6,15211032
add a comment |
add a comment |
up vote
2
down vote
R, 138 bytes
I'll bet there's an easier way to do this. Use gsub
to get the alternating numeric positions.
function(x,r=-48+~x)Reduce(paste0,ifelse(58<~gsub("[123]{2}","0a",x),"123"["一二三",r],'0-9'["〇〡-〩",r]))
"~"=utf8ToInt
"["=chartr
Try it online!
add a comment |
up vote
2
down vote
R, 138 bytes
I'll bet there's an easier way to do this. Use gsub
to get the alternating numeric positions.
function(x,r=-48+~x)Reduce(paste0,ifelse(58<~gsub("[123]{2}","0a",x),"123"["一二三",r],'0-9'["〇〡-〩",r]))
"~"=utf8ToInt
"["=chartr
Try it online!
add a comment |
up vote
2
down vote
up vote
2
down vote
R, 138 bytes
I'll bet there's an easier way to do this. Use gsub
to get the alternating numeric positions.
function(x,r=-48+~x)Reduce(paste0,ifelse(58<~gsub("[123]{2}","0a",x),"123"["一二三",r],'0-9'["〇〡-〩",r]))
"~"=utf8ToInt
"["=chartr
Try it online!
R, 138 bytes
I'll bet there's an easier way to do this. Use gsub
to get the alternating numeric positions.
function(x,r=-48+~x)Reduce(paste0,ifelse(58<~gsub("[123]{2}","0a",x),"123"["一二三",r],'0-9'["〇〡-〩",r]))
"~"=utf8ToInt
"["=chartr
Try it online!
edited 15 hours ago
answered 15 hours ago
J.Doe
2,149112
2,149112
add a comment |
add a comment |
up vote
2
down vote
Python 3, 102 bytes
f=0
for i in input():f=i in'123'and 9-f;print(end='〇一二三〤〥〦〧〨〩〡〢〣'[int(i)+f])
Try it online!
mypetlion reminded me of a trivial golf. -4 bytes.
add a comment |
up vote
2
down vote
Python 3, 102 bytes
f=0
for i in input():f=i in'123'and 9-f;print(end='〇一二三〤〥〦〧〨〩〡〢〣'[int(i)+f])
Try it online!
mypetlion reminded me of a trivial golf. -4 bytes.
add a comment |
up vote
2
down vote
up vote
2
down vote
Python 3, 102 bytes
f=0
for i in input():f=i in'123'and 9-f;print(end='〇一二三〤〥〦〧〨〩〡〢〣'[int(i)+f])
Try it online!
mypetlion reminded me of a trivial golf. -4 bytes.
Python 3, 102 bytes
f=0
for i in input():f=i in'123'and 9-f;print(end='〇一二三〤〥〦〧〨〩〡〢〣'[int(i)+f])
Try it online!
mypetlion reminded me of a trivial golf. -4 bytes.
edited 10 hours ago
answered 12 hours ago
Erik the Outgolfer
31.1k429102
31.1k429102
add a comment |
add a comment |
up vote
1
down vote
Ruby -p
, 71 bytes
$_=gsub(/[1-3]K[1-3]/){|x|(x.ord+9).chr}.tr"0-<","〇〡-〩一二三"
Try it online!
add a comment |
up vote
1
down vote
Ruby -p
, 71 bytes
$_=gsub(/[1-3]K[1-3]/){|x|(x.ord+9).chr}.tr"0-<","〇〡-〩一二三"
Try it online!
add a comment |
up vote
1
down vote
up vote
1
down vote
Ruby -p
, 71 bytes
$_=gsub(/[1-3]K[1-3]/){|x|(x.ord+9).chr}.tr"0-<","〇〡-〩一二三"
Try it online!
Ruby -p
, 71 bytes
$_=gsub(/[1-3]K[1-3]/){|x|(x.ord+9).chr}.tr"0-<","〇〡-〩一二三"
Try it online!
answered 20 hours ago
Kirill L.
3,5051218
3,5051218
add a comment |
add a comment |
up vote
1
down vote
K (ngn/k), 67 bytes
{,/(0N 3#"〇一二三〤〥〦〧〨〩〡〢〣")x+9*<x&x<4}@10
Try it online!
10
get list of decimal digits
{
}@
apply the following function
x&x<4
boolean (0/1) list of where the argument is less than 4 and non-zero
<
scan with less-than. this turns runs of consecutive 1s into alternating 1s and 0s
x+9*
multiply by 9 and add x
juxtaposition is indexing, so use this as indices in...
0N 3#"〇一二三〤〥〦〧〨〩〡〢〣"
the given string, split into a list of 3-byte strings. k is not unicode aware, so it sees only bytes
,/
concatenate
add a comment |
up vote
1
down vote
K (ngn/k), 67 bytes
{,/(0N 3#"〇一二三〤〥〦〧〨〩〡〢〣")x+9*<x&x<4}@10
Try it online!
10
get list of decimal digits
{
}@
apply the following function
x&x<4
boolean (0/1) list of where the argument is less than 4 and non-zero
<
scan with less-than. this turns runs of consecutive 1s into alternating 1s and 0s
x+9*
multiply by 9 and add x
juxtaposition is indexing, so use this as indices in...
0N 3#"〇一二三〤〥〦〧〨〩〡〢〣"
the given string, split into a list of 3-byte strings. k is not unicode aware, so it sees only bytes
,/
concatenate
add a comment |
up vote
1
down vote
up vote
1
down vote
K (ngn/k), 67 bytes
{,/(0N 3#"〇一二三〤〥〦〧〨〩〡〢〣")x+9*<x&x<4}@10
Try it online!
10
get list of decimal digits
{
}@
apply the following function
x&x<4
boolean (0/1) list of where the argument is less than 4 and non-zero
<
scan with less-than. this turns runs of consecutive 1s into alternating 1s and 0s
x+9*
multiply by 9 and add x
juxtaposition is indexing, so use this as indices in...
0N 3#"〇一二三〤〥〦〧〨〩〡〢〣"
the given string, split into a list of 3-byte strings. k is not unicode aware, so it sees only bytes
,/
concatenate
K (ngn/k), 67 bytes
{,/(0N 3#"〇一二三〤〥〦〧〨〩〡〢〣")x+9*<x&x<4}@10
Try it online!
10
get list of decimal digits
{
}@
apply the following function
x&x<4
boolean (0/1) list of where the argument is less than 4 and non-zero
<
scan with less-than. this turns runs of consecutive 1s into alternating 1s and 0s
x+9*
multiply by 9 and add x
juxtaposition is indexing, so use this as indices in...
0N 3#"〇一二三〤〥〦〧〨〩〡〢〣"
the given string, split into a list of 3-byte strings. k is not unicode aware, so it sees only bytes
,/
concatenate
edited 20 hours ago
answered 20 hours ago
ngn
6,67312459
6,67312459
add a comment |
add a comment |
up vote
0
down vote
C#, 127 bytes
n=>Regex.Replace(n+"",@"[4-90]|[1-3]{1,2}",x=>"〇〡〢〣〤〥〦〧〨〩"[x.Value[0]-'0']+""+(x.Value.Length>1?"一二三"[x.Value[1]-'0'-1]+"":""))
Try it online!
add a comment |
up vote
0
down vote
C#, 127 bytes
n=>Regex.Replace(n+"",@"[4-90]|[1-3]{1,2}",x=>"〇〡〢〣〤〥〦〧〨〩"[x.Value[0]-'0']+""+(x.Value.Length>1?"一二三"[x.Value[1]-'0'-1]+"":""))
Try it online!
add a comment |
up vote
0
down vote
up vote
0
down vote
C#, 127 bytes
n=>Regex.Replace(n+"",@"[4-90]|[1-3]{1,2}",x=>"〇〡〢〣〤〥〦〧〨〩"[x.Value[0]-'0']+""+(x.Value.Length>1?"一二三"[x.Value[1]-'0'-1]+"":""))
Try it online!
C#, 127 bytes
n=>Regex.Replace(n+"",@"[4-90]|[1-3]{1,2}",x=>"〇〡〢〣〤〥〦〧〨〩"[x.Value[0]-'0']+""+(x.Value.Length>1?"一二三"[x.Value[1]-'0'-1]+"":""))
Try it online!
answered 14 hours ago
zruF
495
495
add a comment |
add a comment |
up vote
0
down vote
Jelly, 38 bytes
9Rż“øƓ“œ%“øƈ’;-25+⁽-EỌœị@DżD<4«Ɗ‘×¥ƊƊ
Try it online!
add a comment |
up vote
0
down vote
Jelly, 38 bytes
9Rż“øƓ“œ%“øƈ’;-25+⁽-EỌœị@DżD<4«Ɗ‘×¥ƊƊ
Try it online!
add a comment |
up vote
0
down vote
up vote
0
down vote
Jelly, 38 bytes
9Rż“øƓ“œ%“øƈ’;-25+⁽-EỌœị@DżD<4«Ɗ‘×¥ƊƊ
Try it online!
Jelly, 38 bytes
9Rż“øƓ“œ%“øƈ’;-25+⁽-EỌœị@DżD<4«Ɗ‘×¥ƊƊ
Try it online!
answered 12 hours ago
Erik the Outgolfer
31.1k429102
31.1k429102
add a comment |
add a comment |
up vote
0
down vote
Jelly, 35 bytes
9Ḷ;-26ż“/Ẉ8‘+⁽ȷc¤ṃ@ɓD_2ỊŒgÄFị"+⁽-FỌ
Try it online!
add a comment |
up vote
0
down vote
Jelly, 35 bytes
9Ḷ;-26ż“/Ẉ8‘+⁽ȷc¤ṃ@ɓD_2ỊŒgÄFị"+⁽-FỌ
Try it online!
add a comment |
up vote
0
down vote
up vote
0
down vote
Jelly, 35 bytes
9Ḷ;-26ż“/Ẉ8‘+⁽ȷc¤ṃ@ɓD_2ỊŒgÄFị"+⁽-FỌ
Try it online!
Jelly, 35 bytes
9Ḷ;-26ż“/Ẉ8‘+⁽ȷc¤ṃ@ɓD_2ỊŒgÄFị"+⁽-FỌ
Try it online!
answered 9 hours ago
Dennis♦
185k32295734
185k32295734
add a comment |
add a comment |
up vote
0
down vote
Wolfram Language (Mathematica), 117 bytes
FromCharacterCode[12320+(IntegerDigits@#/. 0->-25//.MapIndexed[{a___,c=#2[[1]],c,b___}->{a,c,#,b}&,{0,140,9}+7648])]&
Try it online!
Note that on TIO this outputs the result in escaped form. In the normal Wolfram front end, it will look like this:
add a comment |
up vote
0
down vote
Wolfram Language (Mathematica), 117 bytes
FromCharacterCode[12320+(IntegerDigits@#/. 0->-25//.MapIndexed[{a___,c=#2[[1]],c,b___}->{a,c,#,b}&,{0,140,9}+7648])]&
Try it online!
Note that on TIO this outputs the result in escaped form. In the normal Wolfram front end, it will look like this:
add a comment |
up vote
0
down vote
up vote
0
down vote
Wolfram Language (Mathematica), 117 bytes
FromCharacterCode[12320+(IntegerDigits@#/. 0->-25//.MapIndexed[{a___,c=#2[[1]],c,b___}->{a,c,#,b}&,{0,140,9}+7648])]&
Try it online!
Note that on TIO this outputs the result in escaped form. In the normal Wolfram front end, it will look like this:
Wolfram Language (Mathematica), 117 bytes
FromCharacterCode[12320+(IntegerDigits@#/. 0->-25//.MapIndexed[{a___,c=#2[[1]],c,b___}->{a,c,#,b}&,{0,140,9}+7648])]&
Try it online!
Note that on TIO this outputs the result in escaped form. In the normal Wolfram front end, it will look like this:
answered 4 hours ago
Kelly Lowder
2,988416
2,988416
add a comment |
add a comment |
If this is an answer to a challenge…
…Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.
…Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
Explanations of your answer make it more interesting to read and are very much encouraged.…Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.
More generally…
…Please make sure to answer the question and provide sufficient detail.
…Avoid asking for help, clarification or responding to other answers (use comments instead).
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f177517%2fconvert-to-suzhou-numerals%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I'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
18 hours ago
1
@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.
– lastresort
16 hours ago
Can you take input in the form of a char array?
– Embodiment of Ignorance
13 hours ago