Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- _D = Dict{Tuple{Int,Int},Int}()
- # count number of ways to write 't' as sum of 'l' integers in [1,6]
- count = function(t,l)
- get!(_D,(t,l)) do
- if l < 1
- 0
- elseif l == 1
- 1 <= t <= 6 ? 1 : 0
- else
- sum(Array{Int}(map(i -> count(t-i,l-1), 1:6)))
- end
- end
- end
- expected_stopping_time = sum(map(l->l*(1//6)^l*sum(map(i->i*count(6+i,l-1),1:6)),3:13))
- # = 9136402849//2176782336 ≈ 4.19720552574348
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement