I woke up early this morning, and decided that I should get moving on the Python Next Level course. I’ve gone through the first couple of sections, but it’s time to really dig in. I finally finished up the first exercise, the Russian Peasant’s Algorithm. If you need to know more about what it is, go
. In a nutshell, it’s one of the first methods used to multiply to large numbers together.
The things I learned in this section of the course were:
Binary shifting - I know binary from my subnetting days, but I had no idea that you could shift binary numbers left and right to do mathmatical computations.
The assert keyword - Basically, this makes sure that the methods you develop return the values you expect
Using time and cache to speed up your algorithms
Here’s the code:
I commented out that last assertion b/c I kept getting an AssertionError, and I’m not sure why. It’s probably something simple. I’ll look into it, but if you have a clue, help me out.