# Data Science & Stats questions [closed]

I have a few probability and stats questions and was hoping if someone could help in answering those.

1). Imagine there is a square. There is an ant at one corner of the square. At each step it reaches the other corner. The rule for it move is as follows: Flip a coin. If it is heads, the ant moves clock-wise. If it is tails, the ant moves counter-clockwise. The goal of the ant is to reach the diagonally opposite corner of square. What is the average steps the ant would take to reach there?

2). There is a building with 100 floors. You are given 2 identical eggs. How do you use 2 eggs to find the threshold floor, where the egg will definitely break from any floor above floor N, including floor N itself.

3) A Russian gangster kidnaps you. He puts two bullets in consecutive order in an empty six-round revolver, spins it, points it at your head and shoots. click You're still alive. He then asks you, do you want me to spin it again and fire or pull the trigger again. For each option, what is the probability that you'll be shot?

Thanks a ton!

• I don't think this is a place that you can post such questions. You'll need to prove what you've done. Jun 5 '15 at 3:13
• Well I am trying out Stats 101 knowledge on some probability questions. And no I am not in college so these are not homework questions. I came across these on a stats forum and found a bit difficult to solve. So thought this forum could help me learn how to think about these problems in general Jun 5 '15 at 3:15
• First problem is expected hitting time of random walk.google that.simplest solution is by setting up recursion based on expected hitting time at position x in terms of x+1,x-1. Third 1 is well known but don't know name..look at 'Monty hall'problem in think bayes greenteapress.com/thinkbayes/html/thinkbayes002.html#toc13 Jun 5 '15 at 6:14
• @user: It's immaterial whether the questions are for homework or for fun: sufficient justifications for our policy are first that we don't want CV to become a compendium of answers to standard textbook exercises, & second that it's of more (lasting) benefit to you to get help in solving the problems yourself rather than being told the answer (if you are kidnapped by a gangster you probably won't have internet access). So please do use CV to help you learn to think about these problems - in accordance with the self-study rules. Jun 5 '15 at 9:35
• 2 is not a stats/data-science question. no probability involved. It's a classic brain-teaser for job interviews (albeit such teasers are apparently now frowned upon, because too many prepare for these questions and then turn out to be foul eggs when confronted with real challenges.) Jun 5 '15 at 17:01

As noted in the comments to your question, Stack Exchange frowns on answering these type of questions that lack any demonstration of work so far as they read like homework questions (or interview questions in this case) on which you've made no effort to solve. But they're fun, so typical stack exchange chiding aside here's my try at what are three interesting problems:

1) The answer is roughly 4, as estimated by simulation in Python:

import random
import pandas as pd
random.seed(882434172)

def ant():
i = 1
j = 1

while True:
i = max(0, i + random.sample([-1,1], 1)[0])
j += 1
if i == 2:
break

else:
i = 1
j += 1

return j

ants = []

i = 0

while i < 100000:
ants.append(ant())
i += 1

df = pd.DataFrame(ants, columns = ['turns'])

The key here is that if the ant can walk closer (+1) or farther (-1) away, but is never gets more than 2 moves from its destination and starts 2 moves from its destination. You also need to factor in that if two moves away the ant always moves closer (because they're moving around a square rather than along a line). So the else statement adds this handicap by tacking on a move and starting them at 1 if they end up 0 (which represents their original starting point from which they can only get closer to the destination).
• Questions like (1) can usually be solved recursively, often in less time than it takes to write a simulation. If $e_2$ is the expected number of steps from the original point and $e_1$ is the expected number from either of its neighbors, then (a) since the first step is necessarily to a neighbor, $e_2=e_1+1$. From there, there is a $1/2$ chance of arriving at the goal or going back to the beginning, whence $e_1 = 1 + (0+e_2)/2$. This simple set of linear equations has a unique solution, easily found.