Sunday, January 29, 2017

Hackerrank world codesprint 9

January 29, 2017

Contest Summary 


Julia worked on first 4 algorithms.

Started around 4:30pm on second day of contest, Julia managed to complete the first 3 algorithm, scored 60, rank 2076 out of 6866, at 1am, January 29, 2017. Julia tried to work on 5 algorithms in 2 hours from 11:00pm to 1am, try to score 10 out of possible score - an array of {50, 60, 70, 90, 100}, one medium, one hard, one advanced, 2 expert algorithms, and tried to make any point to push the ranking forward, but she did not have enough time to study, do some research on those algorithms.

Journal of Contest


Grading Students
Time: 5:25pm - 5:33pm

Weighted Uniform Strings
Time: 5:39pm - 6:48pm
C# code is here.

Queen's Attack II
Time: 7:24pm - 10:35pm
She spent over 2 hours to work on Queen's Attack II, and also she learned a few lessons through the practice. A very good workout! She tried a few times, scored 20, 24, and then scored maximum score 30.

First submission, failed a few test cases, score 20.4 (maximum 30), C# code is here.
Second submission, failed a few test cases, score 24.51, C# code is here.
Third submission, passed all test cases, score 30, C# code is here.

Use online text comparison tool, compare the difference between two versions.
Code comparison is here, left side is third version, right side with bugs.
The idea used in the third version is to avoid redundant checking directions, therefore only one copy for each check, less time to do testing to remove bugs.

Kingdom Division
Time: 11:00pm - 1:00am
She spent more than 2 hours to play with the algorithm starting from 11:00 pm in January 28, 2017. She did have some simple idea to work on. For example, find all cities with only one connected city, and then form a group with those two cities.

Actionable Items


Need to think about how to improve the performance on the first medium algorithm - queen'a attack II, work on writing readable code, follow DRY principle, therefore, time can be cut in less than one hour for the algorithm. Close to 3 hours, including a 20 minutes dinner.

Study some players and get confidence back to work on medium above algorithms. 


Follow up after contest


January 30, 2017

Queen's Attack II

Julia learned the hard way, she did write directions array and define 8 directions. But, she did not push her through to avoid any redundant code, spent time on intermediate results. Near 3 hours, she put together the C# code here in the contest.

She reviewed the statistics, people can finish the algorithm in less than 20 minutes.

The idea is to enumerate each direction by going through the array, and encapsulate all directions’ info inside the array, open for extension but close for change. All direction information update are limited to the two arrays only.

Avoid writing if statement for each direction.

Write again in less than 20 minutes, C# code.

Write again with two changes, C# code.
1. use implicit type local variable var
2. use HashSet<Tuple<int,int>> instead of HashSet<string>


No comments:

Post a Comment