|
I thought it wouldn't be this hard after I worked it out in Java first,
but once again it was fun and I learned a lot:
1. in all my previous exercises, my Python code performed better than my
Java code. This is the first time that my Java code significantly
outperforms my Python code: 0.92 seconds versus 7.93 seconds! My Java
code did use more than twice the memory.
2. Good re-enforcement of Python list copying concept, versus aliasing.
Don't forget the [:] (or [l:r]) magic!
3. list of (num, num) sort by first num by default, with proper tie
breaking. To sort on the second num, do list.sort(key=lambda x: x[1].
Cleve use of lambda, and it also does proper tie breaking.
4. I forgot to put this into my Java program comments, that Java code
gave me a good practice of comparator versus comparable interfaces,
which was very nice.
Fun stuff! Curious how much faster C++ program will be. I'll find out!
|