Consider $\frac{abc-defc+fagh-iafg}{6}=337$ ($abc$ means $100a+10b+c.$ Find the maximum value of $iafg.$

71 Views Asked by At

$\frac{abc-defc+fagh-iafg}{6}=337$

The string of letters are numbers so when the equation had $fagh$ it represents $1000f+100a+10g+h.$ Try to find the maximum of $iafg.$ Good luck!

1

There are 1 best solutions below

3
On BEST ANSWER

I'll answer this because it doesn't take too long and I think the technique is worth seeing. This and similar problems can be slaughtered with integer programming, which is implemented in sage, for instance.

Given linear constraints, we can efficiently maximize a linear target function. If we add bonus constraints that some variables should only be allowed integer values, then the worst case difficulty skyrockets, but many problems (particularly those as small as this) can still be quickly solved in practice.

As an example, here's the sage code for this particular problem, which I think is self explanatory. It solves the problem in roughly $4$ milliseconds.

p = MixedIntegerLinearProgram()
v = p.new_variable(integer=True, nonnegative=True)
a,b,c,d,e,f,g,h,i = v['a'], v['b'], v['c'], v['d'], v['e'], v['f'], v['g'], v['h'], v['i']

p.add_constraint(a <= 9)
p.add_constraint(b <= 9)
p.add_constraint(c <= 9)
p.add_constraint(d <= 9)
p.add_constraint(e <= 9)
p.add_constraint(f <= 9)
p.add_constraint(g <= 9)
p.add_constraint(h <= 9)
p.add_constraint(i <= 9)

p.add_constraint((100*a+10*b+c) - (1000*d+100*e+10*f+c) + (1000*f+100*a+10*g+h) - (1000*i+100*a+10*f+g) == 337*6)

# this is the value we're maximizing
p.set_objective(1000*i + 100*a + 10*f + g)

# this computes the maximum
p.solve()

Since you've listed this as a problem for us to solve, rather than something you want help with, I'll leave the output of p.solve() under a fold.

7999 $$\frac{920 - 0890 + 9991 - 7999}{6} = 337$$


I hope this helps ^_^