Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This Problem Stumped Vietnamese Students - Solution To Viral Puzzler https://www.youtube.com/watch?v=WiB2_dXSSMg
# runs in about 10s on my 1.1GHz MacBook.
equation = "x+13*x/x+x+12*x-x-11+x*x/x-10==66".gsub("x", "%.1f")
puts (1..9).to_a.permutation.map{|nums|equation%nums}.select{|eq| eval(eq)}
1.0+13*2.0/6.0+4.0+12*7.0-8.0-11+3.0*5.0/9.0-10==66.0
1.0+13*2.0/6.0+4.0+12*7.0-8.0-11+5.0*3.0/9.0-10==66.0
1.0+13*3.0/2.0+4.0+12*5.0-8.0-11+7.0*9.0/6.0-10==66.0
1.0+13*3.0/2.0+4.0+12*5.0-8.0-11+9.0*7.0/6.0-10==66.0
1.0+13*3.0/2.0+9.0+12*5.0-6.0-11+4.0*7.0/8.0-10==66.0
1.0+13*3.0/2.0+9.0+12*5.0-6.0-11+7.0*4.0/8.0-10==66.0
1.0+13*3.0/4.0+7.0+12*6.0-5.0-11+2.0*9.0/8.0-10==66.0
1.0+13*3.0/4.0+7.0+12*6.0-5.0-11+9.0*2.0/8.0-10==66.0
1.0+13*3.0/6.0+2.0+12*7.0-9.0-11+4.0*5.0/8.0-10==66.0
1.0+13*3.0/6.0+2.0+12*7.0-9.0-11+5.0*4.0/8.0-10==66.0
1.0+13*3.0/9.0+4.0+12*7.0-8.0-11+2.0*5.0/6.0-10==66.0
1.0+13*3.0/9.0+4.0+12*7.0-8.0-11+5.0*2.0/6.0-10==66.0
1.0+13*4.0/8.0+2.0+12*7.0-9.0-11+3.0*5.0/6.0-10==66.0
1.0+13*4.0/8.0+2.0+12*7.0-9.0-11+5.0*3.0/6.0-10==66.0
1.0+13*5.0/2.0+3.0+12*4.0-8.0-11+7.0*9.0/6.0-10==66.0
1.0+13*5.0/2.0+3.0+12*4.0-8.0-11+9.0*7.0/6.0-10==66.0
1.0+13*5.0/2.0+8.0+12*4.0-7.0-11+3.0*9.0/6.0-10==66.0
1.0+13*5.0/2.0+8.0+12*4.0-7.0-11+9.0*3.0/6.0-10==66.0
1.0+13*5.0/3.0+9.0+12*4.0-2.0-11+7.0*8.0/6.0-10==66.0
1.0+13*5.0/3.0+9.0+12*4.0-2.0-11+8.0*7.0/6.0-10==66.0
1.0+13*9.0/6.0+4.0+12*5.0-8.0-11+3.0*7.0/2.0-10==66.0
1.0+13*9.0/6.0+4.0+12*5.0-8.0-11+7.0*3.0/2.0-10==66.0
1.0+13*9.0/6.0+7.0+12*5.0-2.0-11+3.0*4.0/8.0-10==66.0
1.0+13*9.0/6.0+7.0+12*5.0-2.0-11+4.0*3.0/8.0-10==66.0
2.0+13*1.0/4.0+3.0+12*7.0-9.0-11+5.0*6.0/8.0-10==66.0
2.0+13*1.0/4.0+3.0+12*7.0-9.0-11+6.0*5.0/8.0-10==66.0
2.0+13*3.0/6.0+1.0+12*7.0-9.0-11+4.0*5.0/8.0-10==66.0
2.0+13*3.0/6.0+1.0+12*7.0-9.0-11+5.0*4.0/8.0-10==66.0
2.0+13*4.0/8.0+1.0+12*7.0-9.0-11+3.0*5.0/6.0-10==66.0
2.0+13*4.0/8.0+1.0+12*7.0-9.0-11+5.0*3.0/6.0-10==66.0
2.0+13*8.0/6.0+9.0+12*4.0-1.0-11+5.0*7.0/3.0-10==66.0
2.0+13*8.0/6.0+9.0+12*4.0-1.0-11+7.0*5.0/3.0-10==66.0
2.0+13*9.0/6.0+3.0+12*5.0-1.0-11+4.0*7.0/8.0-10==66.0
2.0+13*9.0/6.0+3.0+12*5.0-1.0-11+7.0*4.0/8.0-10==66.0
3.0+13*1.0/4.0+2.0+12*7.0-9.0-11+5.0*6.0/8.0-10==66.0
3.0+13*1.0/4.0+2.0+12*7.0-9.0-11+6.0*5.0/8.0-10==66.0
3.0+13*2.0/1.0+5.0+12*4.0-7.0-11+8.0*9.0/6.0-10==66.0
3.0+13*2.0/1.0+5.0+12*4.0-7.0-11+9.0*8.0/6.0-10==66.0
3.0+13*2.0/4.0+8.0+12*5.0-1.0-11+7.0*9.0/6.0-10==66.0
3.0+13*2.0/4.0+8.0+12*5.0-1.0-11+9.0*7.0/6.0-10==66.0
3.0+13*2.0/8.0+6.0+12*5.0-1.0-11+7.0*9.0/4.0-10==66.0
3.0+13*2.0/8.0+6.0+12*5.0-1.0-11+9.0*7.0/4.0-10==66.0
3.0+13*5.0/2.0+1.0+12*4.0-8.0-11+7.0*9.0/6.0-10==66.0
3.0+13*5.0/2.0+1.0+12*4.0-8.0-11+9.0*7.0/6.0-10==66.0
3.0+13*6.0/4.0+9.0+12*5.0-8.0-11+1.0*7.0/2.0-10==66.0
3.0+13*6.0/4.0+9.0+12*5.0-8.0-11+7.0*1.0/2.0-10==66.0
3.0+13*9.0/2.0+8.0+12*1.0-5.0-11+6.0*7.0/4.0-10==66.0
3.0+13*9.0/2.0+8.0+12*1.0-5.0-11+7.0*6.0/4.0-10==66.0
3.0+13*9.0/6.0+2.0+12*5.0-1.0-11+4.0*7.0/8.0-10==66.0
3.0+13*9.0/6.0+2.0+12*5.0-1.0-11+7.0*4.0/8.0-10==66.0
4.0+13*2.0/6.0+1.0+12*7.0-8.0-11+3.0*5.0/9.0-10==66.0
4.0+13*2.0/6.0+1.0+12*7.0-8.0-11+5.0*3.0/9.0-10==66.0
4.0+13*3.0/2.0+1.0+12*5.0-8.0-11+7.0*9.0/6.0-10==66.0
4.0+13*3.0/2.0+1.0+12*5.0-8.0-11+9.0*7.0/6.0-10==66.0
4.0+13*3.0/9.0+1.0+12*7.0-8.0-11+2.0*5.0/6.0-10==66.0
4.0+13*3.0/9.0+1.0+12*7.0-8.0-11+5.0*2.0/6.0-10==66.0
4.0+13*9.0/6.0+1.0+12*5.0-8.0-11+3.0*7.0/2.0-10==66.0
4.0+13*9.0/6.0+1.0+12*5.0-8.0-11+7.0*3.0/2.0-10==66.0
5.0+13*1.0/2.0+9.0+12*6.0-7.0-11+3.0*4.0/8.0-10==66.0
5.0+13*1.0/2.0+9.0+12*6.0-7.0-11+4.0*3.0/8.0-10==66.0
5.0+13*2.0/1.0+3.0+12*4.0-7.0-11+8.0*9.0/6.0-10==66.0
5.0+13*2.0/1.0+3.0+12*4.0-7.0-11+9.0*8.0/6.0-10==66.0
5.0+13*3.0/1.0+7.0+12*2.0-6.0-11+8.0*9.0/4.0-10==66.0
5.0+13*3.0/1.0+7.0+12*2.0-6.0-11+9.0*8.0/4.0-10==66.0
5.0+13*4.0/1.0+9.0+12*2.0-7.0-11+3.0*8.0/6.0-10==66.0
5.0+13*4.0/1.0+9.0+12*2.0-7.0-11+8.0*3.0/6.0-10==66.0
5.0+13*4.0/8.0+9.0+12*6.0-7.0-11+1.0*3.0/2.0-10==66.0
5.0+13*4.0/8.0+9.0+12*6.0-7.0-11+3.0*1.0/2.0-10==66.0
5.0+13*7.0/2.0+8.0+12*3.0-9.0-11+1.0*6.0/4.0-10==66.0
5.0+13*7.0/2.0+8.0+12*3.0-9.0-11+6.0*1.0/4.0-10==66.0
5.0+13*9.0/3.0+6.0+12*2.0-1.0-11+7.0*8.0/4.0-10==66.0
5.0+13*9.0/3.0+6.0+12*2.0-1.0-11+8.0*7.0/4.0-10==66.0
6.0+13*2.0/8.0+3.0+12*5.0-1.0-11+7.0*9.0/4.0-10==66.0
6.0+13*2.0/8.0+3.0+12*5.0-1.0-11+9.0*7.0/4.0-10==66.0
6.0+13*3.0/1.0+9.0+12*2.0-5.0-11+7.0*8.0/4.0-10==66.0
6.0+13*3.0/1.0+9.0+12*2.0-5.0-11+8.0*7.0/4.0-10==66.0
6.0+13*9.0/3.0+5.0+12*2.0-1.0-11+7.0*8.0/4.0-10==66.0
6.0+13*9.0/3.0+5.0+12*2.0-1.0-11+8.0*7.0/4.0-10==66.0
7.0+13*1.0/4.0+9.0+12*6.0-5.0-11+2.0*3.0/8.0-10==66.0
7.0+13*1.0/4.0+9.0+12*6.0-5.0-11+3.0*2.0/8.0-10==66.0
7.0+13*2.0/8.0+9.0+12*6.0-5.0-11+1.0*3.0/4.0-10==66.0
7.0+13*2.0/8.0+9.0+12*6.0-5.0-11+3.0*1.0/4.0-10==66.0
7.0+13*3.0/1.0+5.0+12*2.0-6.0-11+8.0*9.0/4.0-10==66.0
7.0+13*3.0/1.0+5.0+12*2.0-6.0-11+9.0*8.0/4.0-10==66.0
7.0+13*3.0/2.0+8.0+12*5.0-9.0-11+1.0*6.0/4.0-10==66.0
7.0+13*3.0/2.0+8.0+12*5.0-9.0-11+6.0*1.0/4.0-10==66.0
7.0+13*3.0/4.0+1.0+12*6.0-5.0-11+2.0*9.0/8.0-10==66.0
7.0+13*3.0/4.0+1.0+12*6.0-5.0-11+9.0*2.0/8.0-10==66.0
7.0+13*5.0/2.0+8.0+12*4.0-9.0-11+1.0*3.0/6.0-10==66.0
7.0+13*5.0/2.0+8.0+12*4.0-9.0-11+3.0*1.0/6.0-10==66.0
7.0+13*6.0/4.0+8.0+12*5.0-9.0-11+1.0*3.0/2.0-10==66.0
7.0+13*6.0/4.0+8.0+12*5.0-9.0-11+3.0*1.0/2.0-10==66.0
7.0+13*9.0/6.0+1.0+12*5.0-2.0-11+3.0*4.0/8.0-10==66.0
7.0+13*9.0/6.0+1.0+12*5.0-2.0-11+4.0*3.0/8.0-10==66.0
8.0+13*2.0/4.0+3.0+12*5.0-1.0-11+7.0*9.0/6.0-10==66.0
8.0+13*2.0/4.0+3.0+12*5.0-1.0-11+9.0*7.0/6.0-10==66.0
8.0+13*3.0/2.0+7.0+12*5.0-9.0-11+1.0*6.0/4.0-10==66.0
8.0+13*3.0/2.0+7.0+12*5.0-9.0-11+6.0*1.0/4.0-10==66.0
8.0+13*5.0/2.0+1.0+12*4.0-7.0-11+3.0*9.0/6.0-10==66.0
8.0+13*5.0/2.0+1.0+12*4.0-7.0-11+9.0*3.0/6.0-10==66.0
8.0+13*5.0/2.0+7.0+12*4.0-9.0-11+1.0*3.0/6.0-10==66.0
8.0+13*5.0/2.0+7.0+12*4.0-9.0-11+3.0*1.0/6.0-10==66.0
8.0+13*6.0/4.0+7.0+12*5.0-9.0-11+1.0*3.0/2.0-10==66.0
8.0+13*6.0/4.0+7.0+12*5.0-9.0-11+3.0*1.0/2.0-10==66.0
8.0+13*7.0/2.0+5.0+12*3.0-9.0-11+1.0*6.0/4.0-10==66.0
8.0+13*7.0/2.0+5.0+12*3.0-9.0-11+6.0*1.0/4.0-10==66.0
8.0+13*9.0/2.0+3.0+12*1.0-5.0-11+6.0*7.0/4.0-10==66.0
8.0+13*9.0/2.0+3.0+12*1.0-5.0-11+7.0*6.0/4.0-10==66.0
9.0+13*1.0/2.0+5.0+12*6.0-7.0-11+3.0*4.0/8.0-10==66.0
9.0+13*1.0/2.0+5.0+12*6.0-7.0-11+4.0*3.0/8.0-10==66.0
9.0+13*1.0/4.0+7.0+12*6.0-5.0-11+2.0*3.0/8.0-10==66.0
9.0+13*1.0/4.0+7.0+12*6.0-5.0-11+3.0*2.0/8.0-10==66.0
9.0+13*2.0/8.0+7.0+12*6.0-5.0-11+1.0*3.0/4.0-10==66.0
9.0+13*2.0/8.0+7.0+12*6.0-5.0-11+3.0*1.0/4.0-10==66.0
9.0+13*3.0/1.0+6.0+12*2.0-5.0-11+7.0*8.0/4.0-10==66.0
9.0+13*3.0/1.0+6.0+12*2.0-5.0-11+8.0*7.0/4.0-10==66.0
9.0+13*3.0/2.0+1.0+12*5.0-6.0-11+4.0*7.0/8.0-10==66.0
9.0+13*3.0/2.0+1.0+12*5.0-6.0-11+7.0*4.0/8.0-10==66.0
9.0+13*4.0/1.0+5.0+12*2.0-7.0-11+3.0*8.0/6.0-10==66.0
9.0+13*4.0/1.0+5.0+12*2.0-7.0-11+8.0*3.0/6.0-10==66.0
9.0+13*4.0/8.0+5.0+12*6.0-7.0-11+1.0*3.0/2.0-10==66.0
9.0+13*4.0/8.0+5.0+12*6.0-7.0-11+3.0*1.0/2.0-10==66.0
9.0+13*5.0/3.0+1.0+12*4.0-2.0-11+7.0*8.0/6.0-10==66.0
9.0+13*5.0/3.0+1.0+12*4.0-2.0-11+8.0*7.0/6.0-10==66.0
9.0+13*6.0/4.0+3.0+12*5.0-8.0-11+1.0*7.0/2.0-10==66.0
9.0+13*6.0/4.0+3.0+12*5.0-8.0-11+7.0*1.0/2.0-10==66.0
9.0+13*8.0/6.0+2.0+12*4.0-1.0-11+5.0*7.0/3.0-10==66.0
9.0+13*8.0/6.0+2.0+12*4.0-1.0-11+7.0*5.0/3.0-10==66.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.