Code for Lecture 6.