Showing posts with label HackerRank NCR codesprint. Show all posts
Showing posts with label HackerRank NCR codesprint. Show all posts

Monday, November 7, 2016

HackerRank NCR codesprint review

Nov. 7, 2016

Codesprint:
https://www.hackerrank.com/contests/ncr-codesprint/challenges


Julia was so motivated to spend 2 days in the weekend to work on the codesprint, she only did one shopping trip to Burnaby crystal mall, less than 2 hours. Rest of weekend, she worked on the problem solving.

Julia reviewed the article about HackerRank contest and how to play better:

https://goo.gl/IHeEoi

Her favorite note in the above blog, item 4:

Even if you are not world class competitive programmer, you still have a chance to get into top 50 or even higher. The minimum goal is to get into top100, which is like usually about top 2–3% of all competitors. Being in top100 is great and sounds really good. 

The major factor to achieve the goal is a combination of problem solving skills, online research, dedication and persistence. First read all the problems and start solving them one by one from the easiest one. First solve the ones you can tackle without any research or long thinking, just to mark them as done and get motivation to tackle harder ones.

Julia did some research on this NCR contest, in top 100, even around 100, some of them are ICPC contest winner, score range is around 200 out of 430. 

Julia's score is 62.76, 480 out of 2621. 

Facts:
1. Julia likes to work on those hard algorithms, last 3 of 8 algorithms. She thought that she could make 10 from each of them. But it was too late when she read the problem statement. She only had 3 hour left to 12:00am in the middle night of Sunday. 

Lessons learned: 

Do not work on ideas taking a lot of time to code; even prototype is questionable. Treat it as a contest, play to win, not play to learn

48 hours contest, a lot of algorithms - 8 of them, total time to work on is 16 hours, 8 hours a day. So, give each algorithm 2 hours a time. 

Spent 6-8 hours to score 6 out of 20 on spiral message. Simple mistake of understanding problem statement, and base test case: one line, one row failure. 

Should be more confident on hard algorithm - game of numbers. Less than 1 hour to score 15 of 50, but gave up bug fix. So close to perfect solution. 
So, if Julia has more experience to play HackerRank contest, she should try to make it at least 100 of 430. And also, she can spend less hours to work on the contest, and spend 1 - 2 hours a day on sport activities in the day time. 

Do not think about past contest - Warlmart codesprint, 24 hour contest, Julia spent time to bet on a hard problem (score: 100) until 4:00am, and scored 0 of 100. 





HackerRank NCR codesprint - Mega Tic-Tac-Toe

Nov. 7, 2016

Problem statement:
https://www.hackerrank.com/contests/ncr-codesprint/challenges/mega-tic-tac-toe

Submission using Dynamic Programming solution, score 30 out of 30.


https://gist.github.com/jianminchen/0055d61e696ef762310f1176734b2d60

HackerRank - Spiral Message - NCR codesprint

Nov. 7, 2016

Problem statement

Julia spent over 4 hours to work on the solution, she made 15 submissions in the contest.

No. 1: first submission - score 4.49 of 20 (pass 4 of 14 test cases)


submission #2: (Score is 0.82 (full score is 20), pass 2 cases of 14 test cases.)


Julia's analysis after contest about the submission:
Submission #2 issues:

1. Repetition: Code is no good in structure, repetition code.
2. Structure issue: Counting mixes with string construction. Counting code duplicates 4 time. line 96 - 100
3. Base case: base case is not handled properly, one row, one column; one row will be counted twice.
4. Missing info: String split using # is avoided, just use count directly. But the spiral message is not correct.
5. Extra variablesrow, col two variable can be avoided, using startX, startY, endX, endY to calculate.

No. 3 submission

code review after the contest:
  1. The while loop - 115 - 119, but line 118, 119 redundant, part of first two lines.
  2. Base case - one row, one column do not work - count twice
  3. Add debug code - stringBuilder to tracker the string output - it is helpful, but unfortunately in the contest, Julia did not catch the error - starting point.
  4. Missing start time/ end time for submission above function comment, need to track time spent.

line 49 - 59 test function: 

if the testing() function, the program does something like string.CompareTo("xaa##ar#rswx#aa") == 0 (line 209 - 210). and then, Julia would have found the start point should be lower left-hand instead of up left-hand in the contest.


No. 15. Julia's submission - score 6.7 of 20



Editorial Notes:

Think about the problem writing. Good problem writing gives out the important information, directly/ indirectly, more than once, twice.

There are 3 times to catch up spiral message starting point bug.
1. First, by following the diagrams closely.
2. Read the word by word
3. Sample test case spiral message result.

Base test case failed - bug, need to think about Math induction proof, starting from base case, and then, assuming N is correct, prove N+1 case based on N and base cases. Detail see book:
Page 15 - mathematical induction vs  programming technique of recursion

Design talk:
Spiral message - a matrix

start point matters,
choices: start from 4 corners.