Skip to main content
saved 2 bytes
Source Link
Arnauld
  • 197.7k
  • 20
  • 179
  • 650

JavaScript (ES6), 6462 bytes

Expects (stopFloor, myFloor, array).

(p,q,a)=>[...a,q].sort((a,b)=>((a<p)-(b<p))*(q-p)+1/+(a-p)/(a-b))

Try it online!Try it online!

JavaScript (ES6), 64 bytes

Expects (stopFloor, myFloor, array).

(p,q,a)=>[...a,q].sort((a,b)=>((a<p)-(b<p))*(q-p)+1/(a-p)/(a-b))

Try it online!

JavaScript (ES6), 62 bytes

Expects (stopFloor, myFloor, array).

(p,q,a)=>[...a,q].sort((a,b)=>((a<p)-(b<p))*(q-p)+(a-p)/(a-b))

Try it online!

Post Undeleted by Arnauld
added another test case
Source Link
Arnauld
  • 197.7k
  • 20
  • 179
  • 650

JavaScript (ES6), 64 bytes

Expects (stopFloor, myFloor, array).

(p,q,a)=>[...a,q].sort((a,b)=>((a<p)-(b<p))*(q-p)+1/(a-p)/(a-b))

Try it online!Try it online!

JavaScript (ES6), 64 bytes

Expects (stopFloor, myFloor, array).

(p,q,a)=>[...a,q].sort((a,b)=>((a<p)-(b<p))*(q-p)+1/(a-p)/(a-b))

Try it online!

JavaScript (ES6), 64 bytes

Expects (stopFloor, myFloor, array).

(p,q,a)=>[...a,q].sort((a,b)=>((a<p)-(b<p))*(q-p)+1/(a-p)/(a-b))

Try it online!

Post Deleted by Arnauld
Source Link
Arnauld
  • 197.7k
  • 20
  • 179
  • 650

JavaScript (ES6), 64 bytes

Expects (stopFloor, myFloor, array).

(p,q,a)=>[...a,q].sort((a,b)=>((a<p)-(b<p))*(q-p)+1/(a-p)/(a-b))

Try it online!