Skip to main content
5 of 7
added 26 characters in body
Mr. Xcoder
  • 42.5k
  • 9
  • 81
  • 214

#Pyth, 10 bytes

sMCc.[EZQQ

Try it here!

#Explanation

sMCc.[EZQQ   Full program.

    .[E      Pad the second input to the right, with repeated copies of...
       Z     ... Zero (0), up to the nearest multiple of...
        Q    ... The first input.
   c     Q   Chop into chunks of length equal to the first input.
  C          Matrix transpose. Get all the columns of the nested list.
sM           Sum each.
             Output (implicitly). 

#Pyth, 8 bytes

m+F%Q>vz

Try it here!

A bit out-dated explanation

ms|%Q>vzdZ   Full program. Q means input.

m            Map over the implicit range [0, input_1), with a variable d.
     >vzd    All the elements of input_2 after d; input_2[d:] in Python.
   %Q        Every Qth element of ^.
  |      Z   Logical OR with 0 (to handle an empty array after trimming).
 s           Sum. Implicitly output the result.
Mr. Xcoder
  • 42.5k
  • 9
  • 81
  • 214