How to Learn an Algorithm