Skip to main content

Questions tagged [probability-theory]

Challenges which involve computing probabilities for random variables and stochastic processes.

13 votes
12 answers
2k views

Odds for second smallest prime factor

Given a prime number \$p\$ output the asymptotic density of the set of positive integers which have \$p\$ as their second-smallest distinct prime factor Input/Output Input: one of the following ...
Mukundan314's user avatar
  • 12.5k
21 votes
4 answers
2k views

Avoiding Loops!

Given a collection of coloured laces, what would be the probability, \$P\$, that Alice won't create any loops if, until impossible, they tie two uniformly chosen, free lace ends of differing colours ...
Jonathan Allan's user avatar
13 votes
7 answers
1k views

Compute probability of seeing all the balls

Given \$x\$ distinguishable balls (say they have different colors), sample with replacement repeatedly until all the balls that have been seen, have been seen at least twice. Challenge The input is ...
Simd's user avatar
  • 3,108
9 votes
5 answers
2k views

Random factorized numbers

Input The code should take an integer \$n\$ between 1 and 1000. Output The code should output positive integers with \$n\$ bits. Accompanying each integer should be its full factorization. Each ...
Simd's user avatar
  • 3,108
6 votes
3 answers
529 views

Pick a random string at a fixed edit distance

I have string \$s\$ of length \$n\$ and some constant integer \$k\$ which is at most \$n\$. Give the fastest algorithm to sample a random string with Levenshtein distance \$k\$ from \$s\$ uniformly. ...
Simd's user avatar
  • 3,108
14 votes
15 answers
1k views

Weighted coin flip strings

Given n, k, and p, find the probability that a weighted coin with probability p of heads will flip heads at least k times in a row in n flips, correct to 3 decimal digits after decimal point (changed ...
dancxviii's user avatar
  • 193
21 votes
21 answers
2k views

Sample integers that sum to one hundred

Given a positive integer n, randomly output n non negative integers that sum to one hundred. n will be at most 200. The output should be present as a list of integers (not sorted). Your random sample ...
user avatar
3 votes
0 answers
191 views

Calculate the probability of getting this hand in n tries [closed]

Imagine there is a card game where the primary objective of the game is to get 4 of one card in your hand. Game mechanics Each player starts of with 10 cards in their hand. The remaining 32 cards (...
violetorigin's user avatar
3 votes
7 answers
743 views

Yet another coin flipping problem

Problem Starting with a set of 10 coins at the start where all coins are tails up, and given n number of integers \$x_1, x_2, x_3... x_n\$ representing n rounds of coin flipping. At each round, we ...
gamerx's user avatar
  • 141
3 votes
2 answers
202 views

A Suitable Mission — The Professor's Revenge

Summer Klerance turned in her term assignment for this challenge. Her professor was miffed (but also amused) when he overheard a disgruntled classmate of Summer's saying she got her answers by ...
DjinTonic's user avatar
  • 636
8 votes
7 answers
470 views

A Suitable Mission

Summer Klerance, a senior in college, is what her teachers refer to as GBL*. Students in her probability class have been assigned individual problems to work on and turn in as part of their final ...
DjinTonic's user avatar
  • 636
5 votes
10 answers
1k views

Odds that a string of N digits contains two or more of the same

I have to fill in 2fa codes all day. They're 6-digit strings. One day I noticed that not once did any of these codes contain 6 unique digits, like 198532 There was always at least one double, like ...
ToonAlfrink's user avatar
  • 1,304
13 votes
11 answers
2k views

Calculate the probability of getting to the target first (exactly)

Consider the following probability puzzle. We start with a string of bits all set to 0. At each step we choose a bit uniformly and independently at random and flip it. The value your code has to ...
user avatar
18 votes
14 answers
2k views

Lucky dice rolls

Lucky dice rolls In pen and paper roleplaying games dice are used for various chance calculations. The usual way to describe a roll is \$n\textbf{d}k\$ where \$n\$ is the number of dice and \$k\$ is ...
Gábor Fekete's user avatar
21 votes
15 answers
1k views

Penney-Conway odds

Background Penney's game is a two-player game about coin tossing. Player A announces a sequence of heads and tails of length \$n\$, then player B selects a different sequence of same length. The ...
Bubbler's user avatar
  • 77.5k

15 30 50 per page
1
2 3 4 5