You are viewing a single comment's thread from:
RE: Brainsteem #9 Prize Maths Puzzle [Win 40% and 10% in SBD]
since 1+2+.......+9 = 45, so all the permutations is divisible by 9.
The question can be reduced to divisible by 11.
This can be checked by d1+d2-d3+d4.....-d9
the range of the equation is -25 to 25
we can just hardcode to check -22,-11,11,22
matlab time:
allperm = perms(1:9);
reduced = allperm(:,1)-allperm(:,2)+allperm(:,3)-allperm(:,4)+allperm(:,5)-allperm(:,6)+allperm(:,7)-allperm(:,8)+allperm(:,9);
sum((reduced(:)==11)+(reduced(:)==-11)+(reduced(:)==-22)+(reduced(:)==22))/length(allperm)
ans = 11/126
11+126 = 137