mathtaskprobabilityprobability-theory# Playful cat and keyboard

### One way to think about it:

### Another way:

Problem:

The keyboard on the screen of the mobile application consists of: 26 capital Latin letters, 10 digits 4 navigation keys: up, down, right and left.

The application is open on a tablet, on which an unpredictable and consistent cat walks. The unpredictability of the cat is that all its movements are random and independent, that is, it can press the same key in a row. Or different - it's unpredictable. And his sequence is that he attacks each in turn, and not simultaneously. What is the probability that after eight steps on the buttons this cat will press the arrow at least once? Give your answer as a percentage, rounded to the nearest whole number.

I tried different formulas on Python for finding the probability and settled on this one, but it does not give the correct result

```
no_arrow_prob = (1/10)**8*100
print(no_arrow_prob)
```

I will be thankful for any help. =)

Solution

So there's 40 keys. And 4 of them are arrows. So the probability that the cat hits an arrow on the first change is `4/40`

or 10%.

If it doesn't hit it on the first try, it's got another chance.

And so on.

```
10%
┌────► hit an arrow
│
│ 10%
│ ┌──► hit an arrow on try two
│ │
first try│ │
│ │
│ │
│ 90% │
└────► didn't hit an arrow │
on try one. │
│90%
└───► didn't hit an arrow
on try two
```

You could implement this logic in python as:

```
arrow_prob = 0
remaining_prob = 1.0
for attempt in range(10):
arrow_prob += remaining_prob * .1
remaining_prob *= .9
print(int(100*arrow_prob))
```

Alternatively, we could ask what is the probability that I **never** hit an arrow key over one attempt. This would be `36/40`

.

And what's the probability that I never hit an arrow key over 10 attempts: `(36/40) ** 10`

.

```
no_arrow_prob = (36/40) ** 10
arrow_prob = 1 - no_arrow_prob
print(int(arrow_prob * 100))
```

- Algorithm to locate local maxima
- unsigned long long int pow
- Simple statistics - Java packages for calculating mean, standard deviation, etc
- Arbitrary-precision arithmetic Explanation
- How do I calculate r-squared using Python and Numpy?
- Print all ways to sum n integers so that they total a given sum.
- Prove that (p → q) → ((r ∨ p) → (r ∨ q)) is a tautology without using truth table
- How to implement this Desmos roll function in Unity
- How to compute the centroid of a mesh with triangular faces?
- Different results for XIRR between Excel and ExcelFinancialFunctions 3.2.0
- Efficiently getting all divisors of a given number
- In JavaScript, why does zero divided by zero return NaN, but any other divided by zero return Infinity?
- Float number division with 3 decimal places
- Python fit line to high dimensional points and sample between them
- How can I compute a dual norm?
- How to pick between 2 numbers
- Fastest implementation of sine, cosine and square root in C++ (doesn't need to be much accurate)
- double and accuracy
- Is there a standard sign function (signum, sgn) in C/C++?
- I convert ASCII words into numbers but am stuck trying to decode them. How to convert 1=a, 2=b, 28=ab etc? (psudeocode okay)
- Is there such thing as math.substring in java?
- Count number of ways to pair integers 1-14 under constraint
- How to round up on a log10
- Bezier curve arc lengths
- Calculate cash flows given a target IRR
- Integration in Python Midpoint Calculation
- Generate P random N-dimensional points from list of ALL possible pairwise distances
- Grouping a list of integers with nearest values
- Branchless calculation for multiplying by the complement of a fraction with a flag
- Finding least number of moves