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




















  • 3




    also known as lunar addition
    – TFeld
    Nov 15 at 14:38








  • 3




    Can we take the input as zero-padded strings (same length)?
    – TFeld
    Nov 15 at 14:44






  • 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
    Nov 15 at 16:09






  • 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
    Nov 15 at 19:00






  • 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
    Nov 15 at 19:01

















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




















  • 3




    also known as lunar addition
    – TFeld
    Nov 15 at 14:38








  • 3




    Can we take the input as zero-padded strings (same length)?
    – TFeld
    Nov 15 at 14:44






  • 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
    Nov 15 at 16:09






  • 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
    Nov 15 at 19:00






  • 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
    Nov 15 at 19:01















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 Nov 16 at 13:05

























asked Nov 15 at 14:37









mdahmoune

1,2521721




1,2521721








  • 3




    also known as lunar addition
    – TFeld
    Nov 15 at 14:38








  • 3




    Can we take the input as zero-padded strings (same length)?
    – TFeld
    Nov 15 at 14:44






  • 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
    Nov 15 at 16:09






  • 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
    Nov 15 at 19:00






  • 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
    Nov 15 at 19:01
















  • 3




    also known as lunar addition
    – TFeld
    Nov 15 at 14:38








  • 3




    Can we take the input as zero-padded strings (same length)?
    – TFeld
    Nov 15 at 14:44






  • 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
    Nov 15 at 16:09






  • 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
    Nov 15 at 19:00






  • 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
    Nov 15 at 19:01










3




3




also known as lunar addition
– TFeld
Nov 15 at 14:38






also known as lunar addition
– TFeld
Nov 15 at 14:38






3




3




Can we take the input as zero-padded strings (same length)?
– TFeld
Nov 15 at 14:44




Can we take the input as zero-padded strings (same length)?
– TFeld
Nov 15 at 14:44




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
Nov 15 at 16:09




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
Nov 15 at 16:09




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
Nov 15 at 19:00




@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
Nov 15 at 19:00




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
Nov 15 at 19:01






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
Nov 15 at 19:01












27 Answers
27






active

oldest

votes

















up vote
14
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














    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
            5
            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
              Nov 16 at 12:30










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


















            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
              Nov 15 at 17:06








            • 1




              @Jonah Of course! Thank you!
              – Galen Ivanov
              Nov 15 at 18:05






            • 1




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


















            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
              Nov 15 at 17:13










            • @KamilDrakari: Uncanny - I was just updating with the exact same solution!
              – Shaggy
              Nov 15 at 17:14










            • Interestingly, the version that separates the "transpose" and "reduce" steps is also 8 bytes because of better shortcuts
              – Kamil Drakari
              Nov 15 at 17:20










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










            • Ooh, that's a neat trick with '. I don't know whether that would ever save bytes, but it's definitely cool.
              – Kamil Drakari
              Nov 15 at 17:25


















            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
                Nov 15 at 16:50










              • @Emigna Thanks! I thought I tried it without €þ and it didn't work, but now it does...
                – Riley
                Nov 15 at 16:59










              • Do you need the J at the end?
                – Shaggy
                Nov 15 at 19:57










              • @Shaggy No, I guess I don't. Thanks!
                – Riley
                Nov 15 at 21:00










              • It's lame, but the rules allow a 3 byte solution by taking a 2D space-padded char array..
                – Kevin Cruijssen
                Nov 16 at 8:40


















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














                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
                    Nov 15 at 22:20










                  • 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
                    Nov 16 at 9:35






                  • 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
                    Nov 16 at 9:53










                  • @Arnauld Thank you! :)
                    – Neyt
                    Nov 16 at 9:54


















                  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
                    Nov 16 at 12:28


















                  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














                    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














                      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













                            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














                              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













                                Ceylon, 55 / 99





                                With 0- or space-padded strings of same length (returning an iterable of characters):



                                function t(String a,String b)=>zipPairs(a,b).map(max);


                                With 0- or space-padded strings (returning a String):



                                String t(String a,String b)=>String(zipPairs(a,b).map(max));


                                With strings of possibly different length (returning a String):



                                String u(String a,String b)=>String(zipPairs(a.padLeading(b.size),b.padLeading(a.size)).map(max));





                                share|improve this answer




























                                  up vote
                                  1
                                  down vote














                                  C# (.NET Core), 57 bytes



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


                                  -1 bytes by adding currying



                                  Try It Online






                                  share|improve this answer






























                                    up vote
                                    1
                                    down vote














                                    Ruby, 25 bytes





                                    ->a,b{a.zip(b).map &:max}


                                    Try it online!



                                    Pre-padded list blah blah. (Although it feels a little like cheating.)






                                    share|improve this answer




























                                      up vote
                                      1
                                      down vote














                                      Retina 0.8.2, 39 bytes



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



                                      Try it online! Link includes test suite. Previous 45-byte Retina 1 version accepts unpadded strings:



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



                                      Try it online! Link includes test suite. Explanation:



                                      P^`.+


                                      Pad both values to the same length. (Retina 1 only. There are ways of emulating this in Retina 0.8.2 but they are not very golfy.)



                                      +`^(.*)(.)¶(.*)(.)
                                      $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, 8 bytes



                                        ⭆θ⌈⟦ι§ηκ


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



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


                                        10-byte version "adds" any number of padded strings:



                                        ⭆§θ⁰⌈Eθ§λκ


                                        Try it online! Link is to verbose version of code. Previous 14-byte version accepts unpadded strings:



                                        ⭆◧θ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























                                        • The question has been changed so the strings can be input as padded
                                          – ASCII-only
                                          18 hours ago










                                        • Nitpicking, but you missed a close paren in the first verbose version :P
                                          – ASCII-only
                                          2 hours ago


















                                        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
                                          Nov 15 at 23:22






                                        • 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
                                          Nov 16 at 2:09











                                        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

























                                        27 Answers
                                        27






                                        active

                                        oldest

                                        votes








                                        27 Answers
                                        27






                                        active

                                        oldest

                                        votes









                                        active

                                        oldest

                                        votes






                                        active

                                        oldest

                                        votes








                                        up vote
                                        14
                                        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
                                          14
                                          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
                                            14
                                            down vote










                                            up vote
                                            14
                                            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 Nov 16 at 12:19

























                                            answered Nov 15 at 15:11









                                            Erik the Outgolfer

                                            30.7k429102




                                            30.7k429102






















                                                up vote
                                                11
                                                down vote














                                                Jelly, 1 byte



                                                »


                                                Try it online!



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






                                                share|improve this answer



























                                                  up vote
                                                  11
                                                  down vote














                                                  Jelly, 1 byte



                                                  »


                                                  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










                                                    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 Nov 16 at 12:16

























                                                    answered Nov 15 at 14:54









                                                    Erik the Outgolfer

                                                    30.7k429102




                                                    30.7k429102






















                                                        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 Nov 15 at 18:12

























                                                            answered Nov 15 at 15:20









                                                            Giuseppe

                                                            16k31052




                                                            16k31052






















                                                                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 Nov 16 at 1:17









                                                                    Luis Mendo

                                                                    73.7k885289




                                                                    73.7k885289






















                                                                        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 Nov 15 at 15:04

























                                                                            answered Nov 15 at 14:48









                                                                            TFeld

                                                                            13.5k21139




                                                                            13.5k21139






















                                                                                up vote
                                                                                5
                                                                                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
                                                                                  Nov 16 at 12:30










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















                                                                                up vote
                                                                                5
                                                                                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
                                                                                  Nov 16 at 12:30










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













                                                                                up vote
                                                                                5
                                                                                down vote










                                                                                up vote
                                                                                5
                                                                                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 Nov 16 at 12:59

























                                                                                answered Nov 16 at 8:47









                                                                                Kevin Cruijssen

                                                                                34.1k554181




                                                                                34.1k554181








                                                                                • 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
                                                                                  Nov 16 at 12:30










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














                                                                                • 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
                                                                                  Nov 16 at 12:30










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








                                                                                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
                                                                                Nov 16 at 12:30




                                                                                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
                                                                                Nov 16 at 12:30












                                                                                @OlivierGrégoire Ah, can't believe I hadn't thought of that. Thanks! :D
                                                                                – Kevin Cruijssen
                                                                                Nov 16 at 12:59




                                                                                @OlivierGrégoire Ah, can't believe I hadn't thought of that. Thanks! :D
                                                                                – Kevin Cruijssen
                                                                                Nov 16 at 12:59










                                                                                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
                                                                                  Nov 15 at 17:06








                                                                                • 1




                                                                                  @Jonah Of course! Thank you!
                                                                                  – Galen Ivanov
                                                                                  Nov 15 at 18:05






                                                                                • 1




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















                                                                                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
                                                                                  Nov 15 at 17:06








                                                                                • 1




                                                                                  @Jonah Of course! Thank you!
                                                                                  – Galen Ivanov
                                                                                  Nov 15 at 18:05






                                                                                • 1




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













                                                                                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 Nov 15 at 18:03

























                                                                                answered Nov 15 at 15:21









                                                                                Galen Ivanov

                                                                                5,89711032




                                                                                5,89711032








                                                                                • 1




                                                                                  12 bytes: (>./@,:)&.|.. Try it online!
                                                                                  – Jonah
                                                                                  Nov 15 at 17:06








                                                                                • 1




                                                                                  @Jonah Of course! Thank you!
                                                                                  – Galen Ivanov
                                                                                  Nov 15 at 18:05






                                                                                • 1




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














                                                                                • 1




                                                                                  12 bytes: (>./@,:)&.|.. Try it online!
                                                                                  – Jonah
                                                                                  Nov 15 at 17:06








                                                                                • 1




                                                                                  @Jonah Of course! Thank you!
                                                                                  – Galen Ivanov
                                                                                  Nov 15 at 18:05






                                                                                • 1




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








                                                                                1




                                                                                1




                                                                                12 bytes: (>./@,:)&.|.. Try it online!
                                                                                – Jonah
                                                                                Nov 15 at 17:06






                                                                                12 bytes: (>./@,:)&.|.. Try it online!
                                                                                – Jonah
                                                                                Nov 15 at 17:06






                                                                                1




                                                                                1




                                                                                @Jonah Of course! Thank you!
                                                                                – Galen Ivanov
                                                                                Nov 15 at 18:05




                                                                                @Jonah Of course! Thank you!
                                                                                – Galen Ivanov
                                                                                Nov 15 at 18:05




                                                                                1




                                                                                1




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




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










                                                                                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
                                                                                  Nov 15 at 17:13










                                                                                • @KamilDrakari: Uncanny - I was just updating with the exact same solution!
                                                                                  – Shaggy
                                                                                  Nov 15 at 17:14










                                                                                • Interestingly, the version that separates the "transpose" and "reduce" steps is also 8 bytes because of better shortcuts
                                                                                  – Kamil Drakari
                                                                                  Nov 15 at 17:20










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










                                                                                • Ooh, that's a neat trick with '. I don't know whether that would ever save bytes, but it's definitely cool.
                                                                                  – Kamil Drakari
                                                                                  Nov 15 at 17:25















                                                                                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
                                                                                  Nov 15 at 17:13










                                                                                • @KamilDrakari: Uncanny - I was just updating with the exact same solution!
                                                                                  – Shaggy
                                                                                  Nov 15 at 17:14










                                                                                • Interestingly, the version that separates the "transpose" and "reduce" steps is also 8 bytes because of better shortcuts
                                                                                  – Kamil Drakari
                                                                                  Nov 15 at 17:20










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










                                                                                • Ooh, that's a neat trick with '. I don't know whether that would ever save bytes, but it's definitely cool.
                                                                                  – Kamil Drakari
                                                                                  Nov 15 at 17:25













                                                                                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 Nov 15 at 18:11

























                                                                                answered Nov 15 at 15:50









                                                                                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
                                                                                  Nov 15 at 17:13










                                                                                • @KamilDrakari: Uncanny - I was just updating with the exact same solution!
                                                                                  – Shaggy
                                                                                  Nov 15 at 17:14










                                                                                • Interestingly, the version that separates the "transpose" and "reduce" steps is also 8 bytes because of better shortcuts
                                                                                  – Kamil Drakari
                                                                                  Nov 15 at 17:20










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










                                                                                • Ooh, that's a neat trick with '. I don't know whether that would ever save bytes, but it's definitely cool.
                                                                                  – Kamil Drakari
                                                                                  Nov 15 at 17:25














                                                                                • 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
                                                                                  Nov 15 at 17:13










                                                                                • @KamilDrakari: Uncanny - I was just updating with the exact same solution!
                                                                                  – Shaggy
                                                                                  Nov 15 at 17:14










                                                                                • Interestingly, the version that separates the "transpose" and "reduce" steps is also 8 bytes because of better shortcuts
                                                                                  – Kamil Drakari
                                                                                  Nov 15 at 17:20










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










                                                                                • Ooh, that's a neat trick with '. I don't know whether that would ever save bytes, but it's definitely cool.
                                                                                  – Kamil Drakari
                                                                                  Nov 15 at 17:25








                                                                                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
                                                                                Nov 15 at 17:13




                                                                                Here's another 8 byte solution with a different strategy and simpler input format. maybe you can shave a byte from that?
                                                                                – Kamil Drakari
                                                                                Nov 15 at 17:13












                                                                                @KamilDrakari: Uncanny - I was just updating with the exact same solution!
                                                                                – Shaggy
                                                                                Nov 15 at 17:14




                                                                                @KamilDrakari: Uncanny - I was just updating with the exact same solution!
                                                                                – Shaggy
                                                                                Nov 15 at 17:14












                                                                                Interestingly, the version that separates the "transpose" and "reduce" steps is also 8 bytes because of better shortcuts
                                                                                – Kamil Drakari
                                                                                Nov 15 at 17:20




                                                                                Interestingly, the version that separates the "transpose" and "reduce" steps is also 8 bytes because of better shortcuts
                                                                                – Kamil Drakari
                                                                                Nov 15 at 17:20












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




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












                                                                                Ooh, that's a neat trick with '. I don't know whether that would ever save bytes, but it's definitely cool.
                                                                                – Kamil Drakari
                                                                                Nov 15 at 17:25




                                                                                Ooh, that's a neat trick with '. I don't know whether that would ever save bytes, but it's definitely cool.
                                                                                – Kamil Drakari
                                                                                Nov 15 at 17:25










                                                                                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 Nov 15 at 19:03









                                                                                    Sean

                                                                                    3,09636




                                                                                    3,09636






















                                                                                        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
                                                                                          Nov 15 at 16:50










                                                                                        • @Emigna Thanks! I thought I tried it without €þ and it didn't work, but now it does...
                                                                                          – Riley
                                                                                          Nov 15 at 16:59










                                                                                        • Do you need the J at the end?
                                                                                          – Shaggy
                                                                                          Nov 15 at 19:57










                                                                                        • @Shaggy No, I guess I don't. Thanks!
                                                                                          – Riley
                                                                                          Nov 15 at 21:00










                                                                                        • It's lame, but the rules allow a 3 byte solution by taking a 2D space-padded char array..
                                                                                          – Kevin Cruijssen
                                                                                          Nov 16 at 8:40















                                                                                        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
                                                                                          Nov 15 at 16:50










                                                                                        • @Emigna Thanks! I thought I tried it without €þ and it didn't work, but now it does...
                                                                                          – Riley
                                                                                          Nov 15 at 16:59










                                                                                        • Do you need the J at the end?
                                                                                          – Shaggy
                                                                                          Nov 15 at 19:57










                                                                                        • @Shaggy No, I guess I don't. Thanks!
                                                                                          – Riley
                                                                                          Nov 15 at 21:00










                                                                                        • It's lame, but the rules allow a 3 byte solution by taking a 2D space-padded char array..
                                                                                          – Kevin Cruijssen
                                                                                          Nov 16 at 8:40













                                                                                        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 Nov 15 at 21:00

























                                                                                        answered Nov 15 at 15:23









                                                                                        Riley

                                                                                        10.9k11448




                                                                                        10.9k11448












                                                                                        • €R can be í. Also, I don't think you need €þ as number > space
                                                                                          – Emigna
                                                                                          Nov 15 at 16:50










                                                                                        • @Emigna Thanks! I thought I tried it without €þ and it didn't work, but now it does...
                                                                                          – Riley
                                                                                          Nov 15 at 16:59










                                                                                        • Do you need the J at the end?
                                                                                          – Shaggy
                                                                                          Nov 15 at 19:57










                                                                                        • @Shaggy No, I guess I don't. Thanks!
                                                                                          – Riley
                                                                                          Nov 15 at 21:00










                                                                                        • It's lame, but the rules allow a 3 byte solution by taking a 2D space-padded char array..
                                                                                          – Kevin Cruijssen
                                                                                          Nov 16 at 8:40


















                                                                                        • €R can be í. Also, I don't think you need €þ as number > space
                                                                                          – Emigna
                                                                                          Nov 15 at 16:50










                                                                                        • @Emigna Thanks! I thought I tried it without €þ and it didn't work, but now it does...
                                                                                          – Riley
                                                                                          Nov 15 at 16:59










                                                                                        • Do you need the J at the end?
                                                                                          – Shaggy
                                                                                          Nov 15 at 19:57










                                                                                        • @Shaggy No, I guess I don't. Thanks!
                                                                                          – Riley
                                                                                          Nov 15 at 21:00










                                                                                        • It's lame, but the rules allow a 3 byte solution by taking a 2D space-padded char array..
                                                                                          – Kevin Cruijssen
                                                                                          Nov 16 at 8:40
















                                                                                        €R can be í. Also, I don't think you need €þ as number > space
                                                                                        – Emigna
                                                                                        Nov 15 at 16:50




                                                                                        €R can be í. Also, I don't think you need €þ as number > space
                                                                                        – Emigna
                                                                                        Nov 15 at 16:50












                                                                                        @Emigna Thanks! I thought I tried it without €þ and it didn't work, but now it does...
                                                                                        – Riley
                                                                                        Nov 15 at 16:59




                                                                                        @Emigna Thanks! I thought I tried it without €þ and it didn't work, but now it does...
                                                                                        – Riley
                                                                                        Nov 15 at 16:59












                                                                                        Do you need the J at the end?
                                                                                        – Shaggy
                                                                                        Nov 15 at 19:57




                                                                                        Do you need the J at the end?
                                                                                        – Shaggy
                                                                                        Nov 15 at 19:57












                                                                                        @Shaggy No, I guess I don't. Thanks!
                                                                                        – Riley
                                                                                        Nov 15 at 21:00




                                                                                        @Shaggy No, I guess I don't. Thanks!
                                                                                        – Riley
                                                                                        Nov 15 at 21:00












                                                                                        It's lame, but the rules allow a 3 byte solution by taking a 2D space-padded char array..
                                                                                        – Kevin Cruijssen
                                                                                        Nov 16 at 8:40




                                                                                        It's lame, but the rules allow a 3 byte solution by taking a 2D space-padded char array..
                                                                                        – Kevin Cruijssen
                                                                                        Nov 16 at 8:40










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










                                                                                            up vote
                                                                                            4
                                                                                            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 Nov 16 at 12:34

























                                                                                            answered Nov 16 at 2:39









                                                                                            Jo King

                                                                                            19.2k244102




                                                                                            19.2k244102






















                                                                                                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 Nov 15 at 18:20

























                                                                                                    answered Nov 15 at 18:15









                                                                                                    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
                                                                                                          Nov 15 at 22:20










                                                                                                        • 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
                                                                                                          Nov 16 at 9:35






                                                                                                        • 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
                                                                                                          Nov 16 at 9:53










                                                                                                        • @Arnauld Thank you! :)
                                                                                                          – Neyt
                                                                                                          Nov 16 at 9:54















                                                                                                        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
                                                                                                          Nov 15 at 22:20










                                                                                                        • 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
                                                                                                          Nov 16 at 9:35






                                                                                                        • 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
                                                                                                          Nov 16 at 9:53










                                                                                                        • @Arnauld Thank you! :)
                                                                                                          – Neyt
                                                                                                          Nov 16 at 9:54













                                                                                                        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 Nov 16 at 9:51

























                                                                                                        answered Nov 15 at 16:15









                                                                                                        Arnauld

                                                                                                        69.1k584292




                                                                                                        69.1k584292












                                                                                                        • You can get much shorter if you assume your input to be a 2d space padded char array.
                                                                                                          – kamoroso94
                                                                                                          Nov 15 at 22:20










                                                                                                        • 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
                                                                                                          Nov 16 at 9:35






                                                                                                        • 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
                                                                                                          Nov 16 at 9:53










                                                                                                        • @Arnauld Thank you! :)
                                                                                                          – Neyt
                                                                                                          Nov 16 at 9:54


















                                                                                                        • You can get much shorter if you assume your input to be a 2d space padded char array.
                                                                                                          – kamoroso94
                                                                                                          Nov 15 at 22:20










                                                                                                        • 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
                                                                                                          Nov 16 at 9:35






                                                                                                        • 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
                                                                                                          Nov 16 at 9:53










                                                                                                        • @Arnauld Thank you! :)
                                                                                                          – Neyt
                                                                                                          Nov 16 at 9:54
















                                                                                                        You can get much shorter if you assume your input to be a 2d space padded char array.
                                                                                                        – kamoroso94
                                                                                                        Nov 15 at 22:20




                                                                                                        You can get much shorter if you assume your input to be a 2d space padded char array.
                                                                                                        – kamoroso94
                                                                                                        Nov 15 at 22:20












                                                                                                        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
                                                                                                        Nov 16 at 9:35




                                                                                                        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
                                                                                                        Nov 16 at 9:35




                                                                                                        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
                                                                                                        Nov 16 at 9:53




                                                                                                        @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
                                                                                                        Nov 16 at 9:53












                                                                                                        @Arnauld Thank you! :)
                                                                                                        – Neyt
                                                                                                        Nov 16 at 9:54




                                                                                                        @Arnauld Thank you! :)
                                                                                                        – Neyt
                                                                                                        Nov 16 at 9:54










                                                                                                        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
                                                                                                          Nov 16 at 12:28















                                                                                                        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
                                                                                                          Nov 16 at 12:28













                                                                                                        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 Nov 15 at 19:06









                                                                                                        sergiol

                                                                                                        2,2421825




                                                                                                        2,2421825












                                                                                                        • Tcl, 159 bytes Failed outgolf
                                                                                                          – sergiol
                                                                                                          Nov 16 at 12:28


















                                                                                                        • Tcl, 159 bytes Failed outgolf
                                                                                                          – sergiol
                                                                                                          Nov 16 at 12:28
















                                                                                                        Tcl, 159 bytes Failed outgolf
                                                                                                        – sergiol
                                                                                                        Nov 16 at 12:28




                                                                                                        Tcl, 159 bytes Failed outgolf
                                                                                                        – sergiol
                                                                                                        Nov 16 at 12:28










                                                                                                        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 Nov 15 at 20:21









                                                                                                            Neil

                                                                                                            78k744175




                                                                                                            78k744175






















                                                                                                                up vote
                                                                                                                2
                                                                                                                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
                                                                                                                  2
                                                                                                                  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
                                                                                                                    2
                                                                                                                    down vote










                                                                                                                    up vote
                                                                                                                    2
                                                                                                                    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 Nov 16 at 11:14









                                                                                                                    Ismael Miguel

                                                                                                                    6,18811432




                                                                                                                    6,18811432






















                                                                                                                        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 Nov 15 at 18:03









                                                                                                                            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 Nov 15 at 18:38









                                                                                                                                    recursive

                                                                                                                                    4,9541221




                                                                                                                                    4,9541221






















                                                                                                                                        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 Nov 15 at 19:33









                                                                                                                                            Giuseppe

                                                                                                                                            16k31052




                                                                                                                                            16k31052






















                                                                                                                                                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 Nov 15 at 21:13









                                                                                                                                                    lirtosiast

                                                                                                                                                    15.4k436104




                                                                                                                                                    15.4k436104






















                                                                                                                                                        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 Nov 16 at 18:22









                                                                                                                                                            Oliver

                                                                                                                                                            4,4801828




                                                                                                                                                            4,4801828






















                                                                                                                                                                up vote
                                                                                                                                                                1
                                                                                                                                                                down vote













                                                                                                                                                                Ceylon, 55 / 99





                                                                                                                                                                With 0- or space-padded strings of same length (returning an iterable of characters):



                                                                                                                                                                function t(String a,String b)=>zipPairs(a,b).map(max);


                                                                                                                                                                With 0- or space-padded strings (returning a String):



                                                                                                                                                                String t(String a,String b)=>String(zipPairs(a,b).map(max));


                                                                                                                                                                With strings of possibly different length (returning a String):



                                                                                                                                                                String u(String a,String b)=>String(zipPairs(a.padLeading(b.size),b.padLeading(a.size)).map(max));





                                                                                                                                                                share|improve this answer

























                                                                                                                                                                  up vote
                                                                                                                                                                  1
                                                                                                                                                                  down vote













                                                                                                                                                                  Ceylon, 55 / 99





                                                                                                                                                                  With 0- or space-padded strings of same length (returning an iterable of characters):



                                                                                                                                                                  function t(String a,String b)=>zipPairs(a,b).map(max);


                                                                                                                                                                  With 0- or space-padded strings (returning a String):



                                                                                                                                                                  String t(String a,String b)=>String(zipPairs(a,b).map(max));


                                                                                                                                                                  With strings of possibly different length (returning a String):



                                                                                                                                                                  String u(String a,String b)=>String(zipPairs(a.padLeading(b.size),b.padLeading(a.size)).map(max));





                                                                                                                                                                  share|improve this answer























                                                                                                                                                                    up vote
                                                                                                                                                                    1
                                                                                                                                                                    down vote










                                                                                                                                                                    up vote
                                                                                                                                                                    1
                                                                                                                                                                    down vote









                                                                                                                                                                    Ceylon, 55 / 99





                                                                                                                                                                    With 0- or space-padded strings of same length (returning an iterable of characters):



                                                                                                                                                                    function t(String a,String b)=>zipPairs(a,b).map(max);


                                                                                                                                                                    With 0- or space-padded strings (returning a String):



                                                                                                                                                                    String t(String a,String b)=>String(zipPairs(a,b).map(max));


                                                                                                                                                                    With strings of possibly different length (returning a String):



                                                                                                                                                                    String u(String a,String b)=>String(zipPairs(a.padLeading(b.size),b.padLeading(a.size)).map(max));





                                                                                                                                                                    share|improve this answer












                                                                                                                                                                    Ceylon, 55 / 99





                                                                                                                                                                    With 0- or space-padded strings of same length (returning an iterable of characters):



                                                                                                                                                                    function t(String a,String b)=>zipPairs(a,b).map(max);


                                                                                                                                                                    With 0- or space-padded strings (returning a String):



                                                                                                                                                                    String t(String a,String b)=>String(zipPairs(a,b).map(max));


                                                                                                                                                                    With strings of possibly different length (returning a String):



                                                                                                                                                                    String u(String a,String b)=>String(zipPairs(a.padLeading(b.size),b.padLeading(a.size)).map(max));






                                                                                                                                                                    share|improve this answer












                                                                                                                                                                    share|improve this answer



                                                                                                                                                                    share|improve this answer










                                                                                                                                                                    answered 2 days ago









                                                                                                                                                                    Paŭlo Ebermann

                                                                                                                                                                    940714




                                                                                                                                                                    940714






















                                                                                                                                                                        up vote
                                                                                                                                                                        1
                                                                                                                                                                        down vote














                                                                                                                                                                        C# (.NET Core), 57 bytes



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


                                                                                                                                                                        -1 bytes by adding currying



                                                                                                                                                                        Try It Online






                                                                                                                                                                        share|improve this answer



























                                                                                                                                                                          up vote
                                                                                                                                                                          1
                                                                                                                                                                          down vote














                                                                                                                                                                          C# (.NET Core), 57 bytes



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


                                                                                                                                                                          -1 bytes by adding currying



                                                                                                                                                                          Try It Online






                                                                                                                                                                          share|improve this answer

























                                                                                                                                                                            up vote
                                                                                                                                                                            1
                                                                                                                                                                            down vote










                                                                                                                                                                            up vote
                                                                                                                                                                            1
                                                                                                                                                                            down vote










                                                                                                                                                                            C# (.NET Core), 57 bytes



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


                                                                                                                                                                            -1 bytes by adding currying



                                                                                                                                                                            Try It Online






                                                                                                                                                                            share|improve this answer















                                                                                                                                                                            C# (.NET Core), 57 bytes



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


                                                                                                                                                                            -1 bytes by adding currying



                                                                                                                                                                            Try It Online







                                                                                                                                                                            share|improve this answer














                                                                                                                                                                            share|improve this answer



                                                                                                                                                                            share|improve this answer








                                                                                                                                                                            edited 16 hours ago

























                                                                                                                                                                            answered Nov 16 at 13:30









                                                                                                                                                                            LiefdeWen

                                                                                                                                                                            2,502936




                                                                                                                                                                            2,502936






















                                                                                                                                                                                up vote
                                                                                                                                                                                1
                                                                                                                                                                                down vote














                                                                                                                                                                                Ruby, 25 bytes





                                                                                                                                                                                ->a,b{a.zip(b).map &:max}


                                                                                                                                                                                Try it online!



                                                                                                                                                                                Pre-padded list blah blah. (Although it feels a little like cheating.)






                                                                                                                                                                                share|improve this answer

























                                                                                                                                                                                  up vote
                                                                                                                                                                                  1
                                                                                                                                                                                  down vote














                                                                                                                                                                                  Ruby, 25 bytes





                                                                                                                                                                                  ->a,b{a.zip(b).map &:max}


                                                                                                                                                                                  Try it online!



                                                                                                                                                                                  Pre-padded list blah blah. (Although it feels a little like cheating.)






                                                                                                                                                                                  share|improve this answer























                                                                                                                                                                                    up vote
                                                                                                                                                                                    1
                                                                                                                                                                                    down vote










                                                                                                                                                                                    up vote
                                                                                                                                                                                    1
                                                                                                                                                                                    down vote










                                                                                                                                                                                    Ruby, 25 bytes





                                                                                                                                                                                    ->a,b{a.zip(b).map &:max}


                                                                                                                                                                                    Try it online!



                                                                                                                                                                                    Pre-padded list blah blah. (Although it feels a little like cheating.)






                                                                                                                                                                                    share|improve this answer













                                                                                                                                                                                    Ruby, 25 bytes





                                                                                                                                                                                    ->a,b{a.zip(b).map &:max}


                                                                                                                                                                                    Try it online!



                                                                                                                                                                                    Pre-padded list blah blah. (Although it feels a little like cheating.)







                                                                                                                                                                                    share|improve this answer












                                                                                                                                                                                    share|improve this answer



                                                                                                                                                                                    share|improve this answer










                                                                                                                                                                                    answered 16 hours ago









                                                                                                                                                                                    G B

                                                                                                                                                                                    7,4561328




                                                                                                                                                                                    7,4561328






















                                                                                                                                                                                        up vote
                                                                                                                                                                                        1
                                                                                                                                                                                        down vote














                                                                                                                                                                                        Retina 0.8.2, 39 bytes



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



                                                                                                                                                                                        Try it online! Link includes test suite. Previous 45-byte Retina 1 version accepts unpadded strings:



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



                                                                                                                                                                                        Try it online! Link includes test suite. Explanation:



                                                                                                                                                                                        P^`.+


                                                                                                                                                                                        Pad both values to the same length. (Retina 1 only. There are ways of emulating this in Retina 0.8.2 but they are not very golfy.)



                                                                                                                                                                                        +`^(.*)(.)¶(.*)(.)
                                                                                                                                                                                        $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 0.8.2, 39 bytes



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



                                                                                                                                                                                          Try it online! Link includes test suite. Previous 45-byte Retina 1 version accepts unpadded strings:



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



                                                                                                                                                                                          Try it online! Link includes test suite. Explanation:



                                                                                                                                                                                          P^`.+


                                                                                                                                                                                          Pad both values to the same length. (Retina 1 only. There are ways of emulating this in Retina 0.8.2 but they are not very golfy.)



                                                                                                                                                                                          +`^(.*)(.)¶(.*)(.)
                                                                                                                                                                                          $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 0.8.2, 39 bytes



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



                                                                                                                                                                                            Try it online! Link includes test suite. Previous 45-byte Retina 1 version accepts unpadded strings:



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



                                                                                                                                                                                            Try it online! Link includes test suite. Explanation:



                                                                                                                                                                                            P^`.+


                                                                                                                                                                                            Pad both values to the same length. (Retina 1 only. There are ways of emulating this in Retina 0.8.2 but they are not very golfy.)



                                                                                                                                                                                            +`^(.*)(.)¶(.*)(.)
                                                                                                                                                                                            $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 0.8.2, 39 bytes



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



                                                                                                                                                                                            Try it online! Link includes test suite. Previous 45-byte Retina 1 version accepts unpadded strings:



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



                                                                                                                                                                                            Try it online! Link includes test suite. Explanation:



                                                                                                                                                                                            P^`.+


                                                                                                                                                                                            Pad both values to the same length. (Retina 1 only. There are ways of emulating this in Retina 0.8.2 but they are not very golfy.)



                                                                                                                                                                                            +`^(.*)(.)¶(.*)(.)
                                                                                                                                                                                            $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








                                                                                                                                                                                            edited 15 hours ago

























                                                                                                                                                                                            answered Nov 15 at 19:53









                                                                                                                                                                                            Neil

                                                                                                                                                                                            78k744175




                                                                                                                                                                                            78k744175






















                                                                                                                                                                                                up vote
                                                                                                                                                                                                1
                                                                                                                                                                                                down vote














                                                                                                                                                                                                Charcoal, 8 bytes



                                                                                                                                                                                                ⭆θ⌈⟦ι§ηκ


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



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


                                                                                                                                                                                                10-byte version "adds" any number of padded strings:



                                                                                                                                                                                                ⭆§θ⁰⌈Eθ§λκ


                                                                                                                                                                                                Try it online! Link is to verbose version of code. Previous 14-byte version accepts unpadded strings:



                                                                                                                                                                                                ⭆◧θ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























                                                                                                                                                                                                • The question has been changed so the strings can be input as padded
                                                                                                                                                                                                  – ASCII-only
                                                                                                                                                                                                  18 hours ago










                                                                                                                                                                                                • Nitpicking, but you missed a close paren in the first verbose version :P
                                                                                                                                                                                                  – ASCII-only
                                                                                                                                                                                                  2 hours ago















                                                                                                                                                                                                up vote
                                                                                                                                                                                                1
                                                                                                                                                                                                down vote














                                                                                                                                                                                                Charcoal, 8 bytes



                                                                                                                                                                                                ⭆θ⌈⟦ι§ηκ


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



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


                                                                                                                                                                                                10-byte version "adds" any number of padded strings:



                                                                                                                                                                                                ⭆§θ⁰⌈Eθ§λκ


                                                                                                                                                                                                Try it online! Link is to verbose version of code. Previous 14-byte version accepts unpadded strings:



                                                                                                                                                                                                ⭆◧θ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























                                                                                                                                                                                                • The question has been changed so the strings can be input as padded
                                                                                                                                                                                                  – ASCII-only
                                                                                                                                                                                                  18 hours ago










                                                                                                                                                                                                • Nitpicking, but you missed a close paren in the first verbose version :P
                                                                                                                                                                                                  – ASCII-only
                                                                                                                                                                                                  2 hours ago













                                                                                                                                                                                                up vote
                                                                                                                                                                                                1
                                                                                                                                                                                                down vote










                                                                                                                                                                                                up vote
                                                                                                                                                                                                1
                                                                                                                                                                                                down vote










                                                                                                                                                                                                Charcoal, 8 bytes



                                                                                                                                                                                                ⭆θ⌈⟦ι§ηκ


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



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


                                                                                                                                                                                                10-byte version "adds" any number of padded strings:



                                                                                                                                                                                                ⭆§θ⁰⌈Eθ§λκ


                                                                                                                                                                                                Try it online! Link is to verbose version of code. Previous 14-byte version accepts unpadded strings:



                                                                                                                                                                                                ⭆◧θ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, 8 bytes



                                                                                                                                                                                                ⭆θ⌈⟦ι§ηκ


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



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


                                                                                                                                                                                                10-byte version "adds" any number of padded strings:



                                                                                                                                                                                                ⭆§θ⁰⌈Eθ§λκ


                                                                                                                                                                                                Try it online! Link is to verbose version of code. Previous 14-byte version accepts unpadded strings:



                                                                                                                                                                                                ⭆◧θ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








                                                                                                                                                                                                edited 15 hours ago

























                                                                                                                                                                                                answered Nov 15 at 20:06









                                                                                                                                                                                                Neil

                                                                                                                                                                                                78k744175




                                                                                                                                                                                                78k744175












                                                                                                                                                                                                • The question has been changed so the strings can be input as padded
                                                                                                                                                                                                  – ASCII-only
                                                                                                                                                                                                  18 hours ago










                                                                                                                                                                                                • Nitpicking, but you missed a close paren in the first verbose version :P
                                                                                                                                                                                                  – ASCII-only
                                                                                                                                                                                                  2 hours ago


















                                                                                                                                                                                                • The question has been changed so the strings can be input as padded
                                                                                                                                                                                                  – ASCII-only
                                                                                                                                                                                                  18 hours ago










                                                                                                                                                                                                • Nitpicking, but you missed a close paren in the first verbose version :P
                                                                                                                                                                                                  – ASCII-only
                                                                                                                                                                                                  2 hours ago
















                                                                                                                                                                                                The question has been changed so the strings can be input as padded
                                                                                                                                                                                                – ASCII-only
                                                                                                                                                                                                18 hours ago




                                                                                                                                                                                                The question has been changed so the strings can be input as padded
                                                                                                                                                                                                – ASCII-only
                                                                                                                                                                                                18 hours ago












                                                                                                                                                                                                Nitpicking, but you missed a close paren in the first verbose version :P
                                                                                                                                                                                                – ASCII-only
                                                                                                                                                                                                2 hours ago




                                                                                                                                                                                                Nitpicking, but you missed a close paren in the first verbose version :P
                                                                                                                                                                                                – ASCII-only
                                                                                                                                                                                                2 hours ago










                                                                                                                                                                                                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
                                                                                                                                                                                                  Nov 15 at 23:22






                                                                                                                                                                                                • 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
                                                                                                                                                                                                  Nov 16 at 2:09















                                                                                                                                                                                                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
                                                                                                                                                                                                  Nov 15 at 23:22






                                                                                                                                                                                                • 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
                                                                                                                                                                                                  Nov 16 at 2:09













                                                                                                                                                                                                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 Nov 15 at 22:54









                                                                                                                                                                                                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
                                                                                                                                                                                                  Nov 15 at 23:22






                                                                                                                                                                                                • 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
                                                                                                                                                                                                  Nov 16 at 2:09














                                                                                                                                                                                                • 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
                                                                                                                                                                                                  Nov 15 at 23:22






                                                                                                                                                                                                • 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
                                                                                                                                                                                                  Nov 16 at 2:09








                                                                                                                                                                                                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
                                                                                                                                                                                                Nov 15 at 23:22




                                                                                                                                                                                                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
                                                                                                                                                                                                Nov 15 at 23:22




                                                                                                                                                                                                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
                                                                                                                                                                                                Nov 16 at 2:09




                                                                                                                                                                                                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
                                                                                                                                                                                                Nov 16 at 2:09


















                                                                                                                                                                                                 

                                                                                                                                                                                                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

                                                                                                                                                                                                AnyDesk - Fatal Program Failure

                                                                                                                                                                                                How to calibrate 16:9 built-in touch-screen to a 4:3 resolution?

                                                                                                                                                                                                QoS: MAC-Priority for clients behind a repeater