Skip to content

Instantly share code, notes, and snippets.

@flatcap
Last active August 29, 2015 14:21
Show Gist options
  • Save flatcap/39d15a98ffdf8247c4a8 to your computer and use it in GitHub Desktop.
Save flatcap/39d15a98ffdf8247c4a8 to your computer and use it in GitHub Desktop.
Sunday Times Teaser 2747 (2015-05-17)
#!/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"
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