At first I was mildly entertained with my initial attempts to solve Google's current puzzle, but after dozens of attempts I became feverishly determined to solve it. I finally decided to screw my manual attempts at a solution and coded a stupid brute force solver for it. The code is below and I just thought I'd provide it in the off chance that anyone else is interested, but don't run it if you want to solve the puzzle yourself or don't give a crap.

If you don't know what I'm talking about, my personalized google.com/ig page "Wei-Hwa's Puzzle Challenges" (which showed up automatically after the Da Vinci Code puzzles ended) currently has this:

Here's the code:Using the numbers 3, 3, 8, 8 (in any order), make a mathematical expression that equals 24. You can use only addition, subtraction, multiplication, and division (and parentheses), but in any order you wish. Note that you have to use all four numbers; otherwise 3 times 8 would be valid -- and that wouldn't be much of a puzzle, would it?

When you think you have an answer, try entering it here (use * for multiplication and / for division)

Code:#include<iostream>usingnamespacestd;enumAction { LEAF, ADD, SUB, DIV, MUL };structExprNode { ExprNode *left; ExprNode *right; Action action;intvalue; ExprNode(intvalue) : left(0), right(0), action(LEAF) {this->value = value; } ExprNode(ExprNode *left, ExprNode *right, Action action) : value(0) {this->left = left;this->right = right;this->action = action; }doubleeval() {switch(action) {caseLEAF:returnvalue;caseADD:returnleft->eval() + right->eval();caseSUB:returnleft->eval() - right->eval();caseDIV:returnleft->eval() / right->eval();caseMUL:returnleft->eval() * right->eval(); }return0; }friendostream&operator<<(ostream &out,constExprNode &rhs) {switch(rhs.action) {caseLEAF:returnout << rhs.value;caseADD:returnout << "(" << *rhs.left << " + " << *rhs.right << ")";caseSUB:returnout << "(" << *rhs.left << " - " << *rhs.right << ")";caseDIV:returnout << "(" << *rhs.left << " / " << *rhs.right << ")";caseMUL:returnout << "(" << *rhs.left << " * " << *rhs.right << ")"; }returnout; } };intmain() { Action actions[4] = { ADD, SUB, DIV, MUL };intvalues[4] = { 3, 3, 8, 8 };for(inti = 0; i < 4; ++i)for(intj = 0; j < 4; ++j)for(intk = 0; k < 4; ++k)for(intl = 0; l < 4; ++l) { // bypass duplicatesif(i == j || i == k || i == l || j == k || j == l || k == l)continue; ExprNode one (values[i]); ExprNode two (values[j]); ExprNode three(values[k]); ExprNode four (values[l]);for(intx = 0; x < 4; ++x) {for(inty = 0; y < 4; ++y) {for(intz = 0; z < 4; ++z) {for(inttype = 0; type < 5; ++type) {switch(type) { // ((a ? b) ? c) ? dcase0: { ExprNode AB(&one, &two, actions[x]); ExprNode ABC(&AB, &three, actions[y]); ExprNode ABCD(&ABC, &four, actions[z]);if(int(ABCD.eval()) == 24) cout << ABCD << " = " << ABCD.eval() << endl;break; } // (a ? b) ? (c ? d)case1: { ExprNode AB(&one, &two, actions[x]); ExprNode CD(&three, &four, actions[z]); ExprNode ABCD(&AB, &CD, actions[y]);if(actions[y] == DIV && CD.eval() == 0)break;if(int(ABCD.eval()) == 24) cout << ABCD << " = " << ABCD.eval() << endl;break; } // (a ? (b ? c)) ? dcase2: { ExprNode BC(&two, &three, actions[y]); ExprNode ABC(&one, &BC, actions[x]); ExprNode ABCD(&ABC, &four, actions[z]);if(actions[x] == DIV && BC.eval() == 0)break;if(int(ABCD.eval()) == 24) cout << ABCD << " = " << ABCD.eval() << endl;break; } // a ? ((b ? c) ? d)case3: { ExprNode BC(&two, &three, actions[y]); ExprNode BCD(&BC, &four, actions[z]); ExprNode ABCD(&one, &BCD, actions[x]);if(actions[x] == DIV && BCD.eval() == 0)break;if(int(ABCD.eval()) == 24) cout << ABCD << " = " << ABCD.eval() << endl;break; } // a ? (b ? (c ? d))case4: { ExprNode CD(&three, &four, actions[z]); ExprNode BCD(&two, &CD, actions[y]); ExprNode ABCD(&one, &BCD, actions[x]);if((actions[y] == DIV && CD.eval() == 0) || (actions[x] == DIV && BCD.eval() == 0))break;if(int(ABCD.eval()) == 24) cout << ABCD << " = " << ABCD.eval() << endl;break; } } } } } } }return0; }