summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2018-12-28Max expression value by placing paren done!HEADmasterHaidong Ji
2018-12-27Kanpsack partition3 done!Haidong Ji
Not sure how scientific this comparison is, but I've got Max time used: 0.03/10.00, max memory used: 10264576/536870912.), and bytwigorlimerick got Max time used: 0.04/10.00, max memory used: 10260480/536870912.). https://courses.edx.org/courses/course-v1:UCSanDiegoX+ALGS200x+2T2017/discussion/forum/course/threads/5a4290cc44a15008b5000768 Looks like we are using different approaches. Funny that my approach is a bit faster than
2018-12-26Knapsack maximize gold done!Haidong Ji
2018-12-25Longest subsequence done! (3 seqs)Haidong Ji
The only tricky part was to create and populate the 3-d list. The instructions here was helpful: https://www.ict.social/python/basics/multidimensional-lists-in-python
2018-12-25Longest subsequence of 2 seqs done!Haidong Ji
Not too bad, since I worked it out in Java already.
2018-12-22Edit distance done!Haidong Ji
It turned out my Java test cases didn't cover enough number of cases. I added one test case for it to fail, and figured out that the range in 2 loops should start with 1.
2018-12-19Primitive calculator done!Haidong Ji
This isn't too bad after I worked out the algo in Java first.
2018-12-17Coin change Dynamic Programming done!Haidong Ji
2018-12-16Closest pair done!Haidong Ji
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!
2018-12-09Organize lottery done.Haidong Ji
It wasn't hard since I worked this out in Java first. Once again, I felt Python is really well designed and efficient.
2018-11-28Inversion count done!Haidong Ji
It was easy, since I did the hard work of working it out in Java first.
2018-11-23Improved QuickSort done!Haidong Ji
Easy after the Java version is finished.
2018-10-31Majority element done!Haidong Ji
Easy, after Java version. Note that don't use ++i or i++, use i = i + 1 instead.
2018-10-10Binary Search iterative approach done!Haidong Ji
Seems that recursive approach is better.
2018-10-08Binary search done!Haidong Ji
2018-10-03Maximize salary done!Haidong Ji
2018-09-28Maximize num of prize places done!Haidong Ji
Got the Java version work first. Then it's easy.
2018-09-19Covering segment complete.Haidong Ji
This is quite tricky. I read the forum and it helped https://courses.edx.org/courses/course-v1:UCSanDiegoX+ALGS200x+2T2017/discussion/forum/course/threads/5a427c497acf2d0810000713 In particular try_my_best's algorithm worked. But I need to de-dup and sort the list before feeding it to that algorithm, otherwise it won't pass all the tests!
2018-09-14Rebuilding Lenovo.Haidong Ji
Checking in the code.
2018-09-07max dot product doneHaidong Ji
aka maximize online ad revenue.
2018-09-07Fractional Knapsack doneHaidong Ji
2018-09-02Changing money algo done.Haidong Ji
2018-08-29Last digit of partial fib sums doneHaidong Ji
It was pretty easy, just reimplemting the algorithm I've finished with Java.
2018-08-28Last digit of Fib sum is done.Haidong Ji
2018-08-26More improvement: not calculating fib at all!Haidong Ji
Doing the first few in a spreadsheet (and properly label columns and rows) really helped.
2018-08-24Improved code by getting rid of array during fib calculationHaidong Ji
2018-08-23Done!Haidong Ji
I actually started implementing this in Java first, but ran into long int overflow issues. Decided to get it working in Python first. I'm glad it worked! Now back to implement it in Java!
2018-08-19Great LCM exercise. Done!Haidong Ji
2 things are really interesting: 1. How to find the right test cases. I think I'll probably need to go back and re-read how to do an exhautisive testing 2. Python 3's floor division versus true division (// and /) operators are interesting. This exercise discussion helped me: https://courses.edx.org/courses/course-v1:UCSanDiegoX+ALGS200x+2T2017/discussion/forum/course/threads/5a3d32d644a15008df00062e and this one: https://stackoverflow.com/questions/19507808/python3-integer-division and this one: https://www.python.org/dev/peps/pep-0238/
2018-08-19GCD done!Haidong Ji
2018-08-16Fib last digit done. Yay!Haidong Ji
Bonus: figured PyDev TDD code generation issue. I created "sources" as a source folder, but really should have created as a package, for TDD code generation to work properly. Fixed now!
2018-08-13Week2 Python Fibonacci done!Haidong Ji
2018-08-07Python 3 implementation of max pairwise product!Haidong Ji
2018-07-28Added .gitignoreHaidong Ji
2018-07-28Initial commit.Haidong Ji