Code for problem 2 of Computation Astrophysics