Learning to Think Algorithmically