Skip to content

Instantly share code, notes, and snippets.

@krishnanraman
Created February 3, 2024 00:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krishnanraman/cccd1d0a640cf25903a5d576c10588f3 to your computer and use it in GitHub Desktop.
Save krishnanraman/cccd1d0a640cf25903a5d576c10588f3 to your computer and use it in GitHub Desktop.
AIME 2024 4
x<-0:9
n<-4
N<-100000
atleasttwomatch<- 0
allfourmatch<-0
for(i in 1:N) {
a<-sample(x,n)
b<-sample(x,n)
s<-length(a[is.element(a, b)])
if (s > 1) {
atleasttwomatch <- atleasttwomatch+1
if (s == n) {
allfourmatch <- allfourmatch + 1
}
}
}
print(allfourmatch/atleasttwomatch)
https://artofproblemsolving.com/wiki/index.php/2024_AIME_I_Problems/Problem_4
> 1/115
[1] 0.008695652
Above code gives:
[1] 0.008576799
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment