Calculating BPM with inputs

MATLAB/Octave, 58 56 55 bytes

Thanks @LuisMendo for -1 byte!

input('');tic;for k=1:7;input('');end;fix(48e3/toc)/100

You have to press enter 9 times. (Also works in Octave.)

Here you see it in action, left MATLAB, right Octave:


JavaScript (ES6), 77 74 bytes

(i=8,n=Date.now,t)=>onclick=_=>(t=t||n(),i--||alert((48e6/(n()-t)|0)/100))

Creates an onclick event on the global window object. Send beats by clicking anywhere in the window.

Test Snippet

let f=
(i=8,n=Date.now,t)=>onclick=_=>(t=t||n(),i--||alert((48e6/(n()-t)|0)/100))

f()
document.write("Running... click anywhere here")
*{user-select:none}


Python 3, 93 92 81 bytes

Saved 11 bytes thanks to Felipe.

import time
a,*l,b=[input()or time.time()for i in' '*9]
print(round(480/(b-a),2))

Tags:

Code Golf