Skip to main content
Commonmark migration
Source Link

#Javascript, 99 95 93 bytes

Javascript, 99 95 93 bytes

4 6 bytes off thanks @Neil.

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

f= a=>a.reduce( (x,y)=> x.concat( b.map?b=y :[...Array(y<b?b-y:y-b||1)] .map(_=>b+=y<b?-1:y>b) ) ,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>

#Javascript, 99 95 93 bytes

4 6 bytes off thanks @Neil.

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

f= a=>a.reduce( (x,y)=> x.concat( b.map?b=y :[...Array(y<b?b-y:y-b||1)] .map(_=>b+=y<b?-1:y>b) ) ,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>

Javascript, 99 95 93 bytes

4 6 bytes off thanks @Neil.

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

f= a=>a.reduce( (x,y)=> x.concat( b.map?b=y :[...Array(y<b?b-y:y-b||1)] .map(_=>b+=y<b?-1:y>b) ) ,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>

replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/
Source Link

#Javascript, 99 95 93 bytes

4 6 bytes off thanks @Neil@Neil.

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

f= a=>a.reduce( (x,y)=> x.concat( b.map?b=y :[...Array(y<b?b-y:y-b||1)] .map(_=>b+=y<b?-1:y>b) ) ,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>

#Javascript, 99 95 93 bytes

4 6 bytes off thanks @Neil.

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

f= a=>a.reduce( (x,y)=> x.concat( b.map?b=y :[...Array(y<b?b-y:y-b||1)] .map(_=>b+=y<b?-1:y>b) ) ,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>

#Javascript, 99 95 93 bytes

4 6 bytes off thanks @Neil.

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

f= a=>a.reduce( (x,y)=> x.concat( b.map?b=y :[...Array(y<b?b-y:y-b||1)] .map(_=>b+=y<b?-1:y>b) ) ,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>

2 more bytes off thanks @Neil.
Source Link
removed
  • 2.8k
  • 15
  • 31

#Javascript, 99 9595 93 bytes

44 6 bytes off thanks @Neil.

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

f= a=>a.reduce( (x,y)=> x.concat( b.map?b=y :[...Array(y<b?b-y:y-b||1)] .map(_=>b+=y>b||y-b&&_=>b+=y<b?-1:y>b) ) ,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>

#Javascript, 99 95 bytes

4 bytes off thanks @Neil.

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

f= a=>a.reduce( (x,y)=> x.concat( b.map?b=y :[...Array(y<b?b-y:y-b||1)] .map(_=>b+=y>b||y-b&&-1) ) ,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>

#Javascript, 99 95 93 bytes

4 6 bytes off thanks @Neil.

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

f= a=>a.reduce( (x,y)=> x.concat( b.map?b=y :[...Array(y<b?b-y:y-b||1)] .map(_=>b+=y<b?-1:y>b) ) ,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>

4 bytes off thanks @Neil.
Source Link
removed
  • 2.8k
  • 15
  • 31
Loading
Snippet
Source Link
removed
  • 2.8k
  • 15
  • 31
Loading
Source Link
removed
  • 2.8k
  • 15
  • 31
Loading