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
From January 2015, she started to practice leetcode questions; she trains herself to stay focus, develops "muscle" memory when she practices those questions one by one. 2015年初, Julia开始参与做Leetcode, 开通自己第一个博客. 刷Leet code的题目, 她看了很多的代码, 每个人那学一点, 也开通Github, 发表自己的代码, 尝试写自己的一些体会. She learns from her favorite sports – tennis, 10,000 serves practice builds up good memory for a great serve. Just keep going. Hard work beats talent when talent fails to work hard.
Showing posts with label NCR codesprint. Show all posts
Showing posts with label NCR codesprint. Show all posts
Monday, November 7, 2016
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 variables - row, col two variable can be avoided, using startX, startY, endX, endY to calculate.
No. 3 submission
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.
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 variables - row, col two variable can be avoided, using startX, startY, endX, endY to calculate.
No. 3 submission
code review after the contest:
- The while loop - 115 - 119, but line 118, 119 redundant, part of first two lines.
- Base case - one row, one column do not work - count twice
- 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.
- 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.
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
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.
Subscribe to:
Posts (Atom)