Saturday, January 14, 2017

Hackerrank week code 28 - Choosing White Balls

January 14, 2017

Choose white balls - problem statement

Introduction
What is the feeling about sitting on the bench while the match is going on? That is something Julia went through in the contest. She tried to do some reach, make 10 - 15 points if possible. One of practice here is to study player's discussion board, and see how top-players are doing when they need to communicate and have some discussion. It is not bad at all to see all over the world, people came together and exchange ideas for the same algorithm.

In the contest 

Hard algorithm, maximum score 54 

Study the khan summation algorithm - read discussion and found some one gave out this tip.

The discussion here is very helpful, at least it is helpful to understand the problem. Work on the example first.

Julia spent 10 minutes to work on the example here:

WBWBW

Analysis with a fault: 

The analysis with some issues:

step 1: 1, 3, 5 are white and 2, 4 black -> 3/5
step 2: 3 possible new sequence

BWBW -> 1 WBWB -> 1 WBBW -> 2/4 -> 1/3 * (1 + 1 + 2/4) = 5/6

total = 3/5 + 5/6 = 1.4333333

Analysis with corrections:

You do not choose xi, they are chosen randomly. You only choose either left or right for given xi. Therefore in step 1, if xi was 2 or 4, you end up with sequences WWBW or WBWW in step 2, you need to count these in your expectation. 

Then you get 3/5 + 1/5 ( 1 + 1 + 2/4 + 1 + 1) = 1.5

Hours of reading - Discussion

BWBWW

Set up a test case for BWBWW - the answer should be
Discussion is here.

BWBBBW

January 14, 2017

Choose white balls - problem statement


Study the khan summation algorithm - read discussion and found some one gave out this tip.

The discussion here is very helpful, at least it is helpful to understand the problem. Work on the example first.

Julia spent 10 minutes to work on the example here:

WBWBW

Analysis with a fault: 

The analysis with some issues:

step 1: 1, 3, 5 are white and 2, 4 black -> 3/5
step 2: 3 possible new sequence

BWBW -> 1 WBWB -> 1 WBBW -> 2/4 -> 1/3 * (1 + 1 + 2/4) = 5/6

total = 3/5 + 5/6 = 1.4333333

Analysis with corrections:

You do not choose xi, they are chosen randomly. You only choose either left or right for given xi. Therefore in step 1, if xi was 2 or 4, you end up with sequences WWBW or WBWW in step 2, you need to count these in your expectation. 

Then you get 3/5 + 1/5 ( 1 + 1 + 2/4 + 1 + 1) = 1.5

Hours of reading - Discussion

BWBWW

Set up a test case for BWBWW - the answer should be
Discussion is here.


BWBBBW

Discussion is here

Summary of Contest Activities

In the contest, spent hours to read the problem statement, discussion, did some research. No code, did not make any points.


Hackerrank week code 28 - Suffix Rotation

January 14, 2017

Introduction
Life is not easy to compete the week code on Hackerrank, now Julia's ranking is following behind around 2900 out of 9985 at 11:54am, 1/14/2016. In order to get into the top 25%, she has to continue to work on the problem solving. It will be a lot of fun, a lot of mistakes, and trial and errors.

Have some images to show the progress first, comparison to one in the ranking of 2000:


Comparison to one in the ranking of 1000:


The Great XOR

Julia just found out through the above graph, she had some issues with the algorithm The Great XOR. Spent 5 minutes to look into detail. She did not have any test case failure when she worked on the algorithm, the hackerrank has issues to run so slow, only at the end of day, all test cases will be run. She lost almost 10 points on the algorithm.

Usually, Julia likes to focus on easy and medium level algorithms, now in order to get a bronze medal, she has to learn to work on hard, advanced and expert algorithms, and try to do some research, read the discussion, and come out a simple idea to make extra points.

Lucky Number Eight
Julia did remember the algorithm was scored 18 instead of 10.80, now there are over 5 test case timeout. Six more test cases are added and she failed all of test cases because of timeout.

Comparison to rank 515



Instead, Julia can choose to walk around the outdoor, and get some physical exercise done first.


Study, research, code 

Suffix Rotation - problem statement

1. Work on a test case:
string abc, there are 6 variations:
abc-> no rotation, answer is 0
acb-> abc,  1 rotation
bac->acb->abc,   2 rotations, second rotation starting from c
bca->cab->abc,  1 rotation, but circular rotation 2 times
cab->abc, 1 rotation
cba->bac->acb->abc, 2 rotations

2. Work on a test case with multiple instances of char:
string abcbb, what is difference?
abbbc,
if we use counting sort, we can determine the char by counting the number, and then calculate difference.
abbbc
c should be in position of 2, starting from index = 0, but actually it is in position of 4
rotation twice move 4 to 2, and also one of b is in position of 4, it should be in 2, also moved forward.

3. Work on a test case, abcdb,
so c should be in position 4, but it is in 2; 4 - 2 = 2, 1 rotation,

Try to use recursion solution to gain a few points first. And get some ideas about the issues.

Test Case: "cababc"

After more than 3 hours coding, at 10:13pm, Julia studied the discussion related to the test case, Julia found out that there are more than one solution, but need to find minimum move.

string cababc, using her naive solution, it will take 3 moves:
cababc ->
ababcc ->
aabccb ->
aabbcc

but the minimum move only needs 2 moves:
first 'a' is to use the second 'a' in the string "cababc", after first rotation, the string will be "abccab", and the second move is to use second b in the string "abccab", then final string "aabbcc".

How to get the minimum move? Use brute force, then calculate each option for any char from a to z.

Try to find something to think about:
cababc->   ababcc
                  abccab

From two strings to choose a small one, how to choose?
abccab  -> aabbcc
ababcc  -> aabccb

Google Search: suffix rotation minimum

ACM ICPC 2003 - the algorithm discussion is here.

One more reading is here.

Review Suffix Array and Longest Common Prefix

Study code review

Ashton and String Hackerrank


my favorite algorithm teacher - JS1

Actionable Items:

Work on the minimum value by simply comparison. Try to get at least 1 point first.

1. check into to document latest progress:
1/15/2017 11:05am
Using my code in C# to test the cases seen in the discussion - link is here.

test case 1: hackerrank - 6
test case 2: suffixrotation - 9

Using queue, and calculate all the possible selections. 

But my C# submission still scores 0, pass test case 0, and time out 1 and 2, and runtime error test case 3 on 1.97s. 

Rotation definition - misunderstanding 

2. Need to look into the rotation definition, see if it is making sense or not. 

Choose index bigger than prior move. 
but, at the index, perform circular rotation in either direction. 
So, work on the example, abcdefjghi, at index 6, with char j, can rotate clock wise or anti-clockwise. 

jghi -> anti-clockwise -> ijgh -> hijg ->..
jghi -> clockwise ->  ghij -> hijg ->..

So, work on the example: cababc
first work on index 0, work on second a, 
                                                      clockwise, abccab
                                                      anti-clockwise, abaccb
                                   work on first a, 
                                                      clockwise, ababca
                                                      anti-clockwise, accbab

and then, work on second char - index = 1, there are 4 choices. 

Because Julia's C# code has wrong answer, probably it is because of her rotation misunderstanding, missing two cases. 

Good workout and great learning 

Suffix Rotation C# practice - score 0, but perfect learning experience. Julia learns the importance to challenge herself to work on hard algorithm, come out the solution to work ok with sample test cases. She spent more than 5 hours to work on the problem on Saturday January 14, 2016 and two more hours on January 15, 2016. 

Have a very excellent experience to work on string manipulation, queue, and also read all discussions to get basic test cases with expected results. 

Make some points on hard algorithm in future week code contest. It seems that week of code is most popular contest on HackerRank, and the difficulty level is up-to-most-top-standard. 

After contest 

code study - link is here
Code review - rewrite the C# code, study and debug, code is here

More study on the code, and 2nd version before code review, code is here.
3rd version, code is here.

Status report

Julia finds out that there are so many solutions to study, and she does not have a lot of time to catch up so many things. Just go one by one.

She will work hard on the algorithm, through the contest, she understood that it is most important to stay humble, and she is thankfulness to enjoy the practice. Just learn one thing a time.

Friday, January 13, 2017

Practice confidence and match confidence - a sports psychology study

January 13, 2017

Introduction
Julia did some research by reading the article written by Dr. Patrick Cohn about tennis match performance and training, the article "Tennis Psychology: Practice Confidence vs. Match Confidence", she learned a few things. Here are her favorite quotes:

-----  great thoughts about tennis sports  - coding should also be the same  ---------

Let’s start by answering a basic question: What does it mean to play with trust? When you play with trust, you allow yourself to play freely – you have faith in your practice. You don’t grind on your technique or over coach yourself in matches because you are confident that you can rely on your practice. You just react to the ball, knowing your training will carry you.

Through practice and repetition – a lot of it – your body learns how to hit shots effortlessly, instinctively. Meaning with enough repetition and practice, you can hit shots without thinking about how to hit shots. You should think of competition as a “closed book test” to use a schoolwork analogy. You’ve studied (practiced) for the test. In competition, it’s time to trust what you studied. 

How does your trust break down all of a sudden when you play in a match? Many mental game or tennis issues can affect your level of trust in matches. A lack of confidence and cause your trust to not show up. Indecision is another barrier to trust. Fear of failure can kill the soundest strokes. Perfectionism can cause you to focus too much on perfect strokes and not enough on strategy and playing smart shots.

What can players do to improve their trust in matches?
Trust starts with having a balance in your practice routines. Practicing the right way will help you improve your trust in matches. The key is to practice like you compete.


-----   end of article excerpts ---

Go over again and again - four times!

Julia has faith in her practice! 
Julia has faith in her practice!! 
Julia has faith in her practice!!! 
Practice is getting better. 


Workout 

Julia experienced the anxiety to take a 75 minutes test, therefore, she has to work on more about match confidence and practice confidence. 

Code Review: SOLID principles

January 13, 2016

Introduction

Julia found out that code review is a really very good to teach and learn. SOLID principle is such a nice topic for her to catch up - a new begining of 2017.

Study

Write down some notes, and prepare to do more research on this study.

community wiki, very nice lecture about SOLID - click here.

Please put together C# code in the above code review and post here as well.

January 19, 2017  9:00pm - 10:28pm

- spent 90 minutes to go over the encapsulation lecture.


Leadership & Management, Productivity study

January 13, 2017

Introduction
Julia spent a few hours to follow hundreds of managers and technical leaders on linkedin a few months ago since she knows the feature "Follow", what she likes to do is to customize her linkedin feeds and then she can get connected to others better. Make herself more valuable.

After a few months, she came cross this article - Leadership study article. So, she likes to do some study on leadership, and figure out something new in 2017.

Workout plan

Will come back soon.


Thursday, January 12, 2017

HackerRank - week of code 28

January 12, 2016

Introduction
Julia did some research by reading the article written by Dr. Patrick Cohn about tennis match performance and training, the article "Tennis Psychology: Practice Confidence vs. Match Confidence", she learned a few things. Here are her favorite quotes:

-----  great thoughts about tennis sports  - coding should also be the same  ---------

Let’s start by answering a basic question: What does it mean to play with trust? When you play with trust, you allow yourself to play freely – you have faith in your practice. You don’t grind on your technique or over coach yourself in matches because you are confident that you can rely on your practice. You just react to the ball, knowing your training will carry you.

Through practice and repetition – a lot of it – your body learns how to hit shots effortlessly, instinctively. Meaning with enough repetition and practice, you can hit shots without thinking about how to hit shots. You should think of competition as a “closed book test” to use a schoolwork analogy. You’ve studied (practiced) for the test. In competition, it’s time to trust what you studied. 

How does your trust break down all of a sudden when you play in a match? Many mental game or tennis issues can affect your level of trust in matches. A lack of confidence and cause your trust to not show up. Indecision is another barrier to trust. Fear of failure can kill the soundest strokes. Perfectionism can cause you to focus too much on perfect strokes and not enough on strategy and playing smart shots.

What can players do to improve their trust in matches?
Trust starts with having a balance in your practice routines. Practicing the right way will help you improve your trust in matches. The key is to practice like you compete.


-----   end of article excerpts ---

Go over again and again - four times!

Julia has faith in her practice! 
Julia has faith in her practice!! 
Julia has faith in her practice!!! 
Practice is getting better. 

So, Julia learns a few things here: 
notes will be written here later. 

She understands that it is very important for her to put herself on stress training daily, therefore, she did work on the week of code 28 so patiently, specially on the algorithm "Lucky Number Eight". She still likes to write a recursion function and review her favorite study blog written in less than 2 months - Nov. 24, 2016.

Contest workout

So far, she ranked 1480 out of 9215 on January 12, 2017, 11:23pm

One of Google employee cui aoxiang - performance unbelievable. She just kept finding new faces from Google, facebook, and also extraordinary performance. Next time, study her code and post some thoughts here.

Another good player from google. Click here.


Wednesday, January 11, 2017

longest palindrome string

January 11, 2017

Review the longest palindrome string through code review.

Previous practices of the algorithm.

Practice I

Practice II


Actionable Items:

Write C# code using this code review.

Longest palindrome string - best review - no raw loop.


Tuesday, January 10, 2017

Code Review stackexchange.com ranking page - a short research

January 10, 2016

Introduction
Julia found out that she had 6% performance tag next to her name, and then she felt so good after she worked on them last 48 days. So, she decided to study the ranking page, spent over one hour to find something to work on.


Study the ranking statistics:
Actionable Items: 
Julia will spend some time to look into 5,000+, less than 200 people, check 10 people a time.

Julia drills down what she did from January 5 - January 10, 2017


134 reputation - Julia gain 34 reputation by posting two code reviews - one is called "Simple Function", another one is called "Find kth largest element in the union of two sorted array". 



Research

Most of important, she found out the best algorithm teachers she can find, and learn from the answers.

1. score over 1122 points on JavaScript - link is here.
2. score 880 algorithm points - link is here.
3. score over algorithm 459 points - link is here.
4. score algorithm 200 points - link is palacsint.
4. Go through algorithm score ranking - link is here.

Study those top algorithm answerers:


Study those top algorithm askers:

Top JavaScript Askers - click here.
Julia's favorite 66 code review by views - click here.

20 algorithm questions - click here.
One algorithm can turn into a fun day. And also see chat room works.

Reversing k size sequence in a linked list. Code review makes perfect.

Longest palindrome string - best review - no raw loop.

Pluralsight: Encapsulation and SOLID

January 10, 2017

Introduction
Julia did some research on stackexchange.com ranking page over one hour, then she found one of talents also teaches on pluralsight.com. Last 2 - 3 months, Julia did not have taken any course. She likes to plan to study the course.

Unbelievable, Julia saw something making her smile, the first 10 days of new year 2017.

Remember the joy, and also first few algorithms she asked, people rushed to help Julia out, and help her write, think and reasoning,  she learned to write her own work, first time she earned the privilege to give out up-vote, Julia found a community to get connected. Have some visual thing to help the celebration of 48 days journey.




Plan

Study the course: Encapsulation and SOLID by Mark Seemann


Sunday, January 8, 2017

Stackexchange.com code review - bonus reputation

January 8, 2016

Julia has a good news to share, she got bonus reputation 100 for code review on stackexchange.com.

Here is the snapshot of the message she got for 8 sites. She got 800 bonus reputation.


Code Review: Sherlock and Anagrams

January 8, 2016

Introduction

Julia worked on the code review by one user third time, she plans to review all submissions from the same user. 

Workout

First algorithm review -

Sherlock and Anagrams


Julia worked on the algorithm, here are her previous blogs about the algorithm:

Practice I

Practice II

Practice III

Practice IV

Practice V

Practice VI: Warmup after 3 months

Spent some time to go over code:

Read editorial notes, and also have some practice using C# on January 8, 2016.

Another practice using C#.

January 22, 2017 

Another practice, C# code is here.
study code review done by mdfst13, review is here.

Tennis coaches and their sharing of teaching

January 8, 2016

Introduction

Julia starts to show strong interest on tennis coaches study after she wrote her first post about tennis coach Rob Steckley on Dec. 26, 2016. Specially, when she experienced the nervousness to prepare a 75 minutes coding assignment and rushed to find help, she knew that sometimes she let nervousness take over, domino effect may happen, because she is still a weak player without strong disciplines and a lot of trials and errors. Algorithm player and tennis sports are two sports Julia trains herself hard.

Julia knew that she had weakness on her English skills, she has to push herself write down something every day; and also, recently, she likes to clean out the blog page content, for example, do not show link url instead of showing some interesting context, pay attention to small detail, specially after she starts to learn aesthetics in design,  read the book the art of readable code (Part I. Surface-Level Improvements - chapter 4: Aesthetics); she learned a few things from stackexchange.com code review, when her posts were edited by various people.

Patrick Mouratoglou and Darren Cahill US open interview, Julia chose to study the interview again, and this time, she likes to document the coach's talk, how coaches help tennis player express the anger in the match, and how to relate to her own experience in sports and also in competition of software programming contests.

Workout 

Julia has to pay attention to her English skills, and then work on small task once a while. Take down notes from the coaches, and continue to do some research.

Will spend one hour to take notes first. Will come back very soon.

1:58pm
Darren Cahill:
Former coach of Agassi & Hweitt
1988 US Open Semifinals
Current coach of Simona Halep

Simona threw the racket - how did coach guide her on releasing her anger properly?
Consistency, consistency in the training. Consistency in the game plan, then be able to evolve as a tennis player as well, not stick to one thing at all; If something is not working, you have to find other ways to win in tennis matches. At the beginning to work with Simona, if something is not working, then bring out domino effect, a lot of loss of points afterwards, affect the game. She is doing much better right now, isolate that thing, move to something working.

In perfect world, no to Simona's action to throw racket on the ground. You want the player to keep those emotions inside. But she is Romania, she has a fire in the belly. They like to express themselves, especially Simona. And my biggest issues are if you do get angry, that is fine. But do not filter through next 2, 3 points, and let games get away from you. But we just need to get her a few rackets.






Code review by User (III)

January 8, 2016

Introduction
Julia woke up in the middle of the sleep, and then she checked her two posts on code review, she was amazed that in her 3 hours sleep she got 3 up-votes. Actually she went bed around 2:00am, she posted 2 algorithms for code review. What a bad unhealthy life style - let internet ruin the good sleep.

She knows that she has to learn how to play a good game about reputations, and do not let reputation take over her strong analytical mind she is trying to build up. At 9:48am the morning, her reputation is up to 189, 20 more reputation compared to 2:00am, January 8, 2017 when she went to sleep.

One of algorithms is about simple function. Link is here. She got 2 up-votes, each brings 5 reputation.
Another one is about "Find kth largest element in the union of two sorted array". Link is here. She also got 2 up-votes.

She taught herself to be very patient in Saturday, spent over 4 hours to work on Hackerearth simple function again, and learn whatever she has to do. She got feedback from her post - the code is hard to follow, where code is rewritten from her study other player's C++ code. One algorithm a time (This algorithm Julia worked on more than 2 * 10 hours). So, she likes to avoid complicated code, and work with high reputation talent (For me that solution is hard for follow – Paparazzi Jan 2 at 15:12 about Julia's post) better, she said goodbye to her old post and all her concerns to work on the follow-up post.

So, most of important is to have some sportsmanship, check other people's post, and give out an up-vote as well. Think about others, give out some encouragement as well. The small sportsmanship leads her to do a study on a post by this user.

Workout

Julia experienced the excitement from reputation going up 20 from 169 to 189, after she worked on algorithm more than 8 hours in Saturday, January 7, 2016. Now she is imaging that how much work she has to complete in order to make this reputation go up to the user - CodeYogi 1683, top 8% overall. 

100 algorithm, have some time to study peers. 

First algorithm review -

Sherlock and Anagrams


Julia worked on the algorithm, here are her previous blogs about the algorithm:

Practice I

Practice II

Practice III

Practice IV

Practice V

Practice VI: Warmup after 3 months




Saturday, January 7, 2017

Facebook hackercup qualification round - Fighting the Zombie

January 7, 2017

Julia likes to get some experience on this - she likes to have some adventure for 2017.
  • Online Qualification Round: January 6, 2017, 4pm PST - January 9, 2017, 4pm PST (72 hours)
Here is the link to get some experience. 

The progress pie - the third algorithm

Plan to spend as many hours as I can this weekend. Enjoy the qualification round.  

Facebook hackercup qualification round - lazy loading

January 7, 2017

Julia likes to get some experience on this - she likes to have some adventure for 2017.
  • Online Qualification Round: January 6, 2017, 4pm PST - January 9, 2017, 4pm PST (72 hours)
Here is the link to get some experience. 

The progress pie - the second algorithm

Plan to spend as many hours as I can this weekend. Enjoy the qualification round.  

Friday, January 6, 2017

Exercise and the brain

January 6, 2017

Watch the video by Wendy Suzuki - a professor of New York university.

http://www.wendysuzuki.com/

Facebook Hacker Cup 2017 - The progress pie

January 6, 2017

Julia likes to get some experience on this - she likes to have some adventure for 2017.
  • Online Qualification Round: January 6, 2017, 4pm PST - January 9, 2017, 4pm PST (72 hours)
Here is the link to get some experience. 

The progress pie - the first algorithm

Plan to spend as many hours as I can this weekend. Enjoy the qualification round. 

Trust your struggle

January 6, 2016

Trust your struggle - Zain Asher - CNN Anchor, a very nice and well-prepared talk around 14 minutes.

Zain Asher Bio is here.

3 beliefs:

1. Hard work is not all. Trust your struggle. The hardship you go through will be your own benefit.

2. Not believe competing what you want, but creating what you want. Do not need to take anything from others.

Abraham Lincoln: The best way to predict your future is to create it. 

Instead of competing, compare yourself again and again, actually bring out fear, insecurity and actually hold you back. 

3. The more you give, the more you receive.

Interview Kat Cole, is something different: The more you give, the more you receive.

You have to network, have a brand, and study your competition.

Loosely related to hard work, success comes when opportunity meets preparation.

Her brother is an actor - master to prepare early, very well.

Trust one day, the opportunity will come. Not prepare for interview.

Teach herself about stock, finance, a few years. After she prepared for financial study for a few years, she had chance of 2 weeks to prepare for the screen test and financial test, for a position of finance reporter in CNN.











What one skill = an awesome life?

January 6, 2017

What one skill = an awesome life? | Dr. Shimi Kang | TEDxKelowna

Thursday, January 5, 2017

8 Do not - Relax and Be Yourself

January 5, 2016

Be yourself and relax in 2017. It will be a great year for hard working people, Julia, you are one of them.

A - Do not act like you know everything.    (I am still learning, do one thing a time.)
B - Do not be a hero.                      (I make mistakes, and then know how to calculate the risk better)
B - Do not be overly format.  (Specially, do not purchase too many clothes.)
O - Do not over-prepare.        (Treat yourself as a human being. Stay in the moment. )
P  - Do not panic if a problem stumps you. (Nobody is perfect. Even champions will fail over and over again.)
S - Do not second-guess yourself.   (Practice makes perfect. Do one thing a time)
S - Do not stress if you are not a 10X coder. (Julia, you fail so many times in programming contests, then you learn the difficulty of problem solving.)


Review the interview cheat sheet blog's notes, write down most favorite ones:

1. Don't be overly format. "Don't act like somebody you're not - it's really a come-as-you-are environment."
2. Don't second-guess yourself. "You have to have confidence in your ability to make connections, because executives are going to challenging your recommendations. You'll be expected to back them up."
3. Don't act like you know everything.
4. Don't stress if you're not a 10X coder.
5. "The interview isn't grading you on your improv skills, but whether you steer difficult conversations forward without falling for distraction."
6. Don't be a hero. "Be able to articulate your specific contributions instead of doing everything yourself."
7. Don't over-prepare. "Planning everything you're going to say and do in the case study portion of the interview makes for a stale presentation and misses the mark. The point of the case is to see how you approach problems in real time."
8. Don't panic if a problem stumps you. "We're really trying to assess your thought process, so if you get stuck or make a mistake, don't stress out - nobody is perfect."


A photo posted by Caroline Wozniacki (@carowozniacki) on