You are viewing a single comment's thread. Return to all comments →
The answer exists because we are calculating the expected number of turns.
Think of a fair 6 sided dice. The expected outcome is the sum of each potential outcome multiplied by the probability of that outcome:
1*(1/6) + 2*(1/6) + 3*(1/6) + 4*(1/6) + 5*(1/6) + 6*(1/6) = 3.5
In other words, if we rolled the dice an infinite number of times we'd expect the average to be 3.5.
I wrote an article with some hints. https://www.jamespking.com/posts/hackerrank-projecteuler-227-writeup/
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #227: The Chase
You are viewing a single comment's thread. Return to all comments →
The answer exists because we are calculating the expected number of turns.
Think of a fair 6 sided dice. The expected outcome is the sum of each potential outcome multiplied by the probability of that outcome:
1*(1/6) + 2*(1/6) + 3*(1/6) + 4*(1/6) + 5*(1/6) + 6*(1/6) = 3.5
In other words, if we rolled the dice an infinite number of times we'd expect the average to be 3.5.
I wrote an article with some hints. https://www.jamespking.com/posts/hackerrank-projecteuler-227-writeup/