Skip to main content
deleted 10 characters in body
Source Link
Kevin Cruijssen
  • 131.4k
  • 13
  • 144
  • 384

05AB1E, 16 15 14 bytes

0ÐIv(2Fy+Š])Äà

Port of @tsh' top Python answer.
-1 byte thanks to @Neil, which also allowed a second byte to be saved

Try it online or verify all test cases.

Explanation:

0Ð            # Push three 0s, let's call these a,b,c
  I           # Push the input-list
   v          # Pop and loop over each item `y`:
    (         #  Negate the top item
     2F       #  Loop 2 times:
       y+     #   Add the current integer `y` to the top
         Š    #   Tripleswap x,y,z to z,x,y
              #  (after this inner loop, a,b,c is y+b,y-c,a)
   ]          # Close both loops
    )         # Wrap all three values into a list
     Ä        # Get the absolute values of each
      à       # Pop and push the maximum

05AB1E, 16 15 14 bytes

0ÐIv(2Fy+Š])Äà

Port of @tsh' top Python answer.
-1 byte thanks to @Neil, which also allowed a second byte to be saved

Try it online or verify all test cases.

Explanation:

0Ð            # Push three 0s, let's call these a,b,c
  I           # Push the input-list
   v          # Pop and loop over each item `y`:
    (         #  Negate the top item
     2F       #  Loop 2 times:
       y+     #   Add the current integer `y` to the top
         Š    #   Tripleswap x,y,z to z,x,y
              #  (after this inner loop, a,b,c is y+b,y-c,a)
   ]          # Close both loops
    )         # Wrap all three values into a list
     Ä        # Get the absolute values of each
      à       # Pop and push the maximum

05AB1E, 16 14 bytes

0ÐIv(2Fy+Š])Äà

Port of @tsh' top Python answer.
-1 byte thanks to @Neil, which also allowed a second byte to be saved

Try it online or verify all test cases.

Explanation:

0Ð            # Push three 0s, let's call these a,b,c
  I           # Push the input-list
   v          # Pop and loop over each item `y`:
    (         #  Negate the top item
     2F       #  Loop 2 times:
       y+     #   Add the current integer `y` to the top
         Š    #   Tripleswap x,y,z to z,x,y
              #  (after this inner loop, a,b,c is y+b,y-c,a)
   ]          # Close both loops
    )         # Wrap all three values into a list
     Ä        # Get the absolute values of each
      à       # Pop and push the maximum
deleted 62 characters in body
Source Link
Kevin Cruijssen
  • 131.4k
  • 13
  • 144
  • 384

05AB1E, 1616 15 14 bytes

0ÐIv(‚ys+`ŠŠ}2Fy+Š])Äà

Port of @tsh' top Python answer.
-1 byte thanks to @Neil, which also allowed a second byte to be saved

Try it onlineTry it online or verify all test casesverify all test cases.

Explanation:

0Ð            # Push three 0s, let's call these a,b,c
  I           # Push the input-list
   v          # Pop and loop over each item `y`:
    (         #  Negate the top item: -c
     2F       #  Pair the top two items inLoop a2 listtimes: [b,-c]
      y  y+     #  Push Add the current integer `y`
       s      #  Swap so the pair is atto the top again
        + Š    #  Add both values in theTripleswap pairx,y,z to this `y`: [y+bz,x,y-c]
         `    #  Pop and push both# separated to(after thethis stackinner again:loop, a,b,c is y+b,y-c,a)
   ]       ŠŠ  # # TripleswapClose twice:both y+b,y-c,aloops
   } )         # After the loop: wrapWrap all three values into a list
     Ä        # Get the absolute values of each
      à       # Pop and push the maximum

05AB1E, 16 bytes

0ÐIv(‚ys+`ŠŠ})Äà

Port of @tsh' top Python answer.

Try it online or verify all test cases.

Explanation:

0Ð            # Push three 0s, let's call these a,b,c
  I           # Push the input-list
   v          # Pop and loop over each item `y`:
    (         #  Negate the top item: -c
            #  Pair the top two items in a list: [b,-c]
      y       #  Push the current integer `y`
       s      #  Swap so the pair is at the top again
        +     #  Add both values in the pair to this `y`: [y+b,y-c]
         `    #  Pop and push both separated to the stack again: a,y+b,y-c
          ŠŠ  #  Tripleswap twice: y+b,y-c,a
   })         # After the loop: wrap all three values into a list
     Ä        # Get the absolute values of each
      à       # Pop and push the maximum

05AB1E, 16 15 14 bytes

0ÐIv(2Fy+Š])Äà

Port of @tsh' top Python answer.
-1 byte thanks to @Neil, which also allowed a second byte to be saved

Try it online or verify all test cases.

Explanation:

0Ð            # Push three 0s, let's call these a,b,c
  I           # Push the input-list
   v          # Pop and loop over each item `y`:
    (         #  Negate the top item
     2F       #  Loop 2 times:
       y+     #   Add the current integer `y` to the top
         Š    #   Tripleswap x,y,z to z,x,y
              #  (after this inner loop, a,b,c is y+b,y-c,a)
   ]          # Close both loops
    )         # Wrap all three values into a list
     Ä        # Get the absolute values of each
      à       # Pop and push the maximum
typo..
Source Link
Kevin Cruijssen
  • 131.4k
  • 13
  • 144
  • 384

05AB1E, 16 bytes

0ÐIv(‚ys+`ŠŠ})Äà

Port of @tsh' top Python answer.

Try it online or verify all test cases.

Explanation:

0Ð            # Push three 0s, let's call these a,b,c
  I           # Push the input-list
   v          # Pop and loop over each item `y`:
    (         #  Negate the top item: -c
     ‚        #  Pair the top two items in a list: [b,-c]
      y       #  Push the current integer `y`
       s      #  Swap so the pair is at the top again
        +     #  Add both values in the pair to this `y`: [y+b,y-c]
         `    #  Pop and push both separated to the stack again: a,y+b,y-c
          ŠŠ  #  Tripleswap twice: y+b,y-c,a
   })         # After the loop: wrap all values three values into a list
     Ä        # Get the absolute values of each
      à       # Pop and push the maximum

05AB1E, 16 bytes

0ÐIv(‚ys+`ŠŠ})Äà

Port of @tsh' top Python answer.

Try it online or verify all test cases.

Explanation:

0Ð            # Push three 0s, let's call these a,b,c
  I           # Push the input-list
   v          # Pop and loop over each item `y`:
    (         #  Negate the top item: -c
     ‚        #  Pair the top two items in a list: [b,-c]
      y       #  Push the current integer `y`
       s      #  Swap so the pair is at the top again
        +     #  Add both values in the pair to this `y`: [y+b,y-c]
         `    #  Pop and push both separated to the stack again: a,y+b,y-c
          ŠŠ  #  Tripleswap twice: y+b,y-c,a
   })         # After the loop: wrap all values three into a list
     Ä        # Get the absolute values of each
      à       # Pop and push the maximum

05AB1E, 16 bytes

0ÐIv(‚ys+`ŠŠ})Äà

Port of @tsh' top Python answer.

Try it online or verify all test cases.

Explanation:

0Ð            # Push three 0s, let's call these a,b,c
  I           # Push the input-list
   v          # Pop and loop over each item `y`:
    (         #  Negate the top item: -c
     ‚        #  Pair the top two items in a list: [b,-c]
      y       #  Push the current integer `y`
       s      #  Swap so the pair is at the top again
        +     #  Add both values in the pair to this `y`: [y+b,y-c]
         `    #  Pop and push both separated to the stack again: a,y+b,y-c
          ŠŠ  #  Tripleswap twice: y+b,y-c,a
   })         # After the loop: wrap all three values into a list
     Ä        # Get the absolute values of each
      à       # Pop and push the maximum
Source Link
Kevin Cruijssen
  • 131.4k
  • 13
  • 144
  • 384
Loading