Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
New 21 Game
Bookmark
Recursive DP
Sliding Window
Input
n=8, k=6, maxPts=4
n=21, k=17, maxPts=10
n=6, k=1, maxPts=10
n=10, k=1 (instant win)
Custom
n
=
8
,
k
=
6
,
maxPts
=
4
dp
1
0
1
2
3
4
5
6
7
8
dp
1
0
1
2
3
4
5
6
7
8
dp
1
0
0.25
1
2
3
4
5
6
7
8
dp[1] += dp[0] / 4
dp
1
0
0.25
1
0.3125
2
0
3
4
5
6
7
8
score 3 is fed by scores 0..2
dp
1
0
0.25
1
0.3125
2
0.3906
3
0
4
5
6
7
8
score 4 is fed by scores 0..3
dp
1
0
0.25
1
0.3125
2
0.3906
3
0.4883
4
5
6
7
8
dp[4] += dp[3] / 4
dp
1
0
0.25
1
0.3125
2
0.3906
3
0.4883
4
0.1406
5
6
7
8
dp[5] += dp[2] / 4
dp
1
0
0.25
1
0.3125
2
0.3906
3
0.4883
4
0.3604
5
0.0781
6
7
8
dp[6] += dp[2] / 4
dp
1
0
0.25
1
0.3125
2
0.3906
3
0.4883
4
0.3604
5
0.3879
6
0
7
8
score 7 is fed by scores 3..5
dp
1
0
0.25
1
0.3125
2
0.3906
3
0.4883
4
0.3604
5
0.3879
6
0.3098
7
0
8
score 8 is fed by scores 4..5
dp
1
0
0.25
1
0.3125
2
0.3906
3
0.4883
4
0.3604
5
0.3879
6
0.3098
7
0.2122
8
stopping scores 6..8 add up to 0.90991
algo
master
.
io
Step:
New 21 Game: draw 1..4 points until score >= 6. Find P(final score <= 8).
0 / 35
Input
n=8, k=6, maxPts=4
n=21, k=17, maxPts=10
n=6, k=1, maxPts=10
n=10, k=1 (instant win)
Custom
n
=
8
,
k
=
6
,
maxPts
=
4
0 / 35
algo
master
.
io
Step:
New 21 Game: draw 1..4 points until score >= 6. Find P(final score <= 8).