Don't use your brain, let the computer do the work 😁
I was watching a TV contest where contestants needed to solve a simple math quiz. Six positive integers are given to get as close as possible to a given target number (usually larger) using arithmetic operations, where each number can only be used once at most. Sometimes there is a perfect match, other times the best shot is a few units away from the target. Any good solution is acceptable, but a solution with fewer numbers might be viewed as better. Since I had my laptop with me, I thought I could write a program to solve the questions faster than I could. But I needed to think about what that program looked like. And then, if my program works, another question would be if it will work fast enough. Finding a solution If we start with a simple problem, where we have just two numbers (a, b) and a target (t), the program could try if any of these (a+b), (a-b), (b-a), (a*b), (b/a), or (b/a) equals t. If we add a third number c, we could then try to combine it with any of the pr...