Last active
August 29, 2015 14:21
-
-
Save flatcap/39d15a98ffdf8247c4a8 to your computer and use it in GitHub Desktop.
Sunday Times Teaser 2747 (2015-05-17)
This file contains 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
#!/bin/bash | |
for sum in {399..350..-1}; do | |
for red in {4..200}; do | |
blue=$((sum-red)) | |
num1=$red | |
den1=$((blue+red)) | |
num2=$((red-1)) | |
den2=$((blue+red-1)) | |
num3=$((red-2)) | |
den3=$((blue+red-2)) | |
num4=$((red-3)) | |
den4=$((blue+red-3)) | |
echo "$red Red + $blue Blue = $sum" | |
echo "($den1*$den2*$den3*$den4)/($num1*$num2*$num3*$num4)" | bc -l | |
done | |
done | grep -B1 "\<[0-9]\{4\}\.000000" |
This file contains 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
nearly 400 marbles | |
some red, rest blue | |
400 > (red+blue) > 350 | |
red < blue | |
select 4 marbles | |
probability of all four being red is 1/X | |
where X is a 4 digit integer | |
How many red marbles? | |
How many blue marbles? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment