Page 1 of 1

11333 - Alphametics

Posted: Sun Nov 04, 2007 8:37 am
by sclo
I don't know why I keep getting TLE for this problem.
My method is to rearrange the equation so that there are no minus signs.
In the backtracking, I keep a upper and lower bound on the left and right sides, and I only continue if there can be a solution within the bounds.

Posted: Sun Nov 04, 2007 10:34 am
by baodog
Make sure you "cancel" out terms that does not matter.

Posted: Sat Dec 01, 2007 4:29 am
by slxst
The first time I tried to backtrack but I got discouraged because I supposed that I will never solve in time.

What I had in mind was to:

1- Count the number of characters in all the equation if is more than 10 then do nothing.
2- Backtrack trying to guess numbers from 0 to 9 for every non-replaced-yet character.

Like baodog said I think we could cancel terms before making the calculations.

It will be enough?

Posted: Sat Dec 01, 2007 8:07 am
by rio
I think just canceling its not enough. You must to prune somehow.