Age | Commit message (Collapse) | Author |
|
Easy implementation of the algorithm described in course slide. It
helped that I named variables according to the pseudo code. Getting
array indexing right is always a bit tricky so pay attention.
|
|
Yay, so much fun. Breaking things down into small, actionable items, and
doing it, this never fails! Persist! Glad that my org-mode Emacs TODO
helps making it happen.
|
|
Pretty challenging and fun exercise. Once again, persistence is the key.
Don't give up, and it is a lot of fun.
|
|
Pretty challenging but a lot of fun and very satisfying. Decided to
implement MergeSort first without worrying about inversion count, then
went from there. Lesson learned: use the debugger! :) Also passing by
reference in Java can be convenient.
|
|
Once again, a lot of fun. PythonTutor's visualization was extremely
helpful!
|
|
Oh yeah, I had so much fun with this one! It really worked my brain and
gave me better appreciation of Divide and Conquer and Merge Sort! Philip
Guo's PythonTutor site is amazing! It really helped me in debugging my
recursive function. Fun fun fun!
|
|
The grader showed that it took less time, but more space. There might be
some sampling issues, since I ran both approach only once.
|
|
I chose to use an iterative method, instead of recursion, to avoid
function stacks. Perhaps I should try recursive approach and compare the
results.
|
|
The compare algorithm provided by bytwigorlimerick was so clever and
elegant! https://courses.edx.org/courses/course-v1:UCSanDiegoX+ALGS200x+2T2017/discussion/forum/course/threads/5a427dbf44a15008cd000701
|
|
Maximize salary close to done. Still some bugs. Will likely fix it on my
laptop.
|
|
Eclipse (I'm currently using Photon) "the type integer is invisible"
error is really annoying. I adjusted Java compiler to version 10, which
appeared to fix, but it came back. (10 is the version from command line
"java --version") Hopefully a restart will take care of it for good.
|
|
Pretty challenging and interesting. I'm glad I worked out the algo in
Python first for this problem. Good review of the comparable interface.
Good feeling of stream and lambda functions. Eclipse's erronous
reporting of errors is annoying.
|
|
|
|
I wasn't just a little surprised how simple it is.
|
|
Very rewarding, lots of fun. I'm glad I wasn't lazy, and did the work of
stress testing, which really didn't put much stress, but helped me
pinpoint the bug. Plus I think stress testing will be useful down the
road, very good technique.
|
|
The bug was simple: I picked the index of the sortedAscendingIndex, not
its value in weight comparison.
|
|
I may need to do an exhaustive testing.
|
|
|
|
Interesting challenge again. Once I figured out that the result should
be SumFn-SumFm-1, things started falling into place :)
|
|
User of spreadsheet really helped here. I should have thought of adding
rows earlier.
|
|
Following the same change I made to Python earlier.
|
|
Huge improvement in terms of both time and memory consumption.
|
|
Reinplemented so that fib is of type BigInteger. With this I was able to
get big Fib(n) mod m working. In this particular case, it felt easier
with Python, since it is dynamic, not strongly typed.
|
|
Learned two interesting things:
1. Use GCD to get LCM https://www.idomaths.com/hcflcm.php#formula
2. To make a literal of numbers long, add L at the end of the number!
|
|
Interesting. The original code was like this:
public static int getGCD(int a, int b) {
if (b == 0) {
return a;
}
if (b > a) {
return getGCD(b, b % a);
} else {
return getGCD(b, a % b);
}
}
And it failed the test of 14159572, 63967072. After chaning the code to:
public static int getGCD(int a, int b) {
if (b == 0) {
return a;
}
if (b > a) {
return getGCD(b, a);
} else {
return getGCD(b, a % b);
}
}
It worked! I guess it's important to do a pretty exhaustive testing to
find this subtle bug
|
|
|
|
It was kinda tricky to get it right, with array indexing and how many I
needed to calculate. Good thing I was using TDD, which helped quite a
bit in getting it done!
|
|
Appear to consume a bit of more memory.
|
|
|
|
|
|
|