Created
February 3, 2024 00:44
-
-
Save krishnanraman/cccd1d0a640cf25903a5d576c10588f3 to your computer and use it in GitHub Desktop.
AIME 2024 4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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