Enigmatic Code

Programming Enigma Puzzles

Enigma 1575: All our days

From New Scientist #2738, 12th December 2009 [link]

I have written the days of the week with their ordinal numbers as shown above.

Letters being consistently replaced by non-zero digits, each day is divisible by its own ordinal number (and by no higher digit).

What is the FAMOUS number?

[enigma1575]

Advertisements

One response to “Enigma 1575: All our days

  1. jimrandell 12 February 2012 at 10:53 pm

    The following Python program runs in 41ms.

    from itertools import permutations
    
    # there is only one possibility for each of F, W
    (F, W) = (5, 3)
    
    # U, H, A are even
    for (U, H, A) in permutations((2, 4, 6, 8), 3):
    
      d1 = set(range(1, 10)).difference((F, W, U, H, A))
      for (T, S) in permutations(d1, 2):
        (TU, TH) = (10*T + U, 10*T + H)
        if TH % 4 or not all(TH % n for n in range(5, 10)): continue
        if not all(TU % n for n in range(3, 10)): continue
        (SU, SA) = (10*S + U, 10*S + A)
        if SU % 7 or not all(SU % n for n in range(8, 10)): continue
        if SA % 6 or not all(SA % n for n in range(7, 10)): continue
    
        d2 = d1.difference((T, S))
        for (M, O) in permutations(d2, 2):
          MO = 10*M + O
          if not all(MO % n for n in range(2, 10)): continue
    
          print("FAMOUS", "=", F, A, M, O, U, S, sep='')
    

    Solution: FAMOUS = 528941.

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: