Which bit are you stuck on - the electronic theory that you have to implement in code, or the code itself?

Supposing you were to do this manually (let's say there are 10 samples rather than 100000). How would you go about it?