I presume we're allowed fractional results and aren't restricted to integer division? If I'm wrong them I'm really baffled as to what the solution could be but I've got it otherwise
Did you get this puzzle from "Hacking - The Art of Exploitation" ?
No, a friend posed it. (I don't know where he got it from though). I quite like this type of puzzle (using four number to make 24), I have in the past used four ten sided dice to give me random numbers and then try to make 24 without knowing if it is possible.
Are there only one solution to this? I think I bruteforced all possible combinations, I'm just not sure.
I would be interested in clever algorithms too, but I don't think it exists. Anyway, my bruteforce 'algorithm' has to check 5184 combinations, which is not too much.
Well I'm baffled. Mainly because of quirkyusername's hint
I presume we're allowed fractional results and aren't restricted to integer division?
I'm failing to see how division could be used in a solution, other than to throw out the 1.
I mean both 6*4/3 and 6*3/4 put you well under 24.
Even if you add 1 to the numerator to push it up as high as possible, dividing still leaves you way short of the goal:
6*(4+1)/3 = 10
6*(3+1)/4 = 6
The way I see it, 6 has to be somehow involved in a multiplication (either before or after you add to it). There's no way to get up to 24 otherwise. But I can't seem to figure it out. Closest I can get is 25.
Well yeah -- but that doesn't really make sense. There's still division involved.
I mean x/(y/z) is the same as (x*z)/y. So either way you have a division by y. So unless y is 1 and you're just dividing by it to throw it out, that division seems to make it impossible to get up to 24. Even if you multiply every other number.
I'm not doubting you. I mean I'm sure there's a solution. I'm just not seeing it.
EDIT: I should also mention I'm bad at these kinds of puzzles. =P
I probably wouldn't have gotten it if I hadn't been practicing this sort of thing so much recently, I've had several job interviews for programming positions and problem solving puzzles crop up a lot.