Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

added 66 characters in body
Source Link
Dennis
  • 211.7k
  • 41
  • 380
  • 830

Jelly, 5 bytes

0;+μ/

Try it online!

How it works

0;+μ/ Main link. Argument: M (matrix / array of rows)
 μ Combine all links to the left into a chain (arity unknown at parse time) and
 begin a new monadic chain.
 / Reduce M by that chain. This makes the chain dyadic.
 Let's call the arguments of the chain L and R (both flat arrays).
0; Prepend a 0 to L.
 + Perform element-wise addition of the result and R.
 Since When the chain is called for the n-th time, R has onen less elementelements, so
  the last elementn elements of L won't have a matching elements in R and will be
 element in R and will be left unaltered.

Jelly, 5 bytes

0;+μ/

Try it online!

How it works

0;+μ/ Main link. Argument: M (matrix / array of rows)
 μ Combine all links to the left into a chain (arity unknown at parse time) and
 begin a new monadic chain.
 / Reduce M by that chain. This makes the chain dyadic.
 Let's call the arguments of the chain L and R (both flat arrays).
0; Prepend a 0 to L.
 + Perform element-wise addition of the result and R.
 Since R has one less element, the last element of L won't have a matching element in R and will be left unaltered.

Jelly, 5 bytes

0;+μ/

Try it online!

How it works

0;+μ/ Main link. Argument: M (matrix / array of rows)
 μ Combine all links to the left into a chain (arity unknown at parse time) and
 begin a new monadic chain.
 / Reduce M by that chain. This makes the chain dyadic.
 Let's call the arguments of the chain L and R (both flat arrays).
0; Prepend a 0 to L.
 + Perform element-wise addition of the result and R.
 When the chain is called for the n-th time, R has n less elements, so
  the last n elements of L won't have matching elements in R and will be
 left unaltered.
added 77 characters in body
Source Link
Dennis
  • 211.7k
  • 41
  • 380
  • 830

Jelly, 5 bytes

0;+μ/

Try it online!

How it works

0;+μ/ Main link. Argument: M (matrix / array of rows)
 μ Combine all links to the left into a chain (arity unknown at parse time) and
 begin a new monadic chain.
 / Reduce M by that chain. This makes the chain dyadic.
 Let's call the arguments of the chain L and R (both flat arrays).
0; Prepend a 0 to L.
 + Perform element-wise addition of the result and R.
 Since R has one less element, the last element of L won't have a matching
 element in R and will be left unaltered.

Jelly, 5 bytes

0;+μ/

Try it online!

Jelly, 5 bytes

0;+μ/

Try it online!

How it works

0;+μ/ Main link. Argument: M (matrix / array of rows)
 μ Combine all links to the left into a chain (arity unknown at parse time) and
 begin a new monadic chain.
 / Reduce M by that chain. This makes the chain dyadic.
 Let's call the arguments of the chain L and R (both flat arrays).
0; Prepend a 0 to L.
 + Perform element-wise addition of the result and R.
 Since R has one less element, the last element of L won't have a matching
 element in R and will be left unaltered.
added 77 characters in body
Source Link
Dennis
  • 211.7k
  • 41
  • 380
  • 830

Jelly, 5 bytes

0;+μ/

Try it online!

Jelly, 5 bytes

0;+μ/

Try it online!

Source Link
Dennis
  • 211.7k
  • 41
  • 380
  • 830
Loading

AltStyle によって変換されたページ (->オリジナル) /