Code written in Mathematica