Showing posts sorted by relevance for query interesting fibonacci sum. Sort by date Show all posts
Showing posts sorted by relevance for query interesting fibonacci sum. Sort by date Show all posts

Sunday, October 30, 2016

HackerRank - WarmartLabs Codesprint (Algorithms) - Interesting Fibonacci Sum

Oct. 30, 2016

Introduction


Julia changed the practice to attend the contest, she chose to take some risk; aim most difficult algorithm, last of 6 algorithm - Hard level. Total score is 100, she knew about Fibonacci algorithm very well, dynamic programming, memorization, bottom up; she also spent over 2 hours to read the problem statement, try to work on the mathematics part of the algorithm.

Until 4:00am, she gave up. She thought about last hour, if she can make this algorithm work, then, she can score 120, rank will be 120/ 2600; She could get into top 10%.

Problem Statement


Summary of practices


Worked on the algorithm from 11:am - 4:00am, near 15 hours, score 0 out of 100.

Submission 17 times. First work on memory issue, remove out-of-memory issue; and then, worked on timeout issue, could not get rid of range sum query O(n2) issue, n is O(n5).

1. First submission:
Fibonacci sum - first submission - line 183 - line 196 function fibo - array declaration on line 187 - 109 * 4 bytes = 4000MB.

If there is no memory limit, timeout issue, the algorithm will work. Cannot scale, timeout 2 issues.

2. 8th submission, out-of-memory, should be less than 512MB; but it is over 4GB for an array

3. 9th submission

4. 10th submission

5. 17th submission

Until last hour of 15 hours, Julia read discussion. "Segment Tree" may be the idea to avoid O(n2), range sum query classical problem.

Encouraging notes for Julia


Julia likes to celebrate her 15 hour effort to work on a hard algorithm problem on HackerRank; focus on the hard algorithm, therefore, she can figure out later what she should put her training next. 

Instead of working on medium/ advanced level algorithm, Julia likes to solve first hard algorithm first. This is the first time she did in 24 hours contest, push herself to the limit, try to solve one hard algorithm. She does not have time to read 3 medium algorithms problem statement in the codesprint. 

3 kinds of people, do not know what is happening, one is to make thing happen. Julia chose the last one. One day, She can solve hard problem on HackerRank contest. Make things happen. Fail fast, fail quick. Just do it.


Previous blogs about Fibonacci algorithm


I solved the algorithm called climbing stairs


Julia, remember the phrase: The hard makes it great! Enjoy the journey.

HackerRank - WarmartLabs Codesprint (Algorithms) - Interesting Fibonacci Sum (II)

Oct. 30, 2016

Work on segment tree idea to solve timeout issue. After the contest, Julia has more time to relax, and try different ideas to solve this hard algorithm on HackerRank.

Previous blog

Will come back to write C# code to try segment tree idea.

Read editorial notes.

Ashar Faudi - study a player - Topcoder SRM problem writer
Need to spend time to figure out this linear recurrence for programming contest .

https://www.linkedin.com/in/fushar

Study C# submissions:

1. C# submission

2. C# submission

Think about the strategies of HackerRank contests - should work on medium algorithm instead of hard one. Math part is not easy to figure out in less than 24 hours.

Spent 2+ hours to go over the submissions on this hard algorithm, get the data - who are those talents? What they are sharing? A special group with strong math or research abilities?

1. Competitive programmer talking about achievements.

2. People good at math - problem solving on the algorithm - a few of them are competitive programmers.

3. programming contest

4. Math Ph.D. graduate (better programmer compared to Julia)

https://www.hackerrank.com/hoek3000

5. Figure out something new in computer science master graduate study:

Wednesday, March 1, 2017

Hackerrank contests - performance review (II)

March 1, 2017


Richness of learning experience


Julia also learned to take those contests seriously, because only if she put all the efforts she can, then she may see some growth over the time. 

First contest she did by her habit, not seeking excellence. And then she noticed that she will have problems to stay that way. 

Week of Code 29               4395/ 9216     Feb. 2017 *
World CodeSprint 9         2164/ 7284     January 2017**
Week of Code 28               2915/ 10421   January 2017***

ACM ICPC Practice Contest 2016   787/ 925            November 2016 ****
Women's CodeSprint 2                     505/ 1882          November 2016 +

University CodeSprint             2081/ 5552     November 2016 ++
WalmartLabs CodeSprint        3226/ 4392     Oct. 2016 +++
World CodeSprint #4               2271/ 5258    June, 2016 ++++
101 Hack Feb 2016                  481/ 723        Feb. 2016  -
Week of Code - 19                    2693/ 3204   Feb. 2016 --


Analysis



Week of Code 29               4395/ 9216     Feb. 2017 *



*( Julia did not work on until last 2 days, and the Sunday she went to church and played tennis, went outdoor from 11:00am - 6:00pm) 



World CodeSprint 9         2164/ 7284     January 2017**



** if Julia started to work on the problem early, same score people had bronze medal. 


Week of Code 28               2915/ 10421   January 2017***



*** very close to top 25%, need to look into the issues 

ACM ICPC Practice Contest 2016   787/ 925            November 2016 ****

**** the algorithms are more difficult to solve, the time is short than other contest.  Julia spent 3 hours in 
the contest.


Women's CodeSprint 2                     505/ 1882          November 2016 +



+ Julia stumbled on a simple recursive algorithm, maximum score 50, she ended up score 0. 
She posted the question on algorithm "stone division" with her C# solution after the contest on codereview.stackexchange.com. 


University CodeSprint             2081/ 5552     November 2016 ++



++ Julia never had chance to work a hard algorithm over 10 hours, so she gambled her luck and 
tried to do some research and problem solving on maximum score 80 - hard algorithm, she ended 
up score 0. 

She learned the lesson of Hackerrank, hackerrank holds high standard on hard algorithm. 


WalmartLabs CodeSprint        3226/ 4392     Oct. 2016 +++



+++ Need to look into the issues, concerns, will come back to add more notes here. 
Julia spent over 10 hours on a 24 hours contest, one hard algorithm called "Interesting Fibonacci Sum", maximum score 100. She tried to submit more than 18 times, but she ended up scored 0 on the algorithm. She did not read medium algorithms problems very carefully, no time to work on. 

After the contest, Julia studied those players good at the hard algorithm, wrote a blog as well. 


World CodeSprint #4               2271/ 5258    June, 2016 ++++



++++ Julia did not know that she can manage to win a bronze medal, at that time, she did not know bronze medal - top 25%. 

She also wrote a lovely blog to document her interest and curiousity. So amazing, like bible verse, Mark 4:8, Still other seed fell on good soil. It came up, grew and produced a crop, some multiplying thirty, some sixty, some a hundred times. 

All she has to do is to give herself time to develop skills, play more contests in the future. She documented her 12 hours labor and score 0 on AorB algorithm. Celebrate the hard work! Post AorB to code review. 

Her blog shares her journey from 40 to 100, won her first bronze medal in her third contests in the row.

More detail see Jianmin Chen hackerrank profile