Strange Addition











up vote
19
down vote

favorite
2












Challenge



Calculate the strange sum of two natural numbers (also known as lunar addition):



Given A=... a2 a1 a0 and B=... b2 b1 b0 two natural numbers written in the decimal base, the strange sum is defined, based on the maximum operation, as:
A+B=... max(a2,b2) max(a1,b1) max(a0,b0)



   ...         a2         a1         a0
+ ... b2 b1 b0
----------------------------------------
... max(a2,b2) max(a1,b1) max(a0,b0)


Input



Two natural numbers



All the following is allowed:




  • Zero-padded strings (same length)

  • Left-space-padded strings

  • Right-space-padded strings

  • Array of two padded strings

  • 2D space-padded char array


Output



A natural numbers



Example



1999+2018-->2999
17210+701-->17711
32+17-->37
308+250-->358
308+25-->328


Rules




  • The input and output can be given in any convenient format (choose the most appropriate format for your language/solution).

  • No need to handle negative values or invalid input

  • Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.

  • If possible, please include a link to an online testing environment so other people can try out your code!


  • Standard loopholes are forbidden.

  • This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.










share|improve this question




















  • 1




    also known as lunar addition
    – TFeld
    2 days ago








  • 3




    Can we take the input as zero-padded strings (same length)?
    – TFeld
    2 days ago






  • 2




    Right now, the challenge rules allow for zero-padded strings/arrays as that would be a "convenient format". If you intend to disallow zero-padding then please update the rules to explicitly state so.
    – Shaggy
    2 days ago






  • 2




    @mdahmoune, can you please address the issue that's been brought up multiple times now: Are leading zeros in the inputs allowed or not?
    – Shaggy
    yesterday






  • 7




    I fail to see what input formats are allowed exactly. The input format is very important in this challenge, as some formats allow much easier processing. What of the following are allowed? 1) Zero-padded strings (same length) 2) Left-space-padded strings 3) Right-space-padded strings. 4) Array of two padded strings. 5) 2D space-padded char array. Voting to close and downvoting for now; I will happily remove my votes when solved
    – Luis Mendo
    yesterday

















up vote
19
down vote

favorite
2












Challenge



Calculate the strange sum of two natural numbers (also known as lunar addition):



Given A=... a2 a1 a0 and B=... b2 b1 b0 two natural numbers written in the decimal base, the strange sum is defined, based on the maximum operation, as:
A+B=... max(a2,b2) max(a1,b1) max(a0,b0)



   ...         a2         a1         a0
+ ... b2 b1 b0
----------------------------------------
... max(a2,b2) max(a1,b1) max(a0,b0)


Input



Two natural numbers



All the following is allowed:




  • Zero-padded strings (same length)

  • Left-space-padded strings

  • Right-space-padded strings

  • Array of two padded strings

  • 2D space-padded char array


Output



A natural numbers



Example



1999+2018-->2999
17210+701-->17711
32+17-->37
308+250-->358
308+25-->328


Rules




  • The input and output can be given in any convenient format (choose the most appropriate format for your language/solution).

  • No need to handle negative values or invalid input

  • Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.

  • If possible, please include a link to an online testing environment so other people can try out your code!


  • Standard loopholes are forbidden.

  • This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.










share|improve this question




















  • 1




    also known as lunar addition
    – TFeld
    2 days ago








  • 3




    Can we take the input as zero-padded strings (same length)?
    – TFeld
    2 days ago






  • 2




    Right now, the challenge rules allow for zero-padded strings/arrays as that would be a "convenient format". If you intend to disallow zero-padding then please update the rules to explicitly state so.
    – Shaggy
    2 days ago






  • 2




    @mdahmoune, can you please address the issue that's been brought up multiple times now: Are leading zeros in the inputs allowed or not?
    – Shaggy
    yesterday






  • 7




    I fail to see what input formats are allowed exactly. The input format is very important in this challenge, as some formats allow much easier processing. What of the following are allowed? 1) Zero-padded strings (same length) 2) Left-space-padded strings 3) Right-space-padded strings. 4) Array of two padded strings. 5) 2D space-padded char array. Voting to close and downvoting for now; I will happily remove my votes when solved
    – Luis Mendo
    yesterday















up vote
19
down vote

favorite
2









up vote
19
down vote

favorite
2






2





Challenge



Calculate the strange sum of two natural numbers (also known as lunar addition):



Given A=... a2 a1 a0 and B=... b2 b1 b0 two natural numbers written in the decimal base, the strange sum is defined, based on the maximum operation, as:
A+B=... max(a2,b2) max(a1,b1) max(a0,b0)



   ...         a2         a1         a0
+ ... b2 b1 b0
----------------------------------------
... max(a2,b2) max(a1,b1) max(a0,b0)


Input



Two natural numbers



All the following is allowed:




  • Zero-padded strings (same length)

  • Left-space-padded strings

  • Right-space-padded strings

  • Array of two padded strings

  • 2D space-padded char array


Output



A natural numbers



Example



1999+2018-->2999
17210+701-->17711
32+17-->37
308+250-->358
308+25-->328


Rules




  • The input and output can be given in any convenient format (choose the most appropriate format for your language/solution).

  • No need to handle negative values or invalid input

  • Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.

  • If possible, please include a link to an online testing environment so other people can try out your code!


  • Standard loopholes are forbidden.

  • This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.










share|improve this question















Challenge



Calculate the strange sum of two natural numbers (also known as lunar addition):



Given A=... a2 a1 a0 and B=... b2 b1 b0 two natural numbers written in the decimal base, the strange sum is defined, based on the maximum operation, as:
A+B=... max(a2,b2) max(a1,b1) max(a0,b0)



   ...         a2         a1         a0
+ ... b2 b1 b0
----------------------------------------
... max(a2,b2) max(a1,b1) max(a0,b0)


Input



Two natural numbers



All the following is allowed:




  • Zero-padded strings (same length)

  • Left-space-padded strings

  • Right-space-padded strings

  • Array of two padded strings

  • 2D space-padded char array


Output



A natural numbers



Example



1999+2018-->2999
17210+701-->17711
32+17-->37
308+250-->358
308+25-->328


Rules




  • The input and output can be given in any convenient format (choose the most appropriate format for your language/solution).

  • No need to handle negative values or invalid input

  • Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.

  • If possible, please include a link to an online testing environment so other people can try out your code!


  • Standard loopholes are forbidden.

  • This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.







code-golf math arithmetic






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited yesterday

























asked 2 days ago









mdahmoune

1,2521621




1,2521621








  • 1




    also known as lunar addition
    – TFeld
    2 days ago








  • 3




    Can we take the input as zero-padded strings (same length)?
    – TFeld
    2 days ago






  • 2




    Right now, the challenge rules allow for zero-padded strings/arrays as that would be a "convenient format". If you intend to disallow zero-padding then please update the rules to explicitly state so.
    – Shaggy
    2 days ago






  • 2




    @mdahmoune, can you please address the issue that's been brought up multiple times now: Are leading zeros in the inputs allowed or not?
    – Shaggy
    yesterday






  • 7




    I fail to see what input formats are allowed exactly. The input format is very important in this challenge, as some formats allow much easier processing. What of the following are allowed? 1) Zero-padded strings (same length) 2) Left-space-padded strings 3) Right-space-padded strings. 4) Array of two padded strings. 5) 2D space-padded char array. Voting to close and downvoting for now; I will happily remove my votes when solved
    – Luis Mendo
    yesterday
















  • 1




    also known as lunar addition
    – TFeld
    2 days ago








  • 3




    Can we take the input as zero-padded strings (same length)?
    – TFeld
    2 days ago






  • 2




    Right now, the challenge rules allow for zero-padded strings/arrays as that would be a "convenient format". If you intend to disallow zero-padding then please update the rules to explicitly state so.
    – Shaggy
    2 days ago






  • 2




    @mdahmoune, can you please address the issue that's been brought up multiple times now: Are leading zeros in the inputs allowed or not?
    – Shaggy
    yesterday






  • 7




    I fail to see what input formats are allowed exactly. The input format is very important in this challenge, as some formats allow much easier processing. What of the following are allowed? 1) Zero-padded strings (same length) 2) Left-space-padded strings 3) Right-space-padded strings. 4) Array of two padded strings. 5) 2D space-padded char array. Voting to close and downvoting for now; I will happily remove my votes when solved
    – Luis Mendo
    yesterday










1




1




also known as lunar addition
– TFeld
2 days ago






also known as lunar addition
– TFeld
2 days ago






3




3




Can we take the input as zero-padded strings (same length)?
– TFeld
2 days ago




Can we take the input as zero-padded strings (same length)?
– TFeld
2 days ago




2




2




Right now, the challenge rules allow for zero-padded strings/arrays as that would be a "convenient format". If you intend to disallow zero-padding then please update the rules to explicitly state so.
– Shaggy
2 days ago




Right now, the challenge rules allow for zero-padded strings/arrays as that would be a "convenient format". If you intend to disallow zero-padding then please update the rules to explicitly state so.
– Shaggy
2 days ago




2




2




@mdahmoune, can you please address the issue that's been brought up multiple times now: Are leading zeros in the inputs allowed or not?
– Shaggy
yesterday




@mdahmoune, can you please address the issue that's been brought up multiple times now: Are leading zeros in the inputs allowed or not?
– Shaggy
yesterday




7




7




I fail to see what input formats are allowed exactly. The input format is very important in this challenge, as some formats allow much easier processing. What of the following are allowed? 1) Zero-padded strings (same length) 2) Left-space-padded strings 3) Right-space-padded strings. 4) Array of two padded strings. 5) 2D space-padded char array. Voting to close and downvoting for now; I will happily remove my votes when solved
– Luis Mendo
yesterday






I fail to see what input formats are allowed exactly. The input format is very important in this challenge, as some formats allow much easier processing. What of the following are allowed? 1) Zero-padded strings (same length) 2) Left-space-padded strings 3) Right-space-padded strings. 4) Array of two padded strings. 5) 2D space-padded char array. Voting to close and downvoting for now; I will happily remove my votes when solved
– Luis Mendo
yesterday












25 Answers
25






active

oldest

votes

















up vote
11
down vote














Python 2, 20 bytes





lambda*a:map(max,*a)


Try it online!



I/O as 0-pre-padded lists of digits.






share|improve this answer






























    up vote
    10
    down vote














    Jelly, 1 byte



    »


    Try it online!



    I/O as 0-pre-padded lists of digits.






    share|improve this answer






























      up vote
      7
      down vote














      R, 68 65 bytes





      function(x)apply(outer(x,10^(max(nchar(x)):1-1),`%/%`)%%10,2,max)


      Try it online!



      Input as integers, output as list of digits.



      If zero-padding lists of digits was allowed, then simply pmax would suffice.






      share|improve this answer






























        up vote
        6
        down vote














        MATL, 2 bytes



        X>



        Choose the most appropriate format for your language/solution




        The input format is: 2D char array of two rows, each corresponding to a line, with the shorter number left-padded with spaces. For example



        17210
        701


        which in MATL is defined as



        ['17210'; '  701']


        Try it online!



        Explanation



              % Implicit input: 2D char array with two rows 
        X> % Take maximum of (code points of) each column
        % Implicit display





        share|improve this answer




























          up vote
          5
          down vote














          Python 2, 73 60 56 bytes





          lambda a,b:map(max,zip(a.rjust(len(b)),b.rjust(len(a))))


          Try it online!



          Takes input as two strings, and returns a list of digits





          Alternative:



          Takes input as two integers; same output




          Python 2, 60 59 bytes





          lambda*i:map(max,zip(*['%*d'%(len(`max(i)`),v)for v in i]))


          Try it online!






          share|improve this answer






























            up vote
            4
            down vote














            J, 14 12 bytes



            -2 bytes thanks to Jonah



            (>./@,:)&.|.


            Try it online!



            Input and output as list(s) of digits






            share|improve this answer



















            • 1




              12 bytes: (>./@,:)&.|.. Try it online!
              – Jonah
              yesterday








            • 1




              @Jonah Of course! Thank you!
              – Galen Ivanov
              yesterday






            • 1




              if you’re looking for a challenge, see if you can improve this monstrosity: codegolf.stackexchange.com/a/175968/15469
              – Jonah
              yesterday


















            up vote
            4
            down vote













            Japt, 9 8 7 bytes



            Takes input as an array of digit arrays.



            mÔÕÔËrw


            Try it



            m            :Map
            Ô : Reverse
            Õ :Transpose
            Ô :Reverse
            Ë :Map
            r : Reduce by
            w : Maximum




            If taking zero-padded arrays as input is permitted (it would currently fall under a "convenient format" but I suspect that's not the challenger's intent) then this can be 3 bytes.



            íwV


            Try it



            í       :Interleave the first input
            V :With the second
            w :Reduce each pair by maximum





            share|improve this answer



















            • 1




              Here's another 8 byte solution with a different strategy and simpler input format. maybe you can shave a byte from that?
              – Kamil Drakari
              yesterday










            • @KamilDrakari: Uncanny - I was just updating with the exact same solution!
              – Shaggy
              yesterday










            • Interestingly, the version that separates the "transpose" and "reduce" steps is also 8 bytes because of better shortcuts
              – Kamil Drakari
              yesterday










            • @KamilDrakari, oh, we have a shortcut for y now? I did not know that. Here's another way, also 8 bytes.
              – Shaggy
              yesterday










            • Ooh, that's a neat trick with '. I don't know whether that would ever save bytes, but it's definitely cool.
              – Kamil Drakari
              yesterday


















            up vote
            4
            down vote














            Perl 6, 37 bytes



            {[R~] roundrobin($_».reverse)».max}


            Try it online!



            Takes input as a list of lists of digits.






            share|improve this answer




























              up vote
              4
              down vote














              05AB1E, 9 6 5 bytes



              -3 thanks to Emigna

              -1 thanks to Shaggy



              íζ€àR


              Takes input as a list of lists of digits



              í      # Reverse both inputs
              ζ # Zip
              ۈ # Keep the bigger digits
              R # Reverse


              Try it online! or Try all test cases






              share|improve this answer























              • €R can be í. Also, I don't think you need €þ as number > space
                – Emigna
                yesterday










              • @Emigna Thanks! I thought I tried it without €þ and it didn't work, but now it does...
                – Riley
                yesterday










              • Do you need the J at the end?
                – Shaggy
                yesterday










              • @Shaggy No, I guess I don't. Thanks!
                – Riley
                yesterday










              • It's lame, but the rules allow a 3 byte solution by taking a 2D space-padded char array..
                – Kevin Cruijssen
                yesterday


















              up vote
              4
              down vote













              Java 10, 78 57 bytes





              a->b->{for(int i=a.length;i-->0;)if(a[i]<b[i])a[i]=b[i];}


              Input as two space-padded character arrays.



              Modifies the first input-array instead of returning a new one to save 21 bytes (thanks to @OlivierGrégoire).



              Try it online.



              Explanation:



              a->b->{            // Method with two char-array parameters and String return-type
              for(int i=a.length;i-->0;)
              // Loop `i` in the range (length, 0]:
              if(a[i]<b[i]) // If the `i`'th character in input `a` is smaller than in input `b`:
              a[i]=b[i];} // Change the `i`'th character in `a` to the `i`'th character of `b`





              share|improve this answer



















              • 1




                a->b->{for(int i=a.length;i-->0;)if(a[i]<b[i])a[i]=b[i];} (57 bytes). Reuse a as output to gain much, much bytes.
                – Olivier Grégoire
                yesterday










              • @OlivierGrégoire Ah, can't believe I hadn't thought of that. Thanks! :D
                – Kevin Cruijssen
                yesterday


















              up vote
              3
              down vote














              Haskell, 40 bytes





              a#b=zipWith max(p b++a)$p a++b
              p=(' '<$)


              Input/output as strings, try it online!



              Explanation



              The function p replaces each character by a space, using p b++a and p a++b are thus the same length. This way we can use zipWith without losing any elements, using max with it works because a (space) has lower codepoint than any of the characters ['0'..'9'].






              share|improve this answer






























                up vote
                3
                down vote













                JavaScript (ES6), 51 49 bytes



                NB: This answer was posted before the loose I/O formats were explicitly allowed. With zero-padded arrays of digits, this can be done in 33 bytes, (but is much less interesting, IMHO).



                Takes input as two integers. Returns an integer.





                f=(a,b,t=10)=>a|b&&(a%t<b%t?b:a)%t+t*f(a/t,b/t)|0


                Try it online!



                Commented



                f = (                     // f = recursive function taking:
                a, // a = first integer
                b, // b = second integer
                t = 10 // t = 10 (which is used 6 times below)
                ) => //
                a | b // bitwise OR between a and b to test whether at least one of
                // them still has an integer part
                && // if not, stop recursion; otherwise:
                ( //
                a % t < b % t ? b : a // if a % 10 is less than b % 10: use b; otherwise: use a
                ) % t + // isolate the last decimal digit of the selected number
                t * // add 10 times the result of
                f(a / t, b / t) // a recursive call with a / 10 and b / 10
                | 0 // bitwise OR with 0 to isolate the integer part


                Alternate version



                Same I/O format.



                f=(a,b)=>a|b&&[f(a/10,b/10)]+(a%10<b%10?b:a)%10|0


                Try it online!






                share|improve this answer























                • You can get much shorter if you assume your input to be a 2d space padded char array.
                  – kamoroso94
                  yesterday










                • Hi! Could you provide some explanation? I ""tried"" to do this challenge in JavaScript but I failed and would like to see how your solution works :)
                  – Neyt
                  yesterday






                • 1




                  @Neyt I've added a commented version. The alternate version is using the same logic; the only difference is that we add the next digit to the left as a string instead of multiplying the result of the recursive call by 10.
                  – Arnauld
                  yesterday










                • @Arnauld Thank you! :)
                  – Neyt
                  yesterday


















                up vote
                3
                down vote














                Perl 6, 15 bytes





                {[~] [Zmax] $_}


                Try it online!



                Takes input as a list of space padded arrays of characters, though for this challenge the lax input format makes it rather boring. Alternatively, here's the program that takes a list of two integers instead:




                Perl 6, 41 bytes





                {+[~] [Zmax] $_>>.fmt("%{.max}d")>>.comb}


                Try it online!



                If you don't mind a huge amount of whitespace, you can also remove the + from the front.



                Explanation:



                {                                       }  # Anonymous code block
                $_>> # Map each integer to
                .fmt("%{.max}d") # The number padded by the max of the list spaces
                >>.comb # And split each to list of characters
                [Zmax] # Get the max of each digit at each index
                # This works because space is coerced to 0
                # Otherwise we would have to add a 0 to the formatting string
                [~] # Join the list of digits and spaces
                + # And coerce the string to a number to get rid of leading whitespace





                share|improve this answer






























                  up vote
                  2
                  down vote














                  Tcl, 156 bytes



                  proc S a b {join [lmap x [split [format %0[set l [expr max([string le $a],[string le $b])]]d $a] ""] y [split [format %0$ld $b] ""] {expr max($x,$y)}] ""}


                  Try it online!



                  Not very golfy, but I had to give a try on it. Will golf it later!






                  share|improve this answer





















                  • Tcl, 159 bytes Failed outgolf
                    – sergiol
                    yesterday


















                  up vote
                  2
                  down vote













                  Batch, 120 bytes



                  @set/aw=1,x=%1,y=%2,z=0
                  @for /l %%i in (0,1,9)do @set/a"z+=w*((v=y%%10)+(v-=x%%10)*(v>>4)),y/=10,x/=10,w*=10
                  @echo %z%


                  Takes input as command-line parameters. 188-byte version works on arbitrary length integers:



                  @set/px=
                  @set/py=
                  @set z=
                  :l
                  @if %x:~-1% gtr %y:~-1% (set z=%x:~-1%%z%)else set z=%y:~-1%%z%
                  @set x=%x:~,-1%
                  @set y=%y:~,-1%
                  @if "%x%" neq "" if "%y%" neq "" goto l
                  @echo %x%%y%%z%


                  Takes input on STDIN.






                  share|improve this answer




























                    up vote
                    1
                    down vote














                    Husk, 5 bytes



                    ↔¤żY↔


                    Conveniently takes input/output as list of digits, try it online or verify all!



                    Explanation



                    ↔¤żY↔  -- example inputs [1,4] [3,2]
                    ¤ ↔ -- reverse the arguments of: [4,1] [2,3]
                    żY -- | zipWith (keeping elements of longer) max: [4,3]
                    ↔ -- reverse: [3,4]





                    share|improve this answer




























                      up vote
                      1
                      down vote














                      Stax, 5 bytes



                      |>E:o


                      Run and debug it



                      This program takes input as an array of strings.



                      |>  Right align inputs (filling with )
                      E "Explode" array onto stack separately
                      :o "Overlay" Keep the maximum element respective element from two arrays.


                      Run this one



                      This is the first time I've seen a use for the overlay instruction "in the wild".






                      share|improve this answer




























                        up vote
                        1
                        down vote














                        SNOBOL4 (CSNOBOL4), 153 bytes



                        	X =INPUT
                        Y =INPUT
                        Y =DUPL(0,SIZE(X) - SIZE(Y)) Y
                        S X LEN(1) . A REM . X :F(O)
                        Y LEN(1) . B REM . Y
                        O =O GT(A,B) A :S(S)
                        O =O B :(S)
                        O OUTPUT =O
                        END


                        Try it online!






                        share|improve this answer




























                          up vote
                          1
                          down vote














                          Retina, 45 bytes



                          P^`.+
                          +`^(.*)(.)¶(.*)(.)
                          $1¶$3¶$2$4
                          %O`.
                          ¶.?



                          Try it online! Link includes test suite. Explanation:



                          P^`.+


                          Pad both values to the same length.



                          +`^(.*)(.)¶(.*)(.)
                          $1¶$3¶$2$4


                          Transpose the values.



                          %O`.


                          Sort each pair into order.



                          ¶.?



                          Delete all the low digits and surplus newlines.






                          share|improve this answer




























                            up vote
                            1
                            down vote














                            Charcoal, 14 bytes



                            ⭆◧θLη⌈⟦ι§◧ηLθκ


                            Try it online! Link is to verbose version of code. Explanation:



                              θ             First input
                            ◧ Padded to
                            L Length of
                            η Second input
                            ⭆ Map over characters and join
                            ⌈ Maximum of
                            ⟦ List of
                            ι Current character of first input and
                            η Second input
                            ◧ Padded to
                            L Length of
                            θ First input
                            § Indexed by
                            κ Current index
                            Implicitly print


                            17-byte version "adds" any number of strings:



                            ≔⌈EθLιη⭆η⌈Eθ§◧ληκ


                            Try it online! Link is to verbose version of code.






                            share|improve this answer




























                              up vote
                              1
                              down vote













                              Pyth, 5 bytes



                              meSdC


                              Takes input as array of two space-padded strings.



                              meSd       map greatest
                              C on the transpose of input


                              Try it here.






                              share|improve this answer




























                                up vote
                                1
                                down vote














                                Twig, 125 bytes



                                When I saw this challenge, I though: "let me use a template language! sure is a good fit"



                                I was wrong ... so wrong .... ... But was fun!



                                {%macro a(a,b,s='')%}{%for k,x in a|reverse|split('')%}{%set s=max(x,(b|reverse|split('')[k]))~s%}{%endfor%}{{s}}{%endmacro%}


                                This requires that "strict_variables" is set to false (default value).



                                To use this macro, you can do like this:



                                {% import 'file.twig' as my_macro %}

                                {{ my_macro.a(195,67) }}


                                Should display 167.



                                You can try this in https://twigfiddle.com/rg0biy

                                ("strict_variables" set to off, it is on by default on the website)






                                share|improve this answer




























                                  up vote
                                  1
                                  down vote














                                  C# (.NET Core), 58 bytes



                                  (a,b)=>a.Select((x,i)=>a[i]>b[i]?x:b[i])


                                  Try It Online






                                  share|improve this answer




























                                    up vote
                                    1
                                    down vote














                                    Japt, 4 bytes



                                    Input is taken as a an array of two 0-padded number arrays.



                                    y_rw


                                    Try it online!






                                    share|improve this answer




























                                      up vote
                                      0
                                      down vote













                                      Mathematica 50 bytes



                                      a = 543;
                                      b = 791;



                                      FromDigits@MapThread[Max, IntegerDigits /@ {a, b}]


                                      (* 793 *)






                                      share|improve this answer

















                                      • 1




                                        Can you add a TIO? I don't know Mathematica but I suspect this might fail if the 2 inputs don't have an equal number of digits.
                                        – Shaggy
                                        yesterday






                                      • 1




                                        I think you're taking input through predefined variables, which would make this a snippet, which is not allowed. Submissions should be either a function or a full program
                                        – Jo King
                                        yesterday











                                      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%2f176010%2fstrange-addition%23new-answer', 'question_page');
                                      }
                                      );

                                      Post as a guest















                                      Required, but never shown

























                                      25 Answers
                                      25






                                      active

                                      oldest

                                      votes








                                      25 Answers
                                      25






                                      active

                                      oldest

                                      votes









                                      active

                                      oldest

                                      votes






                                      active

                                      oldest

                                      votes








                                      up vote
                                      11
                                      down vote














                                      Python 2, 20 bytes





                                      lambda*a:map(max,*a)


                                      Try it online!



                                      I/O as 0-pre-padded lists of digits.






                                      share|improve this answer



























                                        up vote
                                        11
                                        down vote














                                        Python 2, 20 bytes





                                        lambda*a:map(max,*a)


                                        Try it online!



                                        I/O as 0-pre-padded lists of digits.






                                        share|improve this answer

























                                          up vote
                                          11
                                          down vote










                                          up vote
                                          11
                                          down vote










                                          Python 2, 20 bytes





                                          lambda*a:map(max,*a)


                                          Try it online!



                                          I/O as 0-pre-padded lists of digits.






                                          share|improve this answer















                                          Python 2, 20 bytes





                                          lambda*a:map(max,*a)


                                          Try it online!



                                          I/O as 0-pre-padded lists of digits.







                                          share|improve this answer














                                          share|improve this answer



                                          share|improve this answer








                                          edited yesterday

























                                          answered 2 days ago









                                          Erik the Outgolfer

                                          30.6k428102




                                          30.6k428102






















                                              up vote
                                              10
                                              down vote














                                              Jelly, 1 byte



                                              »


                                              Try it online!



                                              I/O as 0-pre-padded lists of digits.






                                              share|improve this answer



























                                                up vote
                                                10
                                                down vote














                                                Jelly, 1 byte



                                                »


                                                Try it online!



                                                I/O as 0-pre-padded lists of digits.






                                                share|improve this answer

























                                                  up vote
                                                  10
                                                  down vote










                                                  up vote
                                                  10
                                                  down vote










                                                  Jelly, 1 byte



                                                  »


                                                  Try it online!



                                                  I/O as 0-pre-padded lists of digits.






                                                  share|improve this answer















                                                  Jelly, 1 byte



                                                  »


                                                  Try it online!



                                                  I/O as 0-pre-padded lists of digits.







                                                  share|improve this answer














                                                  share|improve this answer



                                                  share|improve this answer








                                                  edited yesterday

























                                                  answered 2 days ago









                                                  Erik the Outgolfer

                                                  30.6k428102




                                                  30.6k428102






















                                                      up vote
                                                      7
                                                      down vote














                                                      R, 68 65 bytes





                                                      function(x)apply(outer(x,10^(max(nchar(x)):1-1),`%/%`)%%10,2,max)


                                                      Try it online!



                                                      Input as integers, output as list of digits.



                                                      If zero-padding lists of digits was allowed, then simply pmax would suffice.






                                                      share|improve this answer



























                                                        up vote
                                                        7
                                                        down vote














                                                        R, 68 65 bytes





                                                        function(x)apply(outer(x,10^(max(nchar(x)):1-1),`%/%`)%%10,2,max)


                                                        Try it online!



                                                        Input as integers, output as list of digits.



                                                        If zero-padding lists of digits was allowed, then simply pmax would suffice.






                                                        share|improve this answer

























                                                          up vote
                                                          7
                                                          down vote










                                                          up vote
                                                          7
                                                          down vote










                                                          R, 68 65 bytes





                                                          function(x)apply(outer(x,10^(max(nchar(x)):1-1),`%/%`)%%10,2,max)


                                                          Try it online!



                                                          Input as integers, output as list of digits.



                                                          If zero-padding lists of digits was allowed, then simply pmax would suffice.






                                                          share|improve this answer















                                                          R, 68 65 bytes





                                                          function(x)apply(outer(x,10^(max(nchar(x)):1-1),`%/%`)%%10,2,max)


                                                          Try it online!



                                                          Input as integers, output as list of digits.



                                                          If zero-padding lists of digits was allowed, then simply pmax would suffice.







                                                          share|improve this answer














                                                          share|improve this answer



                                                          share|improve this answer








                                                          edited yesterday

























                                                          answered 2 days ago









                                                          Giuseppe

                                                          15.9k31052




                                                          15.9k31052






















                                                              up vote
                                                              6
                                                              down vote














                                                              MATL, 2 bytes



                                                              X>



                                                              Choose the most appropriate format for your language/solution




                                                              The input format is: 2D char array of two rows, each corresponding to a line, with the shorter number left-padded with spaces. For example



                                                              17210
                                                              701


                                                              which in MATL is defined as



                                                              ['17210'; '  701']


                                                              Try it online!



                                                              Explanation



                                                                    % Implicit input: 2D char array with two rows 
                                                              X> % Take maximum of (code points of) each column
                                                              % Implicit display





                                                              share|improve this answer

























                                                                up vote
                                                                6
                                                                down vote














                                                                MATL, 2 bytes



                                                                X>



                                                                Choose the most appropriate format for your language/solution




                                                                The input format is: 2D char array of two rows, each corresponding to a line, with the shorter number left-padded with spaces. For example



                                                                17210
                                                                701


                                                                which in MATL is defined as



                                                                ['17210'; '  701']


                                                                Try it online!



                                                                Explanation



                                                                      % Implicit input: 2D char array with two rows 
                                                                X> % Take maximum of (code points of) each column
                                                                % Implicit display





                                                                share|improve this answer























                                                                  up vote
                                                                  6
                                                                  down vote










                                                                  up vote
                                                                  6
                                                                  down vote










                                                                  MATL, 2 bytes



                                                                  X>



                                                                  Choose the most appropriate format for your language/solution




                                                                  The input format is: 2D char array of two rows, each corresponding to a line, with the shorter number left-padded with spaces. For example



                                                                  17210
                                                                  701


                                                                  which in MATL is defined as



                                                                  ['17210'; '  701']


                                                                  Try it online!



                                                                  Explanation



                                                                        % Implicit input: 2D char array with two rows 
                                                                  X> % Take maximum of (code points of) each column
                                                                  % Implicit display





                                                                  share|improve this answer













                                                                  MATL, 2 bytes



                                                                  X>



                                                                  Choose the most appropriate format for your language/solution




                                                                  The input format is: 2D char array of two rows, each corresponding to a line, with the shorter number left-padded with spaces. For example



                                                                  17210
                                                                  701


                                                                  which in MATL is defined as



                                                                  ['17210'; '  701']


                                                                  Try it online!



                                                                  Explanation



                                                                        % Implicit input: 2D char array with two rows 
                                                                  X> % Take maximum of (code points of) each column
                                                                  % Implicit display






                                                                  share|improve this answer












                                                                  share|improve this answer



                                                                  share|improve this answer










                                                                  answered yesterday









                                                                  Luis Mendo

                                                                  73.6k885289




                                                                  73.6k885289






















                                                                      up vote
                                                                      5
                                                                      down vote














                                                                      Python 2, 73 60 56 bytes





                                                                      lambda a,b:map(max,zip(a.rjust(len(b)),b.rjust(len(a))))


                                                                      Try it online!



                                                                      Takes input as two strings, and returns a list of digits





                                                                      Alternative:



                                                                      Takes input as two integers; same output




                                                                      Python 2, 60 59 bytes





                                                                      lambda*i:map(max,zip(*['%*d'%(len(`max(i)`),v)for v in i]))


                                                                      Try it online!






                                                                      share|improve this answer



























                                                                        up vote
                                                                        5
                                                                        down vote














                                                                        Python 2, 73 60 56 bytes





                                                                        lambda a,b:map(max,zip(a.rjust(len(b)),b.rjust(len(a))))


                                                                        Try it online!



                                                                        Takes input as two strings, and returns a list of digits





                                                                        Alternative:



                                                                        Takes input as two integers; same output




                                                                        Python 2, 60 59 bytes





                                                                        lambda*i:map(max,zip(*['%*d'%(len(`max(i)`),v)for v in i]))


                                                                        Try it online!






                                                                        share|improve this answer

























                                                                          up vote
                                                                          5
                                                                          down vote










                                                                          up vote
                                                                          5
                                                                          down vote










                                                                          Python 2, 73 60 56 bytes





                                                                          lambda a,b:map(max,zip(a.rjust(len(b)),b.rjust(len(a))))


                                                                          Try it online!



                                                                          Takes input as two strings, and returns a list of digits





                                                                          Alternative:



                                                                          Takes input as two integers; same output




                                                                          Python 2, 60 59 bytes





                                                                          lambda*i:map(max,zip(*['%*d'%(len(`max(i)`),v)for v in i]))


                                                                          Try it online!






                                                                          share|improve this answer















                                                                          Python 2, 73 60 56 bytes





                                                                          lambda a,b:map(max,zip(a.rjust(len(b)),b.rjust(len(a))))


                                                                          Try it online!



                                                                          Takes input as two strings, and returns a list of digits





                                                                          Alternative:



                                                                          Takes input as two integers; same output




                                                                          Python 2, 60 59 bytes





                                                                          lambda*i:map(max,zip(*['%*d'%(len(`max(i)`),v)for v in i]))


                                                                          Try it online!







                                                                          share|improve this answer














                                                                          share|improve this answer



                                                                          share|improve this answer








                                                                          edited 2 days ago

























                                                                          answered 2 days ago









                                                                          TFeld

                                                                          13.5k21139




                                                                          13.5k21139






















                                                                              up vote
                                                                              4
                                                                              down vote














                                                                              J, 14 12 bytes



                                                                              -2 bytes thanks to Jonah



                                                                              (>./@,:)&.|.


                                                                              Try it online!



                                                                              Input and output as list(s) of digits






                                                                              share|improve this answer



















                                                                              • 1




                                                                                12 bytes: (>./@,:)&.|.. Try it online!
                                                                                – Jonah
                                                                                yesterday








                                                                              • 1




                                                                                @Jonah Of course! Thank you!
                                                                                – Galen Ivanov
                                                                                yesterday






                                                                              • 1




                                                                                if you’re looking for a challenge, see if you can improve this monstrosity: codegolf.stackexchange.com/a/175968/15469
                                                                                – Jonah
                                                                                yesterday















                                                                              up vote
                                                                              4
                                                                              down vote














                                                                              J, 14 12 bytes



                                                                              -2 bytes thanks to Jonah



                                                                              (>./@,:)&.|.


                                                                              Try it online!



                                                                              Input and output as list(s) of digits






                                                                              share|improve this answer



















                                                                              • 1




                                                                                12 bytes: (>./@,:)&.|.. Try it online!
                                                                                – Jonah
                                                                                yesterday








                                                                              • 1




                                                                                @Jonah Of course! Thank you!
                                                                                – Galen Ivanov
                                                                                yesterday






                                                                              • 1




                                                                                if you’re looking for a challenge, see if you can improve this monstrosity: codegolf.stackexchange.com/a/175968/15469
                                                                                – Jonah
                                                                                yesterday













                                                                              up vote
                                                                              4
                                                                              down vote










                                                                              up vote
                                                                              4
                                                                              down vote










                                                                              J, 14 12 bytes



                                                                              -2 bytes thanks to Jonah



                                                                              (>./@,:)&.|.


                                                                              Try it online!



                                                                              Input and output as list(s) of digits






                                                                              share|improve this answer















                                                                              J, 14 12 bytes



                                                                              -2 bytes thanks to Jonah



                                                                              (>./@,:)&.|.


                                                                              Try it online!



                                                                              Input and output as list(s) of digits







                                                                              share|improve this answer














                                                                              share|improve this answer



                                                                              share|improve this answer








                                                                              edited yesterday

























                                                                              answered 2 days ago









                                                                              Galen Ivanov

                                                                              5,89711032




                                                                              5,89711032








                                                                              • 1




                                                                                12 bytes: (>./@,:)&.|.. Try it online!
                                                                                – Jonah
                                                                                yesterday








                                                                              • 1




                                                                                @Jonah Of course! Thank you!
                                                                                – Galen Ivanov
                                                                                yesterday






                                                                              • 1




                                                                                if you’re looking for a challenge, see if you can improve this monstrosity: codegolf.stackexchange.com/a/175968/15469
                                                                                – Jonah
                                                                                yesterday














                                                                              • 1




                                                                                12 bytes: (>./@,:)&.|.. Try it online!
                                                                                – Jonah
                                                                                yesterday








                                                                              • 1




                                                                                @Jonah Of course! Thank you!
                                                                                – Galen Ivanov
                                                                                yesterday






                                                                              • 1




                                                                                if you’re looking for a challenge, see if you can improve this monstrosity: codegolf.stackexchange.com/a/175968/15469
                                                                                – Jonah
                                                                                yesterday








                                                                              1




                                                                              1




                                                                              12 bytes: (>./@,:)&.|.. Try it online!
                                                                              – Jonah
                                                                              yesterday






                                                                              12 bytes: (>./@,:)&.|.. Try it online!
                                                                              – Jonah
                                                                              yesterday






                                                                              1




                                                                              1




                                                                              @Jonah Of course! Thank you!
                                                                              – Galen Ivanov
                                                                              yesterday




                                                                              @Jonah Of course! Thank you!
                                                                              – Galen Ivanov
                                                                              yesterday




                                                                              1




                                                                              1




                                                                              if you’re looking for a challenge, see if you can improve this monstrosity: codegolf.stackexchange.com/a/175968/15469
                                                                              – Jonah
                                                                              yesterday




                                                                              if you’re looking for a challenge, see if you can improve this monstrosity: codegolf.stackexchange.com/a/175968/15469
                                                                              – Jonah
                                                                              yesterday










                                                                              up vote
                                                                              4
                                                                              down vote













                                                                              Japt, 9 8 7 bytes



                                                                              Takes input as an array of digit arrays.



                                                                              mÔÕÔËrw


                                                                              Try it



                                                                              m            :Map
                                                                              Ô : Reverse
                                                                              Õ :Transpose
                                                                              Ô :Reverse
                                                                              Ë :Map
                                                                              r : Reduce by
                                                                              w : Maximum




                                                                              If taking zero-padded arrays as input is permitted (it would currently fall under a "convenient format" but I suspect that's not the challenger's intent) then this can be 3 bytes.



                                                                              íwV


                                                                              Try it



                                                                              í       :Interleave the first input
                                                                              V :With the second
                                                                              w :Reduce each pair by maximum





                                                                              share|improve this answer



















                                                                              • 1




                                                                                Here's another 8 byte solution with a different strategy and simpler input format. maybe you can shave a byte from that?
                                                                                – Kamil Drakari
                                                                                yesterday










                                                                              • @KamilDrakari: Uncanny - I was just updating with the exact same solution!
                                                                                – Shaggy
                                                                                yesterday










                                                                              • Interestingly, the version that separates the "transpose" and "reduce" steps is also 8 bytes because of better shortcuts
                                                                                – Kamil Drakari
                                                                                yesterday










                                                                              • @KamilDrakari, oh, we have a shortcut for y now? I did not know that. Here's another way, also 8 bytes.
                                                                                – Shaggy
                                                                                yesterday










                                                                              • Ooh, that's a neat trick with '. I don't know whether that would ever save bytes, but it's definitely cool.
                                                                                – Kamil Drakari
                                                                                yesterday















                                                                              up vote
                                                                              4
                                                                              down vote













                                                                              Japt, 9 8 7 bytes



                                                                              Takes input as an array of digit arrays.



                                                                              mÔÕÔËrw


                                                                              Try it



                                                                              m            :Map
                                                                              Ô : Reverse
                                                                              Õ :Transpose
                                                                              Ô :Reverse
                                                                              Ë :Map
                                                                              r : Reduce by
                                                                              w : Maximum




                                                                              If taking zero-padded arrays as input is permitted (it would currently fall under a "convenient format" but I suspect that's not the challenger's intent) then this can be 3 bytes.



                                                                              íwV


                                                                              Try it



                                                                              í       :Interleave the first input
                                                                              V :With the second
                                                                              w :Reduce each pair by maximum





                                                                              share|improve this answer



















                                                                              • 1




                                                                                Here's another 8 byte solution with a different strategy and simpler input format. maybe you can shave a byte from that?
                                                                                – Kamil Drakari
                                                                                yesterday










                                                                              • @KamilDrakari: Uncanny - I was just updating with the exact same solution!
                                                                                – Shaggy
                                                                                yesterday










                                                                              • Interestingly, the version that separates the "transpose" and "reduce" steps is also 8 bytes because of better shortcuts
                                                                                – Kamil Drakari
                                                                                yesterday










                                                                              • @KamilDrakari, oh, we have a shortcut for y now? I did not know that. Here's another way, also 8 bytes.
                                                                                – Shaggy
                                                                                yesterday










                                                                              • Ooh, that's a neat trick with '. I don't know whether that would ever save bytes, but it's definitely cool.
                                                                                – Kamil Drakari
                                                                                yesterday













                                                                              up vote
                                                                              4
                                                                              down vote










                                                                              up vote
                                                                              4
                                                                              down vote









                                                                              Japt, 9 8 7 bytes



                                                                              Takes input as an array of digit arrays.



                                                                              mÔÕÔËrw


                                                                              Try it



                                                                              m            :Map
                                                                              Ô : Reverse
                                                                              Õ :Transpose
                                                                              Ô :Reverse
                                                                              Ë :Map
                                                                              r : Reduce by
                                                                              w : Maximum




                                                                              If taking zero-padded arrays as input is permitted (it would currently fall under a "convenient format" but I suspect that's not the challenger's intent) then this can be 3 bytes.



                                                                              íwV


                                                                              Try it



                                                                              í       :Interleave the first input
                                                                              V :With the second
                                                                              w :Reduce each pair by maximum





                                                                              share|improve this answer














                                                                              Japt, 9 8 7 bytes



                                                                              Takes input as an array of digit arrays.



                                                                              mÔÕÔËrw


                                                                              Try it



                                                                              m            :Map
                                                                              Ô : Reverse
                                                                              Õ :Transpose
                                                                              Ô :Reverse
                                                                              Ë :Map
                                                                              r : Reduce by
                                                                              w : Maximum




                                                                              If taking zero-padded arrays as input is permitted (it would currently fall under a "convenient format" but I suspect that's not the challenger's intent) then this can be 3 bytes.



                                                                              íwV


                                                                              Try it



                                                                              í       :Interleave the first input
                                                                              V :With the second
                                                                              w :Reduce each pair by maximum






                                                                              share|improve this answer














                                                                              share|improve this answer



                                                                              share|improve this answer








                                                                              edited yesterday

























                                                                              answered 2 days ago









                                                                              Shaggy

                                                                              18.1k21663




                                                                              18.1k21663








                                                                              • 1




                                                                                Here's another 8 byte solution with a different strategy and simpler input format. maybe you can shave a byte from that?
                                                                                – Kamil Drakari
                                                                                yesterday










                                                                              • @KamilDrakari: Uncanny - I was just updating with the exact same solution!
                                                                                – Shaggy
                                                                                yesterday










                                                                              • Interestingly, the version that separates the "transpose" and "reduce" steps is also 8 bytes because of better shortcuts
                                                                                – Kamil Drakari
                                                                                yesterday










                                                                              • @KamilDrakari, oh, we have a shortcut for y now? I did not know that. Here's another way, also 8 bytes.
                                                                                – Shaggy
                                                                                yesterday










                                                                              • Ooh, that's a neat trick with '. I don't know whether that would ever save bytes, but it's definitely cool.
                                                                                – Kamil Drakari
                                                                                yesterday














                                                                              • 1




                                                                                Here's another 8 byte solution with a different strategy and simpler input format. maybe you can shave a byte from that?
                                                                                – Kamil Drakari
                                                                                yesterday










                                                                              • @KamilDrakari: Uncanny - I was just updating with the exact same solution!
                                                                                – Shaggy
                                                                                yesterday










                                                                              • Interestingly, the version that separates the "transpose" and "reduce" steps is also 8 bytes because of better shortcuts
                                                                                – Kamil Drakari
                                                                                yesterday










                                                                              • @KamilDrakari, oh, we have a shortcut for y now? I did not know that. Here's another way, also 8 bytes.
                                                                                – Shaggy
                                                                                yesterday










                                                                              • Ooh, that's a neat trick with '. I don't know whether that would ever save bytes, but it's definitely cool.
                                                                                – Kamil Drakari
                                                                                yesterday








                                                                              1




                                                                              1




                                                                              Here's another 8 byte solution with a different strategy and simpler input format. maybe you can shave a byte from that?
                                                                              – Kamil Drakari
                                                                              yesterday




                                                                              Here's another 8 byte solution with a different strategy and simpler input format. maybe you can shave a byte from that?
                                                                              – Kamil Drakari
                                                                              yesterday












                                                                              @KamilDrakari: Uncanny - I was just updating with the exact same solution!
                                                                              – Shaggy
                                                                              yesterday




                                                                              @KamilDrakari: Uncanny - I was just updating with the exact same solution!
                                                                              – Shaggy
                                                                              yesterday












                                                                              Interestingly, the version that separates the "transpose" and "reduce" steps is also 8 bytes because of better shortcuts
                                                                              – Kamil Drakari
                                                                              yesterday




                                                                              Interestingly, the version that separates the "transpose" and "reduce" steps is also 8 bytes because of better shortcuts
                                                                              – Kamil Drakari
                                                                              yesterday












                                                                              @KamilDrakari, oh, we have a shortcut for y now? I did not know that. Here's another way, also 8 bytes.
                                                                              – Shaggy
                                                                              yesterday




                                                                              @KamilDrakari, oh, we have a shortcut for y now? I did not know that. Here's another way, also 8 bytes.
                                                                              – Shaggy
                                                                              yesterday












                                                                              Ooh, that's a neat trick with '. I don't know whether that would ever save bytes, but it's definitely cool.
                                                                              – Kamil Drakari
                                                                              yesterday




                                                                              Ooh, that's a neat trick with '. I don't know whether that would ever save bytes, but it's definitely cool.
                                                                              – Kamil Drakari
                                                                              yesterday










                                                                              up vote
                                                                              4
                                                                              down vote














                                                                              Perl 6, 37 bytes



                                                                              {[R~] roundrobin($_».reverse)».max}


                                                                              Try it online!



                                                                              Takes input as a list of lists of digits.






                                                                              share|improve this answer

























                                                                                up vote
                                                                                4
                                                                                down vote














                                                                                Perl 6, 37 bytes



                                                                                {[R~] roundrobin($_».reverse)».max}


                                                                                Try it online!



                                                                                Takes input as a list of lists of digits.






                                                                                share|improve this answer























                                                                                  up vote
                                                                                  4
                                                                                  down vote










                                                                                  up vote
                                                                                  4
                                                                                  down vote










                                                                                  Perl 6, 37 bytes



                                                                                  {[R~] roundrobin($_».reverse)».max}


                                                                                  Try it online!



                                                                                  Takes input as a list of lists of digits.






                                                                                  share|improve this answer













                                                                                  Perl 6, 37 bytes



                                                                                  {[R~] roundrobin($_».reverse)».max}


                                                                                  Try it online!



                                                                                  Takes input as a list of lists of digits.







                                                                                  share|improve this answer












                                                                                  share|improve this answer



                                                                                  share|improve this answer










                                                                                  answered yesterday









                                                                                  Sean

                                                                                  3,08636




                                                                                  3,08636






















                                                                                      up vote
                                                                                      4
                                                                                      down vote














                                                                                      05AB1E, 9 6 5 bytes



                                                                                      -3 thanks to Emigna

                                                                                      -1 thanks to Shaggy



                                                                                      íζ€àR


                                                                                      Takes input as a list of lists of digits



                                                                                      í      # Reverse both inputs
                                                                                      ζ # Zip
                                                                                      ۈ # Keep the bigger digits
                                                                                      R # Reverse


                                                                                      Try it online! or Try all test cases






                                                                                      share|improve this answer























                                                                                      • €R can be í. Also, I don't think you need €þ as number > space
                                                                                        – Emigna
                                                                                        yesterday










                                                                                      • @Emigna Thanks! I thought I tried it without €þ and it didn't work, but now it does...
                                                                                        – Riley
                                                                                        yesterday










                                                                                      • Do you need the J at the end?
                                                                                        – Shaggy
                                                                                        yesterday










                                                                                      • @Shaggy No, I guess I don't. Thanks!
                                                                                        – Riley
                                                                                        yesterday










                                                                                      • It's lame, but the rules allow a 3 byte solution by taking a 2D space-padded char array..
                                                                                        – Kevin Cruijssen
                                                                                        yesterday















                                                                                      up vote
                                                                                      4
                                                                                      down vote














                                                                                      05AB1E, 9 6 5 bytes



                                                                                      -3 thanks to Emigna

                                                                                      -1 thanks to Shaggy



                                                                                      íζ€àR


                                                                                      Takes input as a list of lists of digits



                                                                                      í      # Reverse both inputs
                                                                                      ζ # Zip
                                                                                      ۈ # Keep the bigger digits
                                                                                      R # Reverse


                                                                                      Try it online! or Try all test cases






                                                                                      share|improve this answer























                                                                                      • €R can be í. Also, I don't think you need €þ as number > space
                                                                                        – Emigna
                                                                                        yesterday










                                                                                      • @Emigna Thanks! I thought I tried it without €þ and it didn't work, but now it does...
                                                                                        – Riley
                                                                                        yesterday










                                                                                      • Do you need the J at the end?
                                                                                        – Shaggy
                                                                                        yesterday










                                                                                      • @Shaggy No, I guess I don't. Thanks!
                                                                                        – Riley
                                                                                        yesterday










                                                                                      • It's lame, but the rules allow a 3 byte solution by taking a 2D space-padded char array..
                                                                                        – Kevin Cruijssen
                                                                                        yesterday













                                                                                      up vote
                                                                                      4
                                                                                      down vote










                                                                                      up vote
                                                                                      4
                                                                                      down vote










                                                                                      05AB1E, 9 6 5 bytes



                                                                                      -3 thanks to Emigna

                                                                                      -1 thanks to Shaggy



                                                                                      íζ€àR


                                                                                      Takes input as a list of lists of digits



                                                                                      í      # Reverse both inputs
                                                                                      ζ # Zip
                                                                                      ۈ # Keep the bigger digits
                                                                                      R # Reverse


                                                                                      Try it online! or Try all test cases






                                                                                      share|improve this answer















                                                                                      05AB1E, 9 6 5 bytes



                                                                                      -3 thanks to Emigna

                                                                                      -1 thanks to Shaggy



                                                                                      íζ€àR


                                                                                      Takes input as a list of lists of digits



                                                                                      í      # Reverse both inputs
                                                                                      ζ # Zip
                                                                                      ۈ # Keep the bigger digits
                                                                                      R # Reverse


                                                                                      Try it online! or Try all test cases







                                                                                      share|improve this answer














                                                                                      share|improve this answer



                                                                                      share|improve this answer








                                                                                      edited yesterday

























                                                                                      answered 2 days ago









                                                                                      Riley

                                                                                      10.9k11448




                                                                                      10.9k11448












                                                                                      • €R can be í. Also, I don't think you need €þ as number > space
                                                                                        – Emigna
                                                                                        yesterday










                                                                                      • @Emigna Thanks! I thought I tried it without €þ and it didn't work, but now it does...
                                                                                        – Riley
                                                                                        yesterday










                                                                                      • Do you need the J at the end?
                                                                                        – Shaggy
                                                                                        yesterday










                                                                                      • @Shaggy No, I guess I don't. Thanks!
                                                                                        – Riley
                                                                                        yesterday










                                                                                      • It's lame, but the rules allow a 3 byte solution by taking a 2D space-padded char array..
                                                                                        – Kevin Cruijssen
                                                                                        yesterday


















                                                                                      • €R can be í. Also, I don't think you need €þ as number > space
                                                                                        – Emigna
                                                                                        yesterday










                                                                                      • @Emigna Thanks! I thought I tried it without €þ and it didn't work, but now it does...
                                                                                        – Riley
                                                                                        yesterday










                                                                                      • Do you need the J at the end?
                                                                                        – Shaggy
                                                                                        yesterday










                                                                                      • @Shaggy No, I guess I don't. Thanks!
                                                                                        – Riley
                                                                                        yesterday










                                                                                      • It's lame, but the rules allow a 3 byte solution by taking a 2D space-padded char array..
                                                                                        – Kevin Cruijssen
                                                                                        yesterday
















                                                                                      €R can be í. Also, I don't think you need €þ as number > space
                                                                                      – Emigna
                                                                                      yesterday




                                                                                      €R can be í. Also, I don't think you need €þ as number > space
                                                                                      – Emigna
                                                                                      yesterday












                                                                                      @Emigna Thanks! I thought I tried it without €þ and it didn't work, but now it does...
                                                                                      – Riley
                                                                                      yesterday




                                                                                      @Emigna Thanks! I thought I tried it without €þ and it didn't work, but now it does...
                                                                                      – Riley
                                                                                      yesterday












                                                                                      Do you need the J at the end?
                                                                                      – Shaggy
                                                                                      yesterday




                                                                                      Do you need the J at the end?
                                                                                      – Shaggy
                                                                                      yesterday












                                                                                      @Shaggy No, I guess I don't. Thanks!
                                                                                      – Riley
                                                                                      yesterday




                                                                                      @Shaggy No, I guess I don't. Thanks!
                                                                                      – Riley
                                                                                      yesterday












                                                                                      It's lame, but the rules allow a 3 byte solution by taking a 2D space-padded char array..
                                                                                      – Kevin Cruijssen
                                                                                      yesterday




                                                                                      It's lame, but the rules allow a 3 byte solution by taking a 2D space-padded char array..
                                                                                      – Kevin Cruijssen
                                                                                      yesterday










                                                                                      up vote
                                                                                      4
                                                                                      down vote













                                                                                      Java 10, 78 57 bytes





                                                                                      a->b->{for(int i=a.length;i-->0;)if(a[i]<b[i])a[i]=b[i];}


                                                                                      Input as two space-padded character arrays.



                                                                                      Modifies the first input-array instead of returning a new one to save 21 bytes (thanks to @OlivierGrégoire).



                                                                                      Try it online.



                                                                                      Explanation:



                                                                                      a->b->{            // Method with two char-array parameters and String return-type
                                                                                      for(int i=a.length;i-->0;)
                                                                                      // Loop `i` in the range (length, 0]:
                                                                                      if(a[i]<b[i]) // If the `i`'th character in input `a` is smaller than in input `b`:
                                                                                      a[i]=b[i];} // Change the `i`'th character in `a` to the `i`'th character of `b`





                                                                                      share|improve this answer



















                                                                                      • 1




                                                                                        a->b->{for(int i=a.length;i-->0;)if(a[i]<b[i])a[i]=b[i];} (57 bytes). Reuse a as output to gain much, much bytes.
                                                                                        – Olivier Grégoire
                                                                                        yesterday










                                                                                      • @OlivierGrégoire Ah, can't believe I hadn't thought of that. Thanks! :D
                                                                                        – Kevin Cruijssen
                                                                                        yesterday















                                                                                      up vote
                                                                                      4
                                                                                      down vote













                                                                                      Java 10, 78 57 bytes





                                                                                      a->b->{for(int i=a.length;i-->0;)if(a[i]<b[i])a[i]=b[i];}


                                                                                      Input as two space-padded character arrays.



                                                                                      Modifies the first input-array instead of returning a new one to save 21 bytes (thanks to @OlivierGrégoire).



                                                                                      Try it online.



                                                                                      Explanation:



                                                                                      a->b->{            // Method with two char-array parameters and String return-type
                                                                                      for(int i=a.length;i-->0;)
                                                                                      // Loop `i` in the range (length, 0]:
                                                                                      if(a[i]<b[i]) // If the `i`'th character in input `a` is smaller than in input `b`:
                                                                                      a[i]=b[i];} // Change the `i`'th character in `a` to the `i`'th character of `b`





                                                                                      share|improve this answer



















                                                                                      • 1




                                                                                        a->b->{for(int i=a.length;i-->0;)if(a[i]<b[i])a[i]=b[i];} (57 bytes). Reuse a as output to gain much, much bytes.
                                                                                        – Olivier Grégoire
                                                                                        yesterday










                                                                                      • @OlivierGrégoire Ah, can't believe I hadn't thought of that. Thanks! :D
                                                                                        – Kevin Cruijssen
                                                                                        yesterday













                                                                                      up vote
                                                                                      4
                                                                                      down vote










                                                                                      up vote
                                                                                      4
                                                                                      down vote









                                                                                      Java 10, 78 57 bytes





                                                                                      a->b->{for(int i=a.length;i-->0;)if(a[i]<b[i])a[i]=b[i];}


                                                                                      Input as two space-padded character arrays.



                                                                                      Modifies the first input-array instead of returning a new one to save 21 bytes (thanks to @OlivierGrégoire).



                                                                                      Try it online.



                                                                                      Explanation:



                                                                                      a->b->{            // Method with two char-array parameters and String return-type
                                                                                      for(int i=a.length;i-->0;)
                                                                                      // Loop `i` in the range (length, 0]:
                                                                                      if(a[i]<b[i]) // If the `i`'th character in input `a` is smaller than in input `b`:
                                                                                      a[i]=b[i];} // Change the `i`'th character in `a` to the `i`'th character of `b`





                                                                                      share|improve this answer














                                                                                      Java 10, 78 57 bytes





                                                                                      a->b->{for(int i=a.length;i-->0;)if(a[i]<b[i])a[i]=b[i];}


                                                                                      Input as two space-padded character arrays.



                                                                                      Modifies the first input-array instead of returning a new one to save 21 bytes (thanks to @OlivierGrégoire).



                                                                                      Try it online.



                                                                                      Explanation:



                                                                                      a->b->{            // Method with two char-array parameters and String return-type
                                                                                      for(int i=a.length;i-->0;)
                                                                                      // Loop `i` in the range (length, 0]:
                                                                                      if(a[i]<b[i]) // If the `i`'th character in input `a` is smaller than in input `b`:
                                                                                      a[i]=b[i];} // Change the `i`'th character in `a` to the `i`'th character of `b`






                                                                                      share|improve this answer














                                                                                      share|improve this answer



                                                                                      share|improve this answer








                                                                                      edited yesterday

























                                                                                      answered yesterday









                                                                                      Kevin Cruijssen

                                                                                      34k554181




                                                                                      34k554181








                                                                                      • 1




                                                                                        a->b->{for(int i=a.length;i-->0;)if(a[i]<b[i])a[i]=b[i];} (57 bytes). Reuse a as output to gain much, much bytes.
                                                                                        – Olivier Grégoire
                                                                                        yesterday










                                                                                      • @OlivierGrégoire Ah, can't believe I hadn't thought of that. Thanks! :D
                                                                                        – Kevin Cruijssen
                                                                                        yesterday














                                                                                      • 1




                                                                                        a->b->{for(int i=a.length;i-->0;)if(a[i]<b[i])a[i]=b[i];} (57 bytes). Reuse a as output to gain much, much bytes.
                                                                                        – Olivier Grégoire
                                                                                        yesterday










                                                                                      • @OlivierGrégoire Ah, can't believe I hadn't thought of that. Thanks! :D
                                                                                        – Kevin Cruijssen
                                                                                        yesterday








                                                                                      1




                                                                                      1




                                                                                      a->b->{for(int i=a.length;i-->0;)if(a[i]<b[i])a[i]=b[i];} (57 bytes). Reuse a as output to gain much, much bytes.
                                                                                      – Olivier Grégoire
                                                                                      yesterday




                                                                                      a->b->{for(int i=a.length;i-->0;)if(a[i]<b[i])a[i]=b[i];} (57 bytes). Reuse a as output to gain much, much bytes.
                                                                                      – Olivier Grégoire
                                                                                      yesterday












                                                                                      @OlivierGrégoire Ah, can't believe I hadn't thought of that. Thanks! :D
                                                                                      – Kevin Cruijssen
                                                                                      yesterday




                                                                                      @OlivierGrégoire Ah, can't believe I hadn't thought of that. Thanks! :D
                                                                                      – Kevin Cruijssen
                                                                                      yesterday










                                                                                      up vote
                                                                                      3
                                                                                      down vote














                                                                                      Haskell, 40 bytes





                                                                                      a#b=zipWith max(p b++a)$p a++b
                                                                                      p=(' '<$)


                                                                                      Input/output as strings, try it online!



                                                                                      Explanation



                                                                                      The function p replaces each character by a space, using p b++a and p a++b are thus the same length. This way we can use zipWith without losing any elements, using max with it works because a (space) has lower codepoint than any of the characters ['0'..'9'].






                                                                                      share|improve this answer



























                                                                                        up vote
                                                                                        3
                                                                                        down vote














                                                                                        Haskell, 40 bytes





                                                                                        a#b=zipWith max(p b++a)$p a++b
                                                                                        p=(' '<$)


                                                                                        Input/output as strings, try it online!



                                                                                        Explanation



                                                                                        The function p replaces each character by a space, using p b++a and p a++b are thus the same length. This way we can use zipWith without losing any elements, using max with it works because a (space) has lower codepoint than any of the characters ['0'..'9'].






                                                                                        share|improve this answer

























                                                                                          up vote
                                                                                          3
                                                                                          down vote










                                                                                          up vote
                                                                                          3
                                                                                          down vote










                                                                                          Haskell, 40 bytes





                                                                                          a#b=zipWith max(p b++a)$p a++b
                                                                                          p=(' '<$)


                                                                                          Input/output as strings, try it online!



                                                                                          Explanation



                                                                                          The function p replaces each character by a space, using p b++a and p a++b are thus the same length. This way we can use zipWith without losing any elements, using max with it works because a (space) has lower codepoint than any of the characters ['0'..'9'].






                                                                                          share|improve this answer















                                                                                          Haskell, 40 bytes





                                                                                          a#b=zipWith max(p b++a)$p a++b
                                                                                          p=(' '<$)


                                                                                          Input/output as strings, try it online!



                                                                                          Explanation



                                                                                          The function p replaces each character by a space, using p b++a and p a++b are thus the same length. This way we can use zipWith without losing any elements, using max with it works because a (space) has lower codepoint than any of the characters ['0'..'9'].







                                                                                          share|improve this answer














                                                                                          share|improve this answer



                                                                                          share|improve this answer








                                                                                          edited yesterday

























                                                                                          answered yesterday









                                                                                          BMO

                                                                                          10.5k21880




                                                                                          10.5k21880






















                                                                                              up vote
                                                                                              3
                                                                                              down vote













                                                                                              JavaScript (ES6), 51 49 bytes



                                                                                              NB: This answer was posted before the loose I/O formats were explicitly allowed. With zero-padded arrays of digits, this can be done in 33 bytes, (but is much less interesting, IMHO).



                                                                                              Takes input as two integers. Returns an integer.





                                                                                              f=(a,b,t=10)=>a|b&&(a%t<b%t?b:a)%t+t*f(a/t,b/t)|0


                                                                                              Try it online!



                                                                                              Commented



                                                                                              f = (                     // f = recursive function taking:
                                                                                              a, // a = first integer
                                                                                              b, // b = second integer
                                                                                              t = 10 // t = 10 (which is used 6 times below)
                                                                                              ) => //
                                                                                              a | b // bitwise OR between a and b to test whether at least one of
                                                                                              // them still has an integer part
                                                                                              && // if not, stop recursion; otherwise:
                                                                                              ( //
                                                                                              a % t < b % t ? b : a // if a % 10 is less than b % 10: use b; otherwise: use a
                                                                                              ) % t + // isolate the last decimal digit of the selected number
                                                                                              t * // add 10 times the result of
                                                                                              f(a / t, b / t) // a recursive call with a / 10 and b / 10
                                                                                              | 0 // bitwise OR with 0 to isolate the integer part


                                                                                              Alternate version



                                                                                              Same I/O format.



                                                                                              f=(a,b)=>a|b&&[f(a/10,b/10)]+(a%10<b%10?b:a)%10|0


                                                                                              Try it online!






                                                                                              share|improve this answer























                                                                                              • You can get much shorter if you assume your input to be a 2d space padded char array.
                                                                                                – kamoroso94
                                                                                                yesterday










                                                                                              • Hi! Could you provide some explanation? I ""tried"" to do this challenge in JavaScript but I failed and would like to see how your solution works :)
                                                                                                – Neyt
                                                                                                yesterday






                                                                                              • 1




                                                                                                @Neyt I've added a commented version. The alternate version is using the same logic; the only difference is that we add the next digit to the left as a string instead of multiplying the result of the recursive call by 10.
                                                                                                – Arnauld
                                                                                                yesterday










                                                                                              • @Arnauld Thank you! :)
                                                                                                – Neyt
                                                                                                yesterday















                                                                                              up vote
                                                                                              3
                                                                                              down vote













                                                                                              JavaScript (ES6), 51 49 bytes



                                                                                              NB: This answer was posted before the loose I/O formats were explicitly allowed. With zero-padded arrays of digits, this can be done in 33 bytes, (but is much less interesting, IMHO).



                                                                                              Takes input as two integers. Returns an integer.





                                                                                              f=(a,b,t=10)=>a|b&&(a%t<b%t?b:a)%t+t*f(a/t,b/t)|0


                                                                                              Try it online!



                                                                                              Commented



                                                                                              f = (                     // f = recursive function taking:
                                                                                              a, // a = first integer
                                                                                              b, // b = second integer
                                                                                              t = 10 // t = 10 (which is used 6 times below)
                                                                                              ) => //
                                                                                              a | b // bitwise OR between a and b to test whether at least one of
                                                                                              // them still has an integer part
                                                                                              && // if not, stop recursion; otherwise:
                                                                                              ( //
                                                                                              a % t < b % t ? b : a // if a % 10 is less than b % 10: use b; otherwise: use a
                                                                                              ) % t + // isolate the last decimal digit of the selected number
                                                                                              t * // add 10 times the result of
                                                                                              f(a / t, b / t) // a recursive call with a / 10 and b / 10
                                                                                              | 0 // bitwise OR with 0 to isolate the integer part


                                                                                              Alternate version



                                                                                              Same I/O format.



                                                                                              f=(a,b)=>a|b&&[f(a/10,b/10)]+(a%10<b%10?b:a)%10|0


                                                                                              Try it online!






                                                                                              share|improve this answer























                                                                                              • You can get much shorter if you assume your input to be a 2d space padded char array.
                                                                                                – kamoroso94
                                                                                                yesterday










                                                                                              • Hi! Could you provide some explanation? I ""tried"" to do this challenge in JavaScript but I failed and would like to see how your solution works :)
                                                                                                – Neyt
                                                                                                yesterday






                                                                                              • 1




                                                                                                @Neyt I've added a commented version. The alternate version is using the same logic; the only difference is that we add the next digit to the left as a string instead of multiplying the result of the recursive call by 10.
                                                                                                – Arnauld
                                                                                                yesterday










                                                                                              • @Arnauld Thank you! :)
                                                                                                – Neyt
                                                                                                yesterday













                                                                                              up vote
                                                                                              3
                                                                                              down vote










                                                                                              up vote
                                                                                              3
                                                                                              down vote









                                                                                              JavaScript (ES6), 51 49 bytes



                                                                                              NB: This answer was posted before the loose I/O formats were explicitly allowed. With zero-padded arrays of digits, this can be done in 33 bytes, (but is much less interesting, IMHO).



                                                                                              Takes input as two integers. Returns an integer.





                                                                                              f=(a,b,t=10)=>a|b&&(a%t<b%t?b:a)%t+t*f(a/t,b/t)|0


                                                                                              Try it online!



                                                                                              Commented



                                                                                              f = (                     // f = recursive function taking:
                                                                                              a, // a = first integer
                                                                                              b, // b = second integer
                                                                                              t = 10 // t = 10 (which is used 6 times below)
                                                                                              ) => //
                                                                                              a | b // bitwise OR between a and b to test whether at least one of
                                                                                              // them still has an integer part
                                                                                              && // if not, stop recursion; otherwise:
                                                                                              ( //
                                                                                              a % t < b % t ? b : a // if a % 10 is less than b % 10: use b; otherwise: use a
                                                                                              ) % t + // isolate the last decimal digit of the selected number
                                                                                              t * // add 10 times the result of
                                                                                              f(a / t, b / t) // a recursive call with a / 10 and b / 10
                                                                                              | 0 // bitwise OR with 0 to isolate the integer part


                                                                                              Alternate version



                                                                                              Same I/O format.



                                                                                              f=(a,b)=>a|b&&[f(a/10,b/10)]+(a%10<b%10?b:a)%10|0


                                                                                              Try it online!






                                                                                              share|improve this answer














                                                                                              JavaScript (ES6), 51 49 bytes



                                                                                              NB: This answer was posted before the loose I/O formats were explicitly allowed. With zero-padded arrays of digits, this can be done in 33 bytes, (but is much less interesting, IMHO).



                                                                                              Takes input as two integers. Returns an integer.





                                                                                              f=(a,b,t=10)=>a|b&&(a%t<b%t?b:a)%t+t*f(a/t,b/t)|0


                                                                                              Try it online!



                                                                                              Commented



                                                                                              f = (                     // f = recursive function taking:
                                                                                              a, // a = first integer
                                                                                              b, // b = second integer
                                                                                              t = 10 // t = 10 (which is used 6 times below)
                                                                                              ) => //
                                                                                              a | b // bitwise OR between a and b to test whether at least one of
                                                                                              // them still has an integer part
                                                                                              && // if not, stop recursion; otherwise:
                                                                                              ( //
                                                                                              a % t < b % t ? b : a // if a % 10 is less than b % 10: use b; otherwise: use a
                                                                                              ) % t + // isolate the last decimal digit of the selected number
                                                                                              t * // add 10 times the result of
                                                                                              f(a / t, b / t) // a recursive call with a / 10 and b / 10
                                                                                              | 0 // bitwise OR with 0 to isolate the integer part


                                                                                              Alternate version



                                                                                              Same I/O format.



                                                                                              f=(a,b)=>a|b&&[f(a/10,b/10)]+(a%10<b%10?b:a)%10|0


                                                                                              Try it online!







                                                                                              share|improve this answer














                                                                                              share|improve this answer



                                                                                              share|improve this answer








                                                                                              edited yesterday

























                                                                                              answered 2 days ago









                                                                                              Arnauld

                                                                                              68.6k584289




                                                                                              68.6k584289












                                                                                              • You can get much shorter if you assume your input to be a 2d space padded char array.
                                                                                                – kamoroso94
                                                                                                yesterday










                                                                                              • Hi! Could you provide some explanation? I ""tried"" to do this challenge in JavaScript but I failed and would like to see how your solution works :)
                                                                                                – Neyt
                                                                                                yesterday






                                                                                              • 1




                                                                                                @Neyt I've added a commented version. The alternate version is using the same logic; the only difference is that we add the next digit to the left as a string instead of multiplying the result of the recursive call by 10.
                                                                                                – Arnauld
                                                                                                yesterday










                                                                                              • @Arnauld Thank you! :)
                                                                                                – Neyt
                                                                                                yesterday


















                                                                                              • You can get much shorter if you assume your input to be a 2d space padded char array.
                                                                                                – kamoroso94
                                                                                                yesterday










                                                                                              • Hi! Could you provide some explanation? I ""tried"" to do this challenge in JavaScript but I failed and would like to see how your solution works :)
                                                                                                – Neyt
                                                                                                yesterday






                                                                                              • 1




                                                                                                @Neyt I've added a commented version. The alternate version is using the same logic; the only difference is that we add the next digit to the left as a string instead of multiplying the result of the recursive call by 10.
                                                                                                – Arnauld
                                                                                                yesterday










                                                                                              • @Arnauld Thank you! :)
                                                                                                – Neyt
                                                                                                yesterday
















                                                                                              You can get much shorter if you assume your input to be a 2d space padded char array.
                                                                                              – kamoroso94
                                                                                              yesterday




                                                                                              You can get much shorter if you assume your input to be a 2d space padded char array.
                                                                                              – kamoroso94
                                                                                              yesterday












                                                                                              Hi! Could you provide some explanation? I ""tried"" to do this challenge in JavaScript but I failed and would like to see how your solution works :)
                                                                                              – Neyt
                                                                                              yesterday




                                                                                              Hi! Could you provide some explanation? I ""tried"" to do this challenge in JavaScript but I failed and would like to see how your solution works :)
                                                                                              – Neyt
                                                                                              yesterday




                                                                                              1




                                                                                              1




                                                                                              @Neyt I've added a commented version. The alternate version is using the same logic; the only difference is that we add the next digit to the left as a string instead of multiplying the result of the recursive call by 10.
                                                                                              – Arnauld
                                                                                              yesterday




                                                                                              @Neyt I've added a commented version. The alternate version is using the same logic; the only difference is that we add the next digit to the left as a string instead of multiplying the result of the recursive call by 10.
                                                                                              – Arnauld
                                                                                              yesterday












                                                                                              @Arnauld Thank you! :)
                                                                                              – Neyt
                                                                                              yesterday




                                                                                              @Arnauld Thank you! :)
                                                                                              – Neyt
                                                                                              yesterday










                                                                                              up vote
                                                                                              3
                                                                                              down vote














                                                                                              Perl 6, 15 bytes





                                                                                              {[~] [Zmax] $_}


                                                                                              Try it online!



                                                                                              Takes input as a list of space padded arrays of characters, though for this challenge the lax input format makes it rather boring. Alternatively, here's the program that takes a list of two integers instead:




                                                                                              Perl 6, 41 bytes





                                                                                              {+[~] [Zmax] $_>>.fmt("%{.max}d")>>.comb}


                                                                                              Try it online!



                                                                                              If you don't mind a huge amount of whitespace, you can also remove the + from the front.



                                                                                              Explanation:



                                                                                              {                                       }  # Anonymous code block
                                                                                              $_>> # Map each integer to
                                                                                              .fmt("%{.max}d") # The number padded by the max of the list spaces
                                                                                              >>.comb # And split each to list of characters
                                                                                              [Zmax] # Get the max of each digit at each index
                                                                                              # This works because space is coerced to 0
                                                                                              # Otherwise we would have to add a 0 to the formatting string
                                                                                              [~] # Join the list of digits and spaces
                                                                                              + # And coerce the string to a number to get rid of leading whitespace





                                                                                              share|improve this answer



























                                                                                                up vote
                                                                                                3
                                                                                                down vote














                                                                                                Perl 6, 15 bytes





                                                                                                {[~] [Zmax] $_}


                                                                                                Try it online!



                                                                                                Takes input as a list of space padded arrays of characters, though for this challenge the lax input format makes it rather boring. Alternatively, here's the program that takes a list of two integers instead:




                                                                                                Perl 6, 41 bytes





                                                                                                {+[~] [Zmax] $_>>.fmt("%{.max}d")>>.comb}


                                                                                                Try it online!



                                                                                                If you don't mind a huge amount of whitespace, you can also remove the + from the front.



                                                                                                Explanation:



                                                                                                {                                       }  # Anonymous code block
                                                                                                $_>> # Map each integer to
                                                                                                .fmt("%{.max}d") # The number padded by the max of the list spaces
                                                                                                >>.comb # And split each to list of characters
                                                                                                [Zmax] # Get the max of each digit at each index
                                                                                                # This works because space is coerced to 0
                                                                                                # Otherwise we would have to add a 0 to the formatting string
                                                                                                [~] # Join the list of digits and spaces
                                                                                                + # And coerce the string to a number to get rid of leading whitespace





                                                                                                share|improve this answer

























                                                                                                  up vote
                                                                                                  3
                                                                                                  down vote










                                                                                                  up vote
                                                                                                  3
                                                                                                  down vote










                                                                                                  Perl 6, 15 bytes





                                                                                                  {[~] [Zmax] $_}


                                                                                                  Try it online!



                                                                                                  Takes input as a list of space padded arrays of characters, though for this challenge the lax input format makes it rather boring. Alternatively, here's the program that takes a list of two integers instead:




                                                                                                  Perl 6, 41 bytes





                                                                                                  {+[~] [Zmax] $_>>.fmt("%{.max}d")>>.comb}


                                                                                                  Try it online!



                                                                                                  If you don't mind a huge amount of whitespace, you can also remove the + from the front.



                                                                                                  Explanation:



                                                                                                  {                                       }  # Anonymous code block
                                                                                                  $_>> # Map each integer to
                                                                                                  .fmt("%{.max}d") # The number padded by the max of the list spaces
                                                                                                  >>.comb # And split each to list of characters
                                                                                                  [Zmax] # Get the max of each digit at each index
                                                                                                  # This works because space is coerced to 0
                                                                                                  # Otherwise we would have to add a 0 to the formatting string
                                                                                                  [~] # Join the list of digits and spaces
                                                                                                  + # And coerce the string to a number to get rid of leading whitespace





                                                                                                  share|improve this answer















                                                                                                  Perl 6, 15 bytes





                                                                                                  {[~] [Zmax] $_}


                                                                                                  Try it online!



                                                                                                  Takes input as a list of space padded arrays of characters, though for this challenge the lax input format makes it rather boring. Alternatively, here's the program that takes a list of two integers instead:




                                                                                                  Perl 6, 41 bytes





                                                                                                  {+[~] [Zmax] $_>>.fmt("%{.max}d")>>.comb}


                                                                                                  Try it online!



                                                                                                  If you don't mind a huge amount of whitespace, you can also remove the + from the front.



                                                                                                  Explanation:



                                                                                                  {                                       }  # Anonymous code block
                                                                                                  $_>> # Map each integer to
                                                                                                  .fmt("%{.max}d") # The number padded by the max of the list spaces
                                                                                                  >>.comb # And split each to list of characters
                                                                                                  [Zmax] # Get the max of each digit at each index
                                                                                                  # This works because space is coerced to 0
                                                                                                  # Otherwise we would have to add a 0 to the formatting string
                                                                                                  [~] # Join the list of digits and spaces
                                                                                                  + # And coerce the string to a number to get rid of leading whitespace






                                                                                                  share|improve this answer














                                                                                                  share|improve this answer



                                                                                                  share|improve this answer








                                                                                                  edited yesterday

























                                                                                                  answered yesterday









                                                                                                  Jo King

                                                                                                  19.1k242102




                                                                                                  19.1k242102






















                                                                                                      up vote
                                                                                                      2
                                                                                                      down vote














                                                                                                      Tcl, 156 bytes



                                                                                                      proc S a b {join [lmap x [split [format %0[set l [expr max([string le $a],[string le $b])]]d $a] ""] y [split [format %0$ld $b] ""] {expr max($x,$y)}] ""}


                                                                                                      Try it online!



                                                                                                      Not very golfy, but I had to give a try on it. Will golf it later!






                                                                                                      share|improve this answer





















                                                                                                      • Tcl, 159 bytes Failed outgolf
                                                                                                        – sergiol
                                                                                                        yesterday















                                                                                                      up vote
                                                                                                      2
                                                                                                      down vote














                                                                                                      Tcl, 156 bytes



                                                                                                      proc S a b {join [lmap x [split [format %0[set l [expr max([string le $a],[string le $b])]]d $a] ""] y [split [format %0$ld $b] ""] {expr max($x,$y)}] ""}


                                                                                                      Try it online!



                                                                                                      Not very golfy, but I had to give a try on it. Will golf it later!






                                                                                                      share|improve this answer





















                                                                                                      • Tcl, 159 bytes Failed outgolf
                                                                                                        – sergiol
                                                                                                        yesterday













                                                                                                      up vote
                                                                                                      2
                                                                                                      down vote










                                                                                                      up vote
                                                                                                      2
                                                                                                      down vote










                                                                                                      Tcl, 156 bytes



                                                                                                      proc S a b {join [lmap x [split [format %0[set l [expr max([string le $a],[string le $b])]]d $a] ""] y [split [format %0$ld $b] ""] {expr max($x,$y)}] ""}


                                                                                                      Try it online!



                                                                                                      Not very golfy, but I had to give a try on it. Will golf it later!






                                                                                                      share|improve this answer













                                                                                                      Tcl, 156 bytes



                                                                                                      proc S a b {join [lmap x [split [format %0[set l [expr max([string le $a],[string le $b])]]d $a] ""] y [split [format %0$ld $b] ""] {expr max($x,$y)}] ""}


                                                                                                      Try it online!



                                                                                                      Not very golfy, but I had to give a try on it. Will golf it later!







                                                                                                      share|improve this answer












                                                                                                      share|improve this answer



                                                                                                      share|improve this answer










                                                                                                      answered yesterday









                                                                                                      sergiol

                                                                                                      2,2321825




                                                                                                      2,2321825












                                                                                                      • Tcl, 159 bytes Failed outgolf
                                                                                                        – sergiol
                                                                                                        yesterday


















                                                                                                      • Tcl, 159 bytes Failed outgolf
                                                                                                        – sergiol
                                                                                                        yesterday
















                                                                                                      Tcl, 159 bytes Failed outgolf
                                                                                                      – sergiol
                                                                                                      yesterday




                                                                                                      Tcl, 159 bytes Failed outgolf
                                                                                                      – sergiol
                                                                                                      yesterday










                                                                                                      up vote
                                                                                                      2
                                                                                                      down vote













                                                                                                      Batch, 120 bytes



                                                                                                      @set/aw=1,x=%1,y=%2,z=0
                                                                                                      @for /l %%i in (0,1,9)do @set/a"z+=w*((v=y%%10)+(v-=x%%10)*(v>>4)),y/=10,x/=10,w*=10
                                                                                                      @echo %z%


                                                                                                      Takes input as command-line parameters. 188-byte version works on arbitrary length integers:



                                                                                                      @set/px=
                                                                                                      @set/py=
                                                                                                      @set z=
                                                                                                      :l
                                                                                                      @if %x:~-1% gtr %y:~-1% (set z=%x:~-1%%z%)else set z=%y:~-1%%z%
                                                                                                      @set x=%x:~,-1%
                                                                                                      @set y=%y:~,-1%
                                                                                                      @if "%x%" neq "" if "%y%" neq "" goto l
                                                                                                      @echo %x%%y%%z%


                                                                                                      Takes input on STDIN.






                                                                                                      share|improve this answer

























                                                                                                        up vote
                                                                                                        2
                                                                                                        down vote













                                                                                                        Batch, 120 bytes



                                                                                                        @set/aw=1,x=%1,y=%2,z=0
                                                                                                        @for /l %%i in (0,1,9)do @set/a"z+=w*((v=y%%10)+(v-=x%%10)*(v>>4)),y/=10,x/=10,w*=10
                                                                                                        @echo %z%


                                                                                                        Takes input as command-line parameters. 188-byte version works on arbitrary length integers:



                                                                                                        @set/px=
                                                                                                        @set/py=
                                                                                                        @set z=
                                                                                                        :l
                                                                                                        @if %x:~-1% gtr %y:~-1% (set z=%x:~-1%%z%)else set z=%y:~-1%%z%
                                                                                                        @set x=%x:~,-1%
                                                                                                        @set y=%y:~,-1%
                                                                                                        @if "%x%" neq "" if "%y%" neq "" goto l
                                                                                                        @echo %x%%y%%z%


                                                                                                        Takes input on STDIN.






                                                                                                        share|improve this answer























                                                                                                          up vote
                                                                                                          2
                                                                                                          down vote










                                                                                                          up vote
                                                                                                          2
                                                                                                          down vote









                                                                                                          Batch, 120 bytes



                                                                                                          @set/aw=1,x=%1,y=%2,z=0
                                                                                                          @for /l %%i in (0,1,9)do @set/a"z+=w*((v=y%%10)+(v-=x%%10)*(v>>4)),y/=10,x/=10,w*=10
                                                                                                          @echo %z%


                                                                                                          Takes input as command-line parameters. 188-byte version works on arbitrary length integers:



                                                                                                          @set/px=
                                                                                                          @set/py=
                                                                                                          @set z=
                                                                                                          :l
                                                                                                          @if %x:~-1% gtr %y:~-1% (set z=%x:~-1%%z%)else set z=%y:~-1%%z%
                                                                                                          @set x=%x:~,-1%
                                                                                                          @set y=%y:~,-1%
                                                                                                          @if "%x%" neq "" if "%y%" neq "" goto l
                                                                                                          @echo %x%%y%%z%


                                                                                                          Takes input on STDIN.






                                                                                                          share|improve this answer












                                                                                                          Batch, 120 bytes



                                                                                                          @set/aw=1,x=%1,y=%2,z=0
                                                                                                          @for /l %%i in (0,1,9)do @set/a"z+=w*((v=y%%10)+(v-=x%%10)*(v>>4)),y/=10,x/=10,w*=10
                                                                                                          @echo %z%


                                                                                                          Takes input as command-line parameters. 188-byte version works on arbitrary length integers:



                                                                                                          @set/px=
                                                                                                          @set/py=
                                                                                                          @set z=
                                                                                                          :l
                                                                                                          @if %x:~-1% gtr %y:~-1% (set z=%x:~-1%%z%)else set z=%y:~-1%%z%
                                                                                                          @set x=%x:~,-1%
                                                                                                          @set y=%y:~,-1%
                                                                                                          @if "%x%" neq "" if "%y%" neq "" goto l
                                                                                                          @echo %x%%y%%z%


                                                                                                          Takes input on STDIN.







                                                                                                          share|improve this answer












                                                                                                          share|improve this answer



                                                                                                          share|improve this answer










                                                                                                          answered yesterday









                                                                                                          Neil

                                                                                                          77.9k744174




                                                                                                          77.9k744174






















                                                                                                              up vote
                                                                                                              1
                                                                                                              down vote














                                                                                                              Husk, 5 bytes



                                                                                                              ↔¤żY↔


                                                                                                              Conveniently takes input/output as list of digits, try it online or verify all!



                                                                                                              Explanation



                                                                                                              ↔¤żY↔  -- example inputs [1,4] [3,2]
                                                                                                              ¤ ↔ -- reverse the arguments of: [4,1] [2,3]
                                                                                                              żY -- | zipWith (keeping elements of longer) max: [4,3]
                                                                                                              ↔ -- reverse: [3,4]





                                                                                                              share|improve this answer

























                                                                                                                up vote
                                                                                                                1
                                                                                                                down vote














                                                                                                                Husk, 5 bytes



                                                                                                                ↔¤żY↔


                                                                                                                Conveniently takes input/output as list of digits, try it online or verify all!



                                                                                                                Explanation



                                                                                                                ↔¤żY↔  -- example inputs [1,4] [3,2]
                                                                                                                ¤ ↔ -- reverse the arguments of: [4,1] [2,3]
                                                                                                                żY -- | zipWith (keeping elements of longer) max: [4,3]
                                                                                                                ↔ -- reverse: [3,4]





                                                                                                                share|improve this answer























                                                                                                                  up vote
                                                                                                                  1
                                                                                                                  down vote










                                                                                                                  up vote
                                                                                                                  1
                                                                                                                  down vote










                                                                                                                  Husk, 5 bytes



                                                                                                                  ↔¤żY↔


                                                                                                                  Conveniently takes input/output as list of digits, try it online or verify all!



                                                                                                                  Explanation



                                                                                                                  ↔¤żY↔  -- example inputs [1,4] [3,2]
                                                                                                                  ¤ ↔ -- reverse the arguments of: [4,1] [2,3]
                                                                                                                  żY -- | zipWith (keeping elements of longer) max: [4,3]
                                                                                                                  ↔ -- reverse: [3,4]





                                                                                                                  share|improve this answer













                                                                                                                  Husk, 5 bytes



                                                                                                                  ↔¤żY↔


                                                                                                                  Conveniently takes input/output as list of digits, try it online or verify all!



                                                                                                                  Explanation



                                                                                                                  ↔¤żY↔  -- example inputs [1,4] [3,2]
                                                                                                                  ¤ ↔ -- reverse the arguments of: [4,1] [2,3]
                                                                                                                  żY -- | zipWith (keeping elements of longer) max: [4,3]
                                                                                                                  ↔ -- reverse: [3,4]






                                                                                                                  share|improve this answer












                                                                                                                  share|improve this answer



                                                                                                                  share|improve this answer










                                                                                                                  answered yesterday









                                                                                                                  BMO

                                                                                                                  10.5k21880




                                                                                                                  10.5k21880






















                                                                                                                      up vote
                                                                                                                      1
                                                                                                                      down vote














                                                                                                                      Stax, 5 bytes



                                                                                                                      |>E:o


                                                                                                                      Run and debug it



                                                                                                                      This program takes input as an array of strings.



                                                                                                                      |>  Right align inputs (filling with )
                                                                                                                      E "Explode" array onto stack separately
                                                                                                                      :o "Overlay" Keep the maximum element respective element from two arrays.


                                                                                                                      Run this one



                                                                                                                      This is the first time I've seen a use for the overlay instruction "in the wild".






                                                                                                                      share|improve this answer

























                                                                                                                        up vote
                                                                                                                        1
                                                                                                                        down vote














                                                                                                                        Stax, 5 bytes



                                                                                                                        |>E:o


                                                                                                                        Run and debug it



                                                                                                                        This program takes input as an array of strings.



                                                                                                                        |>  Right align inputs (filling with )
                                                                                                                        E "Explode" array onto stack separately
                                                                                                                        :o "Overlay" Keep the maximum element respective element from two arrays.


                                                                                                                        Run this one



                                                                                                                        This is the first time I've seen a use for the overlay instruction "in the wild".






                                                                                                                        share|improve this answer























                                                                                                                          up vote
                                                                                                                          1
                                                                                                                          down vote










                                                                                                                          up vote
                                                                                                                          1
                                                                                                                          down vote










                                                                                                                          Stax, 5 bytes



                                                                                                                          |>E:o


                                                                                                                          Run and debug it



                                                                                                                          This program takes input as an array of strings.



                                                                                                                          |>  Right align inputs (filling with )
                                                                                                                          E "Explode" array onto stack separately
                                                                                                                          :o "Overlay" Keep the maximum element respective element from two arrays.


                                                                                                                          Run this one



                                                                                                                          This is the first time I've seen a use for the overlay instruction "in the wild".






                                                                                                                          share|improve this answer













                                                                                                                          Stax, 5 bytes



                                                                                                                          |>E:o


                                                                                                                          Run and debug it



                                                                                                                          This program takes input as an array of strings.



                                                                                                                          |>  Right align inputs (filling with )
                                                                                                                          E "Explode" array onto stack separately
                                                                                                                          :o "Overlay" Keep the maximum element respective element from two arrays.


                                                                                                                          Run this one



                                                                                                                          This is the first time I've seen a use for the overlay instruction "in the wild".







                                                                                                                          share|improve this answer












                                                                                                                          share|improve this answer



                                                                                                                          share|improve this answer










                                                                                                                          answered yesterday









                                                                                                                          recursive

                                                                                                                          4,9641221




                                                                                                                          4,9641221






















                                                                                                                              up vote
                                                                                                                              1
                                                                                                                              down vote














                                                                                                                              SNOBOL4 (CSNOBOL4), 153 bytes



                                                                                                                              	X =INPUT
                                                                                                                              Y =INPUT
                                                                                                                              Y =DUPL(0,SIZE(X) - SIZE(Y)) Y
                                                                                                                              S X LEN(1) . A REM . X :F(O)
                                                                                                                              Y LEN(1) . B REM . Y
                                                                                                                              O =O GT(A,B) A :S(S)
                                                                                                                              O =O B :(S)
                                                                                                                              O OUTPUT =O
                                                                                                                              END


                                                                                                                              Try it online!






                                                                                                                              share|improve this answer

























                                                                                                                                up vote
                                                                                                                                1
                                                                                                                                down vote














                                                                                                                                SNOBOL4 (CSNOBOL4), 153 bytes



                                                                                                                                	X =INPUT
                                                                                                                                Y =INPUT
                                                                                                                                Y =DUPL(0,SIZE(X) - SIZE(Y)) Y
                                                                                                                                S X LEN(1) . A REM . X :F(O)
                                                                                                                                Y LEN(1) . B REM . Y
                                                                                                                                O =O GT(A,B) A :S(S)
                                                                                                                                O =O B :(S)
                                                                                                                                O OUTPUT =O
                                                                                                                                END


                                                                                                                                Try it online!






                                                                                                                                share|improve this answer























                                                                                                                                  up vote
                                                                                                                                  1
                                                                                                                                  down vote










                                                                                                                                  up vote
                                                                                                                                  1
                                                                                                                                  down vote










                                                                                                                                  SNOBOL4 (CSNOBOL4), 153 bytes



                                                                                                                                  	X =INPUT
                                                                                                                                  Y =INPUT
                                                                                                                                  Y =DUPL(0,SIZE(X) - SIZE(Y)) Y
                                                                                                                                  S X LEN(1) . A REM . X :F(O)
                                                                                                                                  Y LEN(1) . B REM . Y
                                                                                                                                  O =O GT(A,B) A :S(S)
                                                                                                                                  O =O B :(S)
                                                                                                                                  O OUTPUT =O
                                                                                                                                  END


                                                                                                                                  Try it online!






                                                                                                                                  share|improve this answer













                                                                                                                                  SNOBOL4 (CSNOBOL4), 153 bytes



                                                                                                                                  	X =INPUT
                                                                                                                                  Y =INPUT
                                                                                                                                  Y =DUPL(0,SIZE(X) - SIZE(Y)) Y
                                                                                                                                  S X LEN(1) . A REM . X :F(O)
                                                                                                                                  Y LEN(1) . B REM . Y
                                                                                                                                  O =O GT(A,B) A :S(S)
                                                                                                                                  O =O B :(S)
                                                                                                                                  O OUTPUT =O
                                                                                                                                  END


                                                                                                                                  Try it online!







                                                                                                                                  share|improve this answer












                                                                                                                                  share|improve this answer



                                                                                                                                  share|improve this answer










                                                                                                                                  answered yesterday









                                                                                                                                  Giuseppe

                                                                                                                                  15.9k31052




                                                                                                                                  15.9k31052






















                                                                                                                                      up vote
                                                                                                                                      1
                                                                                                                                      down vote














                                                                                                                                      Retina, 45 bytes



                                                                                                                                      P^`.+
                                                                                                                                      +`^(.*)(.)¶(.*)(.)
                                                                                                                                      $1¶$3¶$2$4
                                                                                                                                      %O`.
                                                                                                                                      ¶.?



                                                                                                                                      Try it online! Link includes test suite. Explanation:



                                                                                                                                      P^`.+


                                                                                                                                      Pad both values to the same length.



                                                                                                                                      +`^(.*)(.)¶(.*)(.)
                                                                                                                                      $1¶$3¶$2$4


                                                                                                                                      Transpose the values.



                                                                                                                                      %O`.


                                                                                                                                      Sort each pair into order.



                                                                                                                                      ¶.?



                                                                                                                                      Delete all the low digits and surplus newlines.






                                                                                                                                      share|improve this answer

























                                                                                                                                        up vote
                                                                                                                                        1
                                                                                                                                        down vote














                                                                                                                                        Retina, 45 bytes



                                                                                                                                        P^`.+
                                                                                                                                        +`^(.*)(.)¶(.*)(.)
                                                                                                                                        $1¶$3¶$2$4
                                                                                                                                        %O`.
                                                                                                                                        ¶.?



                                                                                                                                        Try it online! Link includes test suite. Explanation:



                                                                                                                                        P^`.+


                                                                                                                                        Pad both values to the same length.



                                                                                                                                        +`^(.*)(.)¶(.*)(.)
                                                                                                                                        $1¶$3¶$2$4


                                                                                                                                        Transpose the values.



                                                                                                                                        %O`.


                                                                                                                                        Sort each pair into order.



                                                                                                                                        ¶.?



                                                                                                                                        Delete all the low digits and surplus newlines.






                                                                                                                                        share|improve this answer























                                                                                                                                          up vote
                                                                                                                                          1
                                                                                                                                          down vote










                                                                                                                                          up vote
                                                                                                                                          1
                                                                                                                                          down vote










                                                                                                                                          Retina, 45 bytes



                                                                                                                                          P^`.+
                                                                                                                                          +`^(.*)(.)¶(.*)(.)
                                                                                                                                          $1¶$3¶$2$4
                                                                                                                                          %O`.
                                                                                                                                          ¶.?



                                                                                                                                          Try it online! Link includes test suite. Explanation:



                                                                                                                                          P^`.+


                                                                                                                                          Pad both values to the same length.



                                                                                                                                          +`^(.*)(.)¶(.*)(.)
                                                                                                                                          $1¶$3¶$2$4


                                                                                                                                          Transpose the values.



                                                                                                                                          %O`.


                                                                                                                                          Sort each pair into order.



                                                                                                                                          ¶.?



                                                                                                                                          Delete all the low digits and surplus newlines.






                                                                                                                                          share|improve this answer













                                                                                                                                          Retina, 45 bytes



                                                                                                                                          P^`.+
                                                                                                                                          +`^(.*)(.)¶(.*)(.)
                                                                                                                                          $1¶$3¶$2$4
                                                                                                                                          %O`.
                                                                                                                                          ¶.?



                                                                                                                                          Try it online! Link includes test suite. Explanation:



                                                                                                                                          P^`.+


                                                                                                                                          Pad both values to the same length.



                                                                                                                                          +`^(.*)(.)¶(.*)(.)
                                                                                                                                          $1¶$3¶$2$4


                                                                                                                                          Transpose the values.



                                                                                                                                          %O`.


                                                                                                                                          Sort each pair into order.



                                                                                                                                          ¶.?



                                                                                                                                          Delete all the low digits and surplus newlines.







                                                                                                                                          share|improve this answer












                                                                                                                                          share|improve this answer



                                                                                                                                          share|improve this answer










                                                                                                                                          answered yesterday









                                                                                                                                          Neil

                                                                                                                                          77.9k744174




                                                                                                                                          77.9k744174






















                                                                                                                                              up vote
                                                                                                                                              1
                                                                                                                                              down vote














                                                                                                                                              Charcoal, 14 bytes



                                                                                                                                              ⭆◧θLη⌈⟦ι§◧ηLθκ


                                                                                                                                              Try it online! Link is to verbose version of code. Explanation:



                                                                                                                                                θ             First input
                                                                                                                                              ◧ Padded to
                                                                                                                                              L Length of
                                                                                                                                              η Second input
                                                                                                                                              ⭆ Map over characters and join
                                                                                                                                              ⌈ Maximum of
                                                                                                                                              ⟦ List of
                                                                                                                                              ι Current character of first input and
                                                                                                                                              η Second input
                                                                                                                                              ◧ Padded to
                                                                                                                                              L Length of
                                                                                                                                              θ First input
                                                                                                                                              § Indexed by
                                                                                                                                              κ Current index
                                                                                                                                              Implicitly print


                                                                                                                                              17-byte version "adds" any number of strings:



                                                                                                                                              ≔⌈EθLιη⭆η⌈Eθ§◧ληκ


                                                                                                                                              Try it online! Link is to verbose version of code.






                                                                                                                                              share|improve this answer

























                                                                                                                                                up vote
                                                                                                                                                1
                                                                                                                                                down vote














                                                                                                                                                Charcoal, 14 bytes



                                                                                                                                                ⭆◧θLη⌈⟦ι§◧ηLθκ


                                                                                                                                                Try it online! Link is to verbose version of code. Explanation:



                                                                                                                                                  θ             First input
                                                                                                                                                ◧ Padded to
                                                                                                                                                L Length of
                                                                                                                                                η Second input
                                                                                                                                                ⭆ Map over characters and join
                                                                                                                                                ⌈ Maximum of
                                                                                                                                                ⟦ List of
                                                                                                                                                ι Current character of first input and
                                                                                                                                                η Second input
                                                                                                                                                ◧ Padded to
                                                                                                                                                L Length of
                                                                                                                                                θ First input
                                                                                                                                                § Indexed by
                                                                                                                                                κ Current index
                                                                                                                                                Implicitly print


                                                                                                                                                17-byte version "adds" any number of strings:



                                                                                                                                                ≔⌈EθLιη⭆η⌈Eθ§◧ληκ


                                                                                                                                                Try it online! Link is to verbose version of code.






                                                                                                                                                share|improve this answer























                                                                                                                                                  up vote
                                                                                                                                                  1
                                                                                                                                                  down vote










                                                                                                                                                  up vote
                                                                                                                                                  1
                                                                                                                                                  down vote










                                                                                                                                                  Charcoal, 14 bytes



                                                                                                                                                  ⭆◧θLη⌈⟦ι§◧ηLθκ


                                                                                                                                                  Try it online! Link is to verbose version of code. Explanation:



                                                                                                                                                    θ             First input
                                                                                                                                                  ◧ Padded to
                                                                                                                                                  L Length of
                                                                                                                                                  η Second input
                                                                                                                                                  ⭆ Map over characters and join
                                                                                                                                                  ⌈ Maximum of
                                                                                                                                                  ⟦ List of
                                                                                                                                                  ι Current character of first input and
                                                                                                                                                  η Second input
                                                                                                                                                  ◧ Padded to
                                                                                                                                                  L Length of
                                                                                                                                                  θ First input
                                                                                                                                                  § Indexed by
                                                                                                                                                  κ Current index
                                                                                                                                                  Implicitly print


                                                                                                                                                  17-byte version "adds" any number of strings:



                                                                                                                                                  ≔⌈EθLιη⭆η⌈Eθ§◧ληκ


                                                                                                                                                  Try it online! Link is to verbose version of code.






                                                                                                                                                  share|improve this answer













                                                                                                                                                  Charcoal, 14 bytes



                                                                                                                                                  ⭆◧θLη⌈⟦ι§◧ηLθκ


                                                                                                                                                  Try it online! Link is to verbose version of code. Explanation:



                                                                                                                                                    θ             First input
                                                                                                                                                  ◧ Padded to
                                                                                                                                                  L Length of
                                                                                                                                                  η Second input
                                                                                                                                                  ⭆ Map over characters and join
                                                                                                                                                  ⌈ Maximum of
                                                                                                                                                  ⟦ List of
                                                                                                                                                  ι Current character of first input and
                                                                                                                                                  η Second input
                                                                                                                                                  ◧ Padded to
                                                                                                                                                  L Length of
                                                                                                                                                  θ First input
                                                                                                                                                  § Indexed by
                                                                                                                                                  κ Current index
                                                                                                                                                  Implicitly print


                                                                                                                                                  17-byte version "adds" any number of strings:



                                                                                                                                                  ≔⌈EθLιη⭆η⌈Eθ§◧ληκ


                                                                                                                                                  Try it online! Link is to verbose version of code.







                                                                                                                                                  share|improve this answer












                                                                                                                                                  share|improve this answer



                                                                                                                                                  share|improve this answer










                                                                                                                                                  answered yesterday









                                                                                                                                                  Neil

                                                                                                                                                  77.9k744174




                                                                                                                                                  77.9k744174






















                                                                                                                                                      up vote
                                                                                                                                                      1
                                                                                                                                                      down vote













                                                                                                                                                      Pyth, 5 bytes



                                                                                                                                                      meSdC


                                                                                                                                                      Takes input as array of two space-padded strings.



                                                                                                                                                      meSd       map greatest
                                                                                                                                                      C on the transpose of input


                                                                                                                                                      Try it here.






                                                                                                                                                      share|improve this answer

























                                                                                                                                                        up vote
                                                                                                                                                        1
                                                                                                                                                        down vote













                                                                                                                                                        Pyth, 5 bytes



                                                                                                                                                        meSdC


                                                                                                                                                        Takes input as array of two space-padded strings.



                                                                                                                                                        meSd       map greatest
                                                                                                                                                        C on the transpose of input


                                                                                                                                                        Try it here.






                                                                                                                                                        share|improve this answer























                                                                                                                                                          up vote
                                                                                                                                                          1
                                                                                                                                                          down vote










                                                                                                                                                          up vote
                                                                                                                                                          1
                                                                                                                                                          down vote









                                                                                                                                                          Pyth, 5 bytes



                                                                                                                                                          meSdC


                                                                                                                                                          Takes input as array of two space-padded strings.



                                                                                                                                                          meSd       map greatest
                                                                                                                                                          C on the transpose of input


                                                                                                                                                          Try it here.






                                                                                                                                                          share|improve this answer












                                                                                                                                                          Pyth, 5 bytes



                                                                                                                                                          meSdC


                                                                                                                                                          Takes input as array of two space-padded strings.



                                                                                                                                                          meSd       map greatest
                                                                                                                                                          C on the transpose of input


                                                                                                                                                          Try it here.







                                                                                                                                                          share|improve this answer












                                                                                                                                                          share|improve this answer



                                                                                                                                                          share|improve this answer










                                                                                                                                                          answered yesterday









                                                                                                                                                          lirtosiast

                                                                                                                                                          15.1k436102




                                                                                                                                                          15.1k436102






















                                                                                                                                                              up vote
                                                                                                                                                              1
                                                                                                                                                              down vote














                                                                                                                                                              Twig, 125 bytes



                                                                                                                                                              When I saw this challenge, I though: "let me use a template language! sure is a good fit"



                                                                                                                                                              I was wrong ... so wrong .... ... But was fun!



                                                                                                                                                              {%macro a(a,b,s='')%}{%for k,x in a|reverse|split('')%}{%set s=max(x,(b|reverse|split('')[k]))~s%}{%endfor%}{{s}}{%endmacro%}


                                                                                                                                                              This requires that "strict_variables" is set to false (default value).



                                                                                                                                                              To use this macro, you can do like this:



                                                                                                                                                              {% import 'file.twig' as my_macro %}

                                                                                                                                                              {{ my_macro.a(195,67) }}


                                                                                                                                                              Should display 167.



                                                                                                                                                              You can try this in https://twigfiddle.com/rg0biy

                                                                                                                                                              ("strict_variables" set to off, it is on by default on the website)






                                                                                                                                                              share|improve this answer

























                                                                                                                                                                up vote
                                                                                                                                                                1
                                                                                                                                                                down vote














                                                                                                                                                                Twig, 125 bytes



                                                                                                                                                                When I saw this challenge, I though: "let me use a template language! sure is a good fit"



                                                                                                                                                                I was wrong ... so wrong .... ... But was fun!



                                                                                                                                                                {%macro a(a,b,s='')%}{%for k,x in a|reverse|split('')%}{%set s=max(x,(b|reverse|split('')[k]))~s%}{%endfor%}{{s}}{%endmacro%}


                                                                                                                                                                This requires that "strict_variables" is set to false (default value).



                                                                                                                                                                To use this macro, you can do like this:



                                                                                                                                                                {% import 'file.twig' as my_macro %}

                                                                                                                                                                {{ my_macro.a(195,67) }}


                                                                                                                                                                Should display 167.



                                                                                                                                                                You can try this in https://twigfiddle.com/rg0biy

                                                                                                                                                                ("strict_variables" set to off, it is on by default on the website)






                                                                                                                                                                share|improve this answer























                                                                                                                                                                  up vote
                                                                                                                                                                  1
                                                                                                                                                                  down vote










                                                                                                                                                                  up vote
                                                                                                                                                                  1
                                                                                                                                                                  down vote










                                                                                                                                                                  Twig, 125 bytes



                                                                                                                                                                  When I saw this challenge, I though: "let me use a template language! sure is a good fit"



                                                                                                                                                                  I was wrong ... so wrong .... ... But was fun!



                                                                                                                                                                  {%macro a(a,b,s='')%}{%for k,x in a|reverse|split('')%}{%set s=max(x,(b|reverse|split('')[k]))~s%}{%endfor%}{{s}}{%endmacro%}


                                                                                                                                                                  This requires that "strict_variables" is set to false (default value).



                                                                                                                                                                  To use this macro, you can do like this:



                                                                                                                                                                  {% import 'file.twig' as my_macro %}

                                                                                                                                                                  {{ my_macro.a(195,67) }}


                                                                                                                                                                  Should display 167.



                                                                                                                                                                  You can try this in https://twigfiddle.com/rg0biy

                                                                                                                                                                  ("strict_variables" set to off, it is on by default on the website)






                                                                                                                                                                  share|improve this answer













                                                                                                                                                                  Twig, 125 bytes



                                                                                                                                                                  When I saw this challenge, I though: "let me use a template language! sure is a good fit"



                                                                                                                                                                  I was wrong ... so wrong .... ... But was fun!



                                                                                                                                                                  {%macro a(a,b,s='')%}{%for k,x in a|reverse|split('')%}{%set s=max(x,(b|reverse|split('')[k]))~s%}{%endfor%}{{s}}{%endmacro%}


                                                                                                                                                                  This requires that "strict_variables" is set to false (default value).



                                                                                                                                                                  To use this macro, you can do like this:



                                                                                                                                                                  {% import 'file.twig' as my_macro %}

                                                                                                                                                                  {{ my_macro.a(195,67) }}


                                                                                                                                                                  Should display 167.



                                                                                                                                                                  You can try this in https://twigfiddle.com/rg0biy

                                                                                                                                                                  ("strict_variables" set to off, it is on by default on the website)







                                                                                                                                                                  share|improve this answer












                                                                                                                                                                  share|improve this answer



                                                                                                                                                                  share|improve this answer










                                                                                                                                                                  answered yesterday









                                                                                                                                                                  Ismael Miguel

                                                                                                                                                                  6,17811432




                                                                                                                                                                  6,17811432






















                                                                                                                                                                      up vote
                                                                                                                                                                      1
                                                                                                                                                                      down vote














                                                                                                                                                                      C# (.NET Core), 58 bytes



                                                                                                                                                                      (a,b)=>a.Select((x,i)=>a[i]>b[i]?x:b[i])


                                                                                                                                                                      Try It Online






                                                                                                                                                                      share|improve this answer

























                                                                                                                                                                        up vote
                                                                                                                                                                        1
                                                                                                                                                                        down vote














                                                                                                                                                                        C# (.NET Core), 58 bytes



                                                                                                                                                                        (a,b)=>a.Select((x,i)=>a[i]>b[i]?x:b[i])


                                                                                                                                                                        Try It Online






                                                                                                                                                                        share|improve this answer























                                                                                                                                                                          up vote
                                                                                                                                                                          1
                                                                                                                                                                          down vote










                                                                                                                                                                          up vote
                                                                                                                                                                          1
                                                                                                                                                                          down vote










                                                                                                                                                                          C# (.NET Core), 58 bytes



                                                                                                                                                                          (a,b)=>a.Select((x,i)=>a[i]>b[i]?x:b[i])


                                                                                                                                                                          Try It Online






                                                                                                                                                                          share|improve this answer













                                                                                                                                                                          C# (.NET Core), 58 bytes



                                                                                                                                                                          (a,b)=>a.Select((x,i)=>a[i]>b[i]?x:b[i])


                                                                                                                                                                          Try It Online







                                                                                                                                                                          share|improve this answer












                                                                                                                                                                          share|improve this answer



                                                                                                                                                                          share|improve this answer










                                                                                                                                                                          answered yesterday









                                                                                                                                                                          LiefdeWen

                                                                                                                                                                          2,502936




                                                                                                                                                                          2,502936






















                                                                                                                                                                              up vote
                                                                                                                                                                              1
                                                                                                                                                                              down vote














                                                                                                                                                                              Japt, 4 bytes



                                                                                                                                                                              Input is taken as a an array of two 0-padded number arrays.



                                                                                                                                                                              y_rw


                                                                                                                                                                              Try it online!






                                                                                                                                                                              share|improve this answer

























                                                                                                                                                                                up vote
                                                                                                                                                                                1
                                                                                                                                                                                down vote














                                                                                                                                                                                Japt, 4 bytes



                                                                                                                                                                                Input is taken as a an array of two 0-padded number arrays.



                                                                                                                                                                                y_rw


                                                                                                                                                                                Try it online!






                                                                                                                                                                                share|improve this answer























                                                                                                                                                                                  up vote
                                                                                                                                                                                  1
                                                                                                                                                                                  down vote










                                                                                                                                                                                  up vote
                                                                                                                                                                                  1
                                                                                                                                                                                  down vote










                                                                                                                                                                                  Japt, 4 bytes



                                                                                                                                                                                  Input is taken as a an array of two 0-padded number arrays.



                                                                                                                                                                                  y_rw


                                                                                                                                                                                  Try it online!






                                                                                                                                                                                  share|improve this answer













                                                                                                                                                                                  Japt, 4 bytes



                                                                                                                                                                                  Input is taken as a an array of two 0-padded number arrays.



                                                                                                                                                                                  y_rw


                                                                                                                                                                                  Try it online!







                                                                                                                                                                                  share|improve this answer












                                                                                                                                                                                  share|improve this answer



                                                                                                                                                                                  share|improve this answer










                                                                                                                                                                                  answered 21 hours ago









                                                                                                                                                                                  Oliver

                                                                                                                                                                                  4,4801828




                                                                                                                                                                                  4,4801828






















                                                                                                                                                                                      up vote
                                                                                                                                                                                      0
                                                                                                                                                                                      down vote













                                                                                                                                                                                      Mathematica 50 bytes



                                                                                                                                                                                      a = 543;
                                                                                                                                                                                      b = 791;



                                                                                                                                                                                      FromDigits@MapThread[Max, IntegerDigits /@ {a, b}]


                                                                                                                                                                                      (* 793 *)






                                                                                                                                                                                      share|improve this answer

















                                                                                                                                                                                      • 1




                                                                                                                                                                                        Can you add a TIO? I don't know Mathematica but I suspect this might fail if the 2 inputs don't have an equal number of digits.
                                                                                                                                                                                        – Shaggy
                                                                                                                                                                                        yesterday






                                                                                                                                                                                      • 1




                                                                                                                                                                                        I think you're taking input through predefined variables, which would make this a snippet, which is not allowed. Submissions should be either a function or a full program
                                                                                                                                                                                        – Jo King
                                                                                                                                                                                        yesterday















                                                                                                                                                                                      up vote
                                                                                                                                                                                      0
                                                                                                                                                                                      down vote













                                                                                                                                                                                      Mathematica 50 bytes



                                                                                                                                                                                      a = 543;
                                                                                                                                                                                      b = 791;



                                                                                                                                                                                      FromDigits@MapThread[Max, IntegerDigits /@ {a, b}]


                                                                                                                                                                                      (* 793 *)






                                                                                                                                                                                      share|improve this answer

















                                                                                                                                                                                      • 1




                                                                                                                                                                                        Can you add a TIO? I don't know Mathematica but I suspect this might fail if the 2 inputs don't have an equal number of digits.
                                                                                                                                                                                        – Shaggy
                                                                                                                                                                                        yesterday






                                                                                                                                                                                      • 1




                                                                                                                                                                                        I think you're taking input through predefined variables, which would make this a snippet, which is not allowed. Submissions should be either a function or a full program
                                                                                                                                                                                        – Jo King
                                                                                                                                                                                        yesterday













                                                                                                                                                                                      up vote
                                                                                                                                                                                      0
                                                                                                                                                                                      down vote










                                                                                                                                                                                      up vote
                                                                                                                                                                                      0
                                                                                                                                                                                      down vote









                                                                                                                                                                                      Mathematica 50 bytes



                                                                                                                                                                                      a = 543;
                                                                                                                                                                                      b = 791;



                                                                                                                                                                                      FromDigits@MapThread[Max, IntegerDigits /@ {a, b}]


                                                                                                                                                                                      (* 793 *)






                                                                                                                                                                                      share|improve this answer












                                                                                                                                                                                      Mathematica 50 bytes



                                                                                                                                                                                      a = 543;
                                                                                                                                                                                      b = 791;



                                                                                                                                                                                      FromDigits@MapThread[Max, IntegerDigits /@ {a, b}]


                                                                                                                                                                                      (* 793 *)







                                                                                                                                                                                      share|improve this answer












                                                                                                                                                                                      share|improve this answer



                                                                                                                                                                                      share|improve this answer










                                                                                                                                                                                      answered yesterday









                                                                                                                                                                                      David G. Stork

                                                                                                                                                                                      1857




                                                                                                                                                                                      1857








                                                                                                                                                                                      • 1




                                                                                                                                                                                        Can you add a TIO? I don't know Mathematica but I suspect this might fail if the 2 inputs don't have an equal number of digits.
                                                                                                                                                                                        – Shaggy
                                                                                                                                                                                        yesterday






                                                                                                                                                                                      • 1




                                                                                                                                                                                        I think you're taking input through predefined variables, which would make this a snippet, which is not allowed. Submissions should be either a function or a full program
                                                                                                                                                                                        – Jo King
                                                                                                                                                                                        yesterday














                                                                                                                                                                                      • 1




                                                                                                                                                                                        Can you add a TIO? I don't know Mathematica but I suspect this might fail if the 2 inputs don't have an equal number of digits.
                                                                                                                                                                                        – Shaggy
                                                                                                                                                                                        yesterday






                                                                                                                                                                                      • 1




                                                                                                                                                                                        I think you're taking input through predefined variables, which would make this a snippet, which is not allowed. Submissions should be either a function or a full program
                                                                                                                                                                                        – Jo King
                                                                                                                                                                                        yesterday








                                                                                                                                                                                      1




                                                                                                                                                                                      1




                                                                                                                                                                                      Can you add a TIO? I don't know Mathematica but I suspect this might fail if the 2 inputs don't have an equal number of digits.
                                                                                                                                                                                      – Shaggy
                                                                                                                                                                                      yesterday




                                                                                                                                                                                      Can you add a TIO? I don't know Mathematica but I suspect this might fail if the 2 inputs don't have an equal number of digits.
                                                                                                                                                                                      – Shaggy
                                                                                                                                                                                      yesterday




                                                                                                                                                                                      1




                                                                                                                                                                                      1




                                                                                                                                                                                      I think you're taking input through predefined variables, which would make this a snippet, which is not allowed. Submissions should be either a function or a full program
                                                                                                                                                                                      – Jo King
                                                                                                                                                                                      yesterday




                                                                                                                                                                                      I think you're taking input through predefined variables, which would make this a snippet, which is not allowed. Submissions should be either a function or a full program
                                                                                                                                                                                      – Jo King
                                                                                                                                                                                      yesterday


















                                                                                                                                                                                       

                                                                                                                                                                                      draft saved


                                                                                                                                                                                      draft discarded



















































                                                                                                                                                                                       


                                                                                                                                                                                      draft saved


                                                                                                                                                                                      draft discarded














                                                                                                                                                                                      StackExchange.ready(
                                                                                                                                                                                      function () {
                                                                                                                                                                                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f176010%2fstrange-addition%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

                                                                                                                                                                                      Costa Masnaga

                                                                                                                                                                                      Fotorealismo

                                                                                                                                                                                      Sidney Franklin