Japt -Rx
, 20 18 bytes
#Japt -Rx
, 20 18 bytes
TheThe second line includes a trailing tab.
Nc¡=ä+
Ëq' ² iEç'
##Explanation :Implicit input of array U N :The array of inputs (NOT the input array) c :Concatenate ¡ : Map U ä+ : Consecutive sums of U = : Reassign to U for next iteration \n :Reassign the resulting 2D-array to U Ë :Map each array at index E q : Join with '\t : Tab ² : Repeated twice i : Prepend '\t : Tab ç : Repeated E : E times :Implicitly join with newlines, trim (not strictly necessary) and output.
Explanation
:Implicit input of array U
N :The array of inputs (NOT the input array)
c :Concatenate
¡ : Map U
ä+ : Consecutive sums of U
= : Reassign to U for next iteration
\n :Reassign the resulting 2D-array to U
Ë :Map each array at index E
q : Join with
'\t : Tab
² : Repeated twice
i : Prepend
'\t : Tab
ç : Repeated
E : E times
:Implicitly join with newlines, trim (not strictly necessary) and output.