Convert to Suzhou numerals











up vote
18
down vote

favorite
2












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.










share|improve this question
























  • 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
    6 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
    4 hours ago










  • Can you take input in the form of a char array?
    – Embodiment of Ignorance
    1 hour ago















up vote
18
down vote

favorite
2












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.










share|improve this question
























  • 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
    6 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
    4 hours ago










  • Can you take input in the form of a char array?
    – Embodiment of Ignorance
    1 hour ago













up vote
18
down vote

favorite
2









up vote
18
down vote

favorite
2






2





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.










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 13 hours ago









qwr

5,59952556




5,59952556










asked 17 hours ago









lastresort

865312




865312












  • 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
    6 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
    4 hours ago










  • Can you take input in the form of a char array?
    – Embodiment of Ignorance
    1 hour 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
    6 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
    4 hours ago










  • Can you take input in the form of a char array?
    – Embodiment of Ignorance
    1 hour 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
6 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
6 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
4 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
4 hours ago












Can you take input in the form of a char array?
– Embodiment of Ignorance
1 hour ago




Can you take input in the form of a char array?
– Embodiment of Ignorance
1 hour ago










14 Answers
14






active

oldest

votes

















up vote
4
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.






share|improve this answer




























    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.






    share|improve this answer






























      up vote
      3
      down vote













      JavaScript, 83 bytes





      s=>s.replace(/./g,c=>(p=c>0&c<4&!p)|c>3?eval(`"\u302${c}"`):'〇一二三'[c],p=0)


      Try it online!






      share|improve this answer





















      • p=c>0&c<4&!p can be turned into p=14>>c&!p
        – Arnauld
        4 hours ago




















      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






      share|improve this answer



















      • 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
        8 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
        7 hours ago




















      up vote
      3
      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!






      share|improve this answer























      • 89 bytes
        – Shieru Asakoto
        15 hours ago












      • @ShieruAsakoto That's much better! Thanks a lot!
        – Arnauld
        15 hours ago


















      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





      share|improve this answer























      • -3 bytes with s/[123]K[123]/$&^$;/ge;y/--</一二三〇〡-〩/ (TIO)
        – Grimy
        4 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
        4 hours ago












      • 46: s/[123]{2}|./OS&$&/ge;y//〇〡-〰一二三/c (TIO)
        – Grimy
        3 hours ago


















      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!






      share|improve this answer






























        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!






        share|improve this answer






























          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!






          share|improve this answer




























            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






            share|improve this answer






























              up vote
              1
              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!






              share|improve this answer






























                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!






                share|improve this answer




























                  up vote
                  0
                  down vote














                  Jelly, 38 bytes



                  9Rż“øƓ“œ%“øƈ’;-25+⁽-EỌœị@DżD<4«Ɗ‘×¥ƊƊ


                  Try it online!






                  share|improve this answer




























                    up vote
                    0
                    down vote














                    Python 3, 106 bytes





                    n=input()
                    f=0
                    for i in n:f=i in'123'and 9-f;print(end='〇一二三〤〥〦〧〨〩〡〢〣'[int(i)+f])


                    Try it online!






                    share|improve this answer





















                      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
                      });


                      }
                      });














                      draft saved

                      draft discarded


















                      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

























                      14 Answers
                      14






                      active

                      oldest

                      votes








                      14 Answers
                      14






                      active

                      oldest

                      votes









                      active

                      oldest

                      votes






                      active

                      oldest

                      votes








                      up vote
                      4
                      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.






                      share|improve this answer

























                        up vote
                        4
                        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.






                        share|improve this answer























                          up vote
                          4
                          down vote










                          up vote
                          4
                          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.






                          share|improve this answer













                          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.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered 17 hours ago









                          Neil

                          78.8k744175




                          78.8k744175






















                              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.






                              share|improve this answer



























                                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.






                                share|improve this answer

























                                  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.






                                  share|improve this answer















                                  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.







                                  share|improve this answer














                                  share|improve this answer



                                  share|improve this answer








                                  edited 15 hours ago

























                                  answered 15 hours ago









                                  Οurous

                                  6,24811032




                                  6,24811032






















                                      up vote
                                      3
                                      down vote













                                      JavaScript, 83 bytes





                                      s=>s.replace(/./g,c=>(p=c>0&c<4&!p)|c>3?eval(`"\u302${c}"`):'〇一二三'[c],p=0)


                                      Try it online!






                                      share|improve this answer





















                                      • p=c>0&c<4&!p can be turned into p=14>>c&!p
                                        – Arnauld
                                        4 hours ago

















                                      up vote
                                      3
                                      down vote













                                      JavaScript, 83 bytes





                                      s=>s.replace(/./g,c=>(p=c>0&c<4&!p)|c>3?eval(`"\u302${c}"`):'〇一二三'[c],p=0)


                                      Try it online!






                                      share|improve this answer





















                                      • p=c>0&c<4&!p can be turned into p=14>>c&!p
                                        – Arnauld
                                        4 hours ago















                                      up vote
                                      3
                                      down vote










                                      up vote
                                      3
                                      down vote









                                      JavaScript, 83 bytes





                                      s=>s.replace(/./g,c=>(p=c>0&c<4&!p)|c>3?eval(`"\u302${c}"`):'〇一二三'[c],p=0)


                                      Try it online!






                                      share|improve this answer












                                      JavaScript, 83 bytes





                                      s=>s.replace(/./g,c=>(p=c>0&c<4&!p)|c>3?eval(`"\u302${c}"`):'〇一二三'[c],p=0)


                                      Try it online!







                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered 9 hours ago









                                      tsh

                                      8,23511546




                                      8,23511546












                                      • p=c>0&c<4&!p can be turned into p=14>>c&!p
                                        – Arnauld
                                        4 hours ago




















                                      • p=c>0&c<4&!p can be turned into p=14>>c&!p
                                        – Arnauld
                                        4 hours ago


















                                      p=c>0&c<4&!p can be turned into p=14>>c&!p
                                      – Arnauld
                                      4 hours ago






                                      p=c>0&c<4&!p can be turned into p=14>>c&!p
                                      – Arnauld
                                      4 hours ago












                                      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






                                      share|improve this answer



















                                      • 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
                                        8 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
                                        7 hours ago

















                                      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






                                      share|improve this answer



















                                      • 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
                                        8 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
                                        7 hours ago















                                      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






                                      share|improve this answer















                                      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







                                      share|improve this answer














                                      share|improve this answer



                                      share|improve this answer








                                      edited 7 hours ago

























                                      answered 8 hours ago









                                      Olivier Grégoire

                                      8,68711843




                                      8,68711843








                                      • 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
                                        8 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
                                        7 hours ago
















                                      • 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
                                        8 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
                                        7 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
                                      8 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
                                      8 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
                                      7 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
                                      7 hours ago












                                      up vote
                                      3
                                      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!






                                      share|improve this answer























                                      • 89 bytes
                                        – Shieru Asakoto
                                        15 hours ago












                                      • @ShieruAsakoto That's much better! Thanks a lot!
                                        – Arnauld
                                        15 hours ago















                                      up vote
                                      3
                                      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!






                                      share|improve this answer























                                      • 89 bytes
                                        – Shieru Asakoto
                                        15 hours ago












                                      • @ShieruAsakoto That's much better! Thanks a lot!
                                        – Arnauld
                                        15 hours ago













                                      up vote
                                      3
                                      down vote










                                      up vote
                                      3
                                      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!






                                      share|improve this answer














                                      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!







                                      share|improve this answer














                                      share|improve this answer



                                      share|improve this answer








                                      edited 4 hours ago

























                                      answered 17 hours ago









                                      Arnauld

                                      71.4k688299




                                      71.4k688299












                                      • 89 bytes
                                        – Shieru Asakoto
                                        15 hours ago












                                      • @ShieruAsakoto That's much better! Thanks a lot!
                                        – Arnauld
                                        15 hours ago


















                                      • 89 bytes
                                        – Shieru Asakoto
                                        15 hours ago












                                      • @ShieruAsakoto That's much better! Thanks a lot!
                                        – Arnauld
                                        15 hours ago
















                                      89 bytes
                                      – Shieru Asakoto
                                      15 hours ago






                                      89 bytes
                                      – Shieru Asakoto
                                      15 hours ago














                                      @ShieruAsakoto That's much better! Thanks a lot!
                                      – Arnauld
                                      15 hours ago




                                      @ShieruAsakoto That's much better! Thanks a lot!
                                      – Arnauld
                                      15 hours ago










                                      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





                                      share|improve this answer























                                      • -3 bytes with s/[123]K[123]/$&^$;/ge;y/--</一二三〇〡-〩/ (TIO)
                                        – Grimy
                                        4 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
                                        4 hours ago












                                      • 46: s/[123]{2}|./OS&$&/ge;y//〇〡-〰一二三/c (TIO)
                                        – Grimy
                                        3 hours ago















                                      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





                                      share|improve this answer























                                      • -3 bytes with s/[123]K[123]/$&^$;/ge;y/--</一二三〇〡-〩/ (TIO)
                                        – Grimy
                                        4 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
                                        4 hours ago












                                      • 46: s/[123]{2}|./OS&$&/ge;y//〇〡-〰一二三/c (TIO)
                                        – Grimy
                                        3 hours ago













                                      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





                                      share|improve this answer















                                      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






                                      share|improve this answer














                                      share|improve this answer



                                      share|improve this answer








                                      edited 3 hours ago

























                                      answered 17 hours ago









                                      nwellnhof

                                      6,4431125




                                      6,4431125












                                      • -3 bytes with s/[123]K[123]/$&^$;/ge;y/--</一二三〇〡-〩/ (TIO)
                                        – Grimy
                                        4 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
                                        4 hours ago












                                      • 46: s/[123]{2}|./OS&$&/ge;y//〇〡-〰一二三/c (TIO)
                                        – Grimy
                                        3 hours ago


















                                      • -3 bytes with s/[123]K[123]/$&^$;/ge;y/--</一二三〇〡-〩/ (TIO)
                                        – Grimy
                                        4 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
                                        4 hours ago












                                      • 46: s/[123]{2}|./OS&$&/ge;y//〇〡-〰一二三/c (TIO)
                                        – Grimy
                                        3 hours ago
















                                      -3 bytes with s/[123]K[123]/$&^$;/ge;y/--</一二三〇〡-〩/ (TIO)
                                      – Grimy
                                      4 hours ago






                                      -3 bytes with s/[123]K[123]/$&^$;/ge;y/--</一二三〇〡-〩/ (TIO)
                                      – Grimy
                                      4 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
                                      4 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
                                      4 hours ago














                                      46: s/[123]{2}|./OS&$&/ge;y//〇〡-〰一二三/c (TIO)
                                      – Grimy
                                      3 hours ago




                                      46: s/[123]{2}|./OS&$&/ge;y//〇〡-〰一二三/c (TIO)
                                      – Grimy
                                      3 hours ago










                                      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!






                                      share|improve this answer



























                                        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!






                                        share|improve this answer

























                                          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!






                                          share|improve this answer















                                          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!







                                          share|improve this answer














                                          share|improve this answer



                                          share|improve this answer








                                          edited 16 hours ago

























                                          answered 17 hours ago









                                          nwellnhof

                                          6,4431125




                                          6,4431125






















                                              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!






                                              share|improve this answer



























                                                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!






                                                share|improve this answer

























                                                  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!






                                                  share|improve this answer















                                                  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!







                                                  share|improve this answer














                                                  share|improve this answer



                                                  share|improve this answer








                                                  edited 3 hours ago

























                                                  answered 3 hours ago









                                                  J.Doe

                                                  2,139112




                                                  2,139112






















                                                      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!






                                                      share|improve this answer

























                                                        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!






                                                        share|improve this answer























                                                          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!






                                                          share|improve this answer













                                                          Ruby -p, 71 bytes





                                                          $_=gsub(/[1-3]K[1-3]/){|x|(x.ord+9).chr}.tr"0-<","〇〡-〩一二三"


                                                          Try it online!







                                                          share|improve this answer












                                                          share|improve this answer



                                                          share|improve this answer










                                                          answered 8 hours ago









                                                          Kirill L.

                                                          3,4951218




                                                          3,4951218






















                                                              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






                                                              share|improve this answer



























                                                                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






                                                                share|improve this answer

























                                                                  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






                                                                  share|improve this answer















                                                                  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







                                                                  share|improve this answer














                                                                  share|improve this answer



                                                                  share|improve this answer








                                                                  edited 7 hours ago

























                                                                  answered 8 hours ago









                                                                  ngn

                                                                  6,67312459




                                                                  6,67312459






















                                                                      up vote
                                                                      1
                                                                      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!






                                                                      share|improve this answer



























                                                                        up vote
                                                                        1
                                                                        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!






                                                                        share|improve this answer

























                                                                          up vote
                                                                          1
                                                                          down vote










                                                                          up vote
                                                                          1
                                                                          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!






                                                                          share|improve this answer















                                                                          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!







                                                                          share|improve this answer














                                                                          share|improve this answer



                                                                          share|improve this answer








                                                                          edited 7 hours ago

























                                                                          answered 8 hours ago









                                                                          Galen Ivanov

                                                                          6,13711032




                                                                          6,13711032






















                                                                              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!






                                                                              share|improve this answer

























                                                                                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!






                                                                                share|improve this answer























                                                                                  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!






                                                                                  share|improve this answer












                                                                                  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!







                                                                                  share|improve this answer












                                                                                  share|improve this answer



                                                                                  share|improve this answer










                                                                                  answered 2 hours ago









                                                                                  zruF

                                                                                  495




                                                                                  495






















                                                                                      up vote
                                                                                      0
                                                                                      down vote














                                                                                      Jelly, 38 bytes



                                                                                      9Rż“øƓ“œ%“øƈ’;-25+⁽-EỌœị@DżD<4«Ɗ‘×¥ƊƊ


                                                                                      Try it online!






                                                                                      share|improve this answer

























                                                                                        up vote
                                                                                        0
                                                                                        down vote














                                                                                        Jelly, 38 bytes



                                                                                        9Rż“øƓ“œ%“øƈ’;-25+⁽-EỌœị@DżD<4«Ɗ‘×¥ƊƊ


                                                                                        Try it online!






                                                                                        share|improve this answer























                                                                                          up vote
                                                                                          0
                                                                                          down vote










                                                                                          up vote
                                                                                          0
                                                                                          down vote










                                                                                          Jelly, 38 bytes



                                                                                          9Rż“øƓ“œ%“øƈ’;-25+⁽-EỌœị@DżD<4«Ɗ‘×¥ƊƊ


                                                                                          Try it online!






                                                                                          share|improve this answer













                                                                                          Jelly, 38 bytes



                                                                                          9Rż“øƓ“œ%“øƈ’;-25+⁽-EỌœị@DżD<4«Ɗ‘×¥ƊƊ


                                                                                          Try it online!







                                                                                          share|improve this answer












                                                                                          share|improve this answer



                                                                                          share|improve this answer










                                                                                          answered 34 mins ago









                                                                                          Erik the Outgolfer

                                                                                          31.1k429102




                                                                                          31.1k429102






















                                                                                              up vote
                                                                                              0
                                                                                              down vote














                                                                                              Python 3, 106 bytes





                                                                                              n=input()
                                                                                              f=0
                                                                                              for i in n:f=i in'123'and 9-f;print(end='〇一二三〤〥〦〧〨〩〡〢〣'[int(i)+f])


                                                                                              Try it online!






                                                                                              share|improve this answer

























                                                                                                up vote
                                                                                                0
                                                                                                down vote














                                                                                                Python 3, 106 bytes





                                                                                                n=input()
                                                                                                f=0
                                                                                                for i in n:f=i in'123'and 9-f;print(end='〇一二三〤〥〦〧〨〩〡〢〣'[int(i)+f])


                                                                                                Try it online!






                                                                                                share|improve this answer























                                                                                                  up vote
                                                                                                  0
                                                                                                  down vote










                                                                                                  up vote
                                                                                                  0
                                                                                                  down vote










                                                                                                  Python 3, 106 bytes





                                                                                                  n=input()
                                                                                                  f=0
                                                                                                  for i in n:f=i in'123'and 9-f;print(end='〇一二三〤〥〦〧〨〩〡〢〣'[int(i)+f])


                                                                                                  Try it online!






                                                                                                  share|improve this answer













                                                                                                  Python 3, 106 bytes





                                                                                                  n=input()
                                                                                                  f=0
                                                                                                  for i in n:f=i in'123'and 9-f;print(end='〇一二三〤〥〦〧〨〩〡〢〣'[int(i)+f])


                                                                                                  Try it online!







                                                                                                  share|improve this answer












                                                                                                  share|improve this answer



                                                                                                  share|improve this answer










                                                                                                  answered 16 mins ago









                                                                                                  Erik the Outgolfer

                                                                                                  31.1k429102




                                                                                                  31.1k429102






























                                                                                                      draft saved

                                                                                                      draft discarded




















































                                                                                                      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.




                                                                                                      draft saved


                                                                                                      draft discarded














                                                                                                      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





















































                                                                                                      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







                                                                                                      Popular posts from this blog

                                                                                                      Ellipse (mathématiques)

                                                                                                      Quarter-circle Tiles

                                                                                                      Mont Emei