Sunday, November 20, 2016

Minimum Cost - comparison of simplicity - C# vs C++ (series 7 of 10)

Nov. 20, 2016

One thing Julia is learning in the contest is to write simple code, avoid complicated situation, cut the executable paths/ giant expression/ complicated things to eat time.

One thing Julia likes to do is to compare her C# solution using Dictionary<Int64, string> to this C++ solution, she just found out that her logic thinking can be simpler.

C# solution written by Julia:

https://gist.github.com/jianminchen/af474846d81b96f4e70fc1a5866dca15

C++ solution: (rank after 400 before 500)

https://gist.github.com/jianminchen/0e98727e40937c11594b0be8ea496885

Compared to top performer (rank 6 out of 1500) - C++ code, just less than 30 lines of code:

https://gist.github.com/jianminchen/8a448bac7de8ad3667b125abe3544e5d

Very close to my idea in C# - by a Microsoft Bing employee -

Nickolas - Topcoder writer, rank 84 of contest.

https://gist.github.com/jianminchen/7ef0dcb49662f277fda36742da5fa57c

Study all her submission on this contest ! - figure out the style I should learn.

Julia's comment: 

Know the problem inside out, a lot of ideas and implementation. One day, Julia can choose best one to make it less than 10 minutes a medium algorithm as well. 

Visual facts to encourage Julia work hard, and continuously improve! The goal is to shorten the time to performance. It is also practical goal, achievable!

Here is the graph Julia likes to share the research she did through the contest:

Case 1:
algorithm: minimum cost
100 minutes vs 8 minutes - over 10 times more to spend on the performance! Julia, you have a big room to improve!

Case 2:
algorithm: stone division, revisited
329 minutes to come out a solution, score 0 of 50; extra 3 hour to work until 2:00am

Compared to 50 minutes full performance, less than 40 minutes.
500 minutes -> 40 minutes, 10 times more! I just could not believe that. The research and development I did over 6 hours, does not help. Best performer uses 40 minutes to do everything, including his research, coding and testing etc.





No comments:

Post a Comment