HomeHome More SamplesMore Samples

///////////////////////////////////////////////////////////////////////////////
// All our days
///////////////////////////////////////////////////////////////////////////////
// Enigma 1575 Adrian Somerfield, New Scientist magazine, December 12, 2009.
///////////////////////////////////////////////////////////////////////////////
//
// I have written the days of the week with their ordinal numbers as shown:
//
//  MO TU  W TH  F SA SU
//   1  2  3  4  5  6  7
//
// Letters being consistently replaced by non-zero digits, each day is 
// divisible by its own ordinal number (and by no higher digit). 
// Please send in the FAMOUS number.
//
///////////////////////////////////////////////////////////////////////////////
//
// Solve the problem by running the query:
//
//          all AllOurDays(famous)
//
///////////////////////////////////////////////////////////////////////////////
//
// Results:
//
// famous = 528941
// ___ Solution: 1 ___ [00:00:00] __ [Backtracks: 268] ____
//
// Number of solutions: 1   Number of backtracks: 3504
// Elapsed time: 00:00:00      
//
///////////////////////////////////////////////////////////////////////////////

local Digit = L[1..9]

pred AllOurDays(famous::L) iff
    m::Digit & o::Digit & t::Digit & u::Digit & w::Digit & 
    h::Digit & f::Digit & s::Digit & a::Digit &
    _AllDifferent(m,o,t,u,w,h,f,s,a) &
    day1 = 10*m + o & day1 mod 1 = 0 & NotDivisible(day1,2) & 
    day2 = 10*t + u & day2 mod 2 = 0 & NotDivisible(day2,3) & 
    day3 =        w & day3 mod 3 = 0 & NotDivisible(day3,4) & 
    day4 = 10*t + h & day4 mod 4 = 0 & NotDivisible(day4,5) & 
    day5 =        f & day5 mod 5 = 0 & NotDivisible(day5,6) & 
    day6 = 10*s + a & day6 mod 6 = 0 & NotDivisible(day6,7) & 
    day7 = 10*s + u & day7 mod 7 = 0 & NotDivisible(day7,8) & 

    famous = f*100000 + a*10000+m*1000+o*100+u*10 +s 
   
local pred NotDivisible(day::L,d:<L) iff
    if d <= 9 then
        day mod d <> 0 & NotDivisible(day,d+1)
    end




This page was created by F1toHTML