parking riddle
The Riddler of this week had a quick riddle: if one does want to avoid parallel parking a car over a six spot street, either the first spot is available or two consecutive spots are free. What is the probability this happens with 4 other cars already parked (at random)?
While a derivation by combinatorics easily returns 9/15 as the probability to fail to park, a straightforward R code does as well
l=0 for(t in 1:1e6){ k=sort(sample(0:5,4)) l=l+1*(!!k[1]|3%in%diff(k)|!k[4]%%3)}
since
> round(choose(6,2)*F/1e6) [1] 10
October 23, 2020 at 8:11 am
[…] article was first published on R â Xi'an's Og, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here) […]
October 23, 2020 at 7:18 am
[…] by data_admin [This article was first published on R â Xi’an’s Og, and kindly contributed to R-bloggers]. (You can report issue about the content on this page […]