Using Hubble's Law
Recap: Your astronomy professor has tasked the class with determining the velocity of Andromeda with respect to the Milky Way. You thought of three possible ways to do this, one of which will give you the right answer. You've decided to try using Hubble's Law to find the velocity from M31's distance.
You learned in astronomy class that Hubble's Law is a relationship between the radial velocities of distant galaxies and their distance from us. The relationship can be stated:
where v is the recessional velocity of the galaxy, d is its distance away, and H0 is Hubble's constant. So, for distant galaxies, if you know the distance and the value of H0, you should be able to solve for the velocity.