Rough first attempt

Success on the very small inputs; will test on the larger inputs
tomorrow.