Skip to main content
added 67 characters in body
Source Link

Javascript (using External Library) (66 bytes)

n=>_.From(n).Select((v,i)=>_.From(n).Slice(i,i+v).Sum()).ToArray()

Link to lib: https://github.com/mvegh1/Enumerable

Code explanation: _.From is loading the input array into the library, which is basically LINQ for js. Then each item in the array is mapped according to the following predicate: Take the input, and slice it from current item index and take that index plus the current item's value. Then Sum up that subsequence. Convert the result to a native JS array and return it

Edit: image coming...enter image description here

Javascript (using External Library) (66 bytes)

n=>_.From(n).Select((v,i)=>_.From(n).Slice(i,i+v).Sum()).ToArray()

Link to lib: https://github.com/mvegh1/Enumerable

Code explanation: _.From is loading the input array into the library, which is basically LINQ for js. Then each item in the array is mapped according to the following predicate: Take the input, and slice it from current item index and take that index plus the current item's value. Then Sum up that subsequence. Convert the result to a native JS array and return it

Edit: image coming...

Javascript (using External Library) (66 bytes)

n=>_.From(n).Select((v,i)=>_.From(n).Slice(i,i+v).Sum()).ToArray()

Link to lib: https://github.com/mvegh1/Enumerable

Code explanation: _.From is loading the input array into the library, which is basically LINQ for js. Then each item in the array is mapped according to the following predicate: Take the input, and slice it from current item index and take that index plus the current item's value. Then Sum up that subsequence. Convert the result to a native JS array and return it

enter image description here

deleted 26 characters in body
Source Link

Javascript (using External Library) (8266 bytes)

n=>{r=[];x=_n=>_.From(n);x.ForEachSelect((i,v,i)=>{r.push(x=>_.SkipFrom(in).TakeSlice(vi,i+v).Sum())}.ToArray();return r}

Link to lib: https://github.com/mvegh1/Enumerable

Code explanation: _.From is loading the input array into the library, which is basically LINQ for js. Then each item in the array is iterated for each element, where we look atmapped according to the following predicate: Take the input array, and skip to theslice it from current item index, and take only as many elements asthat index plus the current element says, then we sum that sub-collection upitem's value. We pushThen Sum up that intosubsequence. Convert the returnresult to a native JS array, r, and when complete we return rit

enter image description here Edit: image coming...

Javascript (using External Library) (82 bytes)

n=>{r=[];x=_.From(n);x.ForEach((i,v)=>{r.push(x.Skip(i).Take(v).Sum())});return r}

Link to lib: https://github.com/mvegh1/Enumerable

Code explanation: _.From is loading the input array into the library, which is basically LINQ for js. Then the array is iterated for each element, where we look at the input array and skip to the current index, and take only as many elements as the current element says, then we sum that sub-collection up. We push that into the return array, r, and when complete we return r

enter image description here

Javascript (using External Library) (66 bytes)

n=>_.From(n).Select((v,i)=>_.From(n).Slice(i,i+v).Sum()).ToArray()

Link to lib: https://github.com/mvegh1/Enumerable

Code explanation: _.From is loading the input array into the library, which is basically LINQ for js. Then each item in the array is mapped according to the following predicate: Take the input, and slice it from current item index and take that index plus the current item's value. Then Sum up that subsequence. Convert the result to a native JS array and return it

Edit: image coming...

deleted 8 characters in body
Source Link

Javascript (using External Library) (9082 bytes)

n=>{var r=[];var x=_r=[];x=_.From(n);x.ForEach((i,v)=>{r.push(x.Skip(i).Take(v).Sum())});return r}

Link to lib: https://github.com/mvegh1/Enumerable

Code explanation: _.From is loading the input array into the library, which is basically LINQ for js. Then the array is iterated for each element, where we look at the input array and skip to the current index, and take only as many elements as the current element says, then we sum that sub-collection up. We push that into the return array, r, and when complete we return r

enter image description here

Javascript (using External Library) (90 bytes)

n=>{var r=[];var x=_.From(n);x.ForEach((i,v)=>{r.push(x.Skip(i).Take(v).Sum())});return r}

Link to lib: https://github.com/mvegh1/Enumerable

Code explanation: _.From is loading the input array into the library, which is basically LINQ for js. Then the array is iterated for each element, where we look at the input array and skip to the current index, and take only as many elements as the current element says, then we sum that sub-collection up. We push that into the return array, r, and when complete we return r

enter image description here

Javascript (using External Library) (82 bytes)

n=>{r=[];x=_.From(n);x.ForEach((i,v)=>{r.push(x.Skip(i).Take(v).Sum())});return r}

Link to lib: https://github.com/mvegh1/Enumerable

Code explanation: _.From is loading the input array into the library, which is basically LINQ for js. Then the array is iterated for each element, where we look at the input array and skip to the current index, and take only as many elements as the current element says, then we sum that sub-collection up. We push that into the return array, r, and when complete we return r

enter image description here

Source Link
Loading