Home More Samples
```
///////////////////////////////////////////////////////////////////////////////
// Back to front
///////////////////////////////////////////////////////////////////////////////
// Enigma 1535 Bob Walker, New Scientist magazine, March 7, 2009.
///////////////////////////////////////////////////////////////////////////////
//
// Joe has found that just a few numbers have a rather unique property.
// Reverse the order of the digits, and the new number is a multiple of the
// original. For some specified numbers of digits (four or more) there are only
// two numbers with the property.
//
// Joe gave Penny the task of finding the two 6-digit numbers.
// What is the lower 6-digit number?
//
//
///////////////////////////////////////////////////////////////////////////////
//
// Solve the problem by running the query:
//
//       all Enigma1535(y)
//
///////////////////////////////////////////////////////////////////////////////
//
// Results:
//
// y = 109989
// ___ Solution: 1 __________________________________
//
// y = 219978
// ___ Solution: 2 __________________________________
//
// Number of solutions: 2   Number of backtracks: 809998
// Elapsed time: 00:00:00
//
///////////////////////////////////////////////////////////////////////////////

local Di09 = I[0..9]
local Di19 = I[1..9]

pred Enigma1535(y::I) iff
z::I & x1::Di19 & x2::Di09 & x3::Di09 & x4::Di09 & x5::Di09 & x6::Di19 &
y = x1*100000 + x2*10000 + x3*1000 + x4*100 + x5*10 + x6 &
z = x6*100000 + x5*10000 + x4*1000 + x3*100 + x2*10 + x1 &
y <> z & z mod y = 0

```