Halloween Sweets

1
2
3
4
5
6
function pick(bags, scale) {
var bagsinthrees=[[bags[0],bags[1],bags[2]],[bags[3],bags[4],bags[5]],[bags[6],bags[7],bags[8]]];
var whichthree=scale.weigh(bagsinthrees[0],bagsinthrees[2])+1;
var lmr=scale.weigh([bagsinthrees[whichthree][0]],[bagsinthrees[whichthree][2]])+1;
return bagsinthrees[whichthree][lmr];
};