Home More Samples
```
///////////////////////////////////////////////////////////////////////////////
// Eight times
///////////////////////////////////////////////////////////////////////////////
// Enigma 1317 Richard England, New Scientist magazine
///////////////////////////////////////////////////////////////////////////////
// I invite you to find a 5-digit number consisting of five different digits
// (not starting with zero) which when multiplied by 8 produces another 5-digit
// number consisting of the other 5-digits; in addition the sum of the digits of
// your 5-digit number must be greater than the sum of the digits of the product.
//
// Which 5-digit number have you found? (Remember that the answer required is
// the number as it was before the multiplication.)
//
///////////////////////////////////////////////////////////////////////////////
//
// Solve the problem by running the query:
//
//          all EightTimes(x)
//
///////////////////////////////////////////////////////////////////////////////
//
// Results:
//
// x = 10679
// ___ Solution: 1 ___ [00:00:00] __ [Backtracks: 1775] ____
//
// Number of solutions: 1   Number of backtracks: 2218
// Elapsed time: 00:00:00
//
///////////////////////////////////////////////////////////////////////////////

pred EightTimes(x::L) iff
a::[0..9]->>L[0..9] & a = [x1,x2,x3,x4,x5,y1,y2,y3,y4,y5] &
x1 <> 0 & y1 <> 0 &
x   = x1*10000 + x2*1000 + x3*100 + x4*10 + x5 &
x*8 = y1*10000 + y2*1000 + y3*100 + y4*10 + y5 &
x1 + x2 + x3 + x4 + x5 > y1 + y2 + y3 + y4 + y5

```