Code for CS 171 class