Skip to main content
2 of 6
Snippet
removed
  • 2.8k
  • 15
  • 31

#Javascript, 99 bytes

a=>a.reduce((x,y)=>x.concat(b.map?b=y:[...Array((c=y-b)<0?-c:c||1)].map(_=>b+=y-b?y>b||-1:0)),b=[]) 

f= a=>a.reduce( (x,y)=> x.concat( b.map?b=y :[...Array((c=y-b)<0?-c:c||1)] .map(_=>b+=y-b?y>b||-1:0) ) ,b=[]) G.addEventListener('click',_=>O.innerHTML=f(JSON.parse(I.value)));
<input id=I value="[3,5,5,3]"><button id=G>Go</button><pre id=O>

removed
  • 2.8k
  • 15
  • 31