Enigmatic Code

Programming Enigma Puzzles

Enigma 1031: Security

From New Scientist #2187, 22nd May 1999 [link]

George’s new office has a security lock in which you have to key in a series of digits — all different — before you can open the door. Unfortunately, George is having difficulty committing this security number to memory.

So far, he has memorised a number comprising a selection of different digits from the security number. He has made a note of the memorised number on the memo sheet on which he was given the security number.

After studying the sequence yet again, he absent-mindedly left the memo lying around his house. When his wife found the piece of paper bearing just two numbers, she thought George has been trying to devise an “Alphametic” Enigma for New Scientist. Just for fun, she multiplied the numbers together and found that the product was a seven-digit number in which all the digits are the same.

What is George’s office security number?


One response to “Enigma 1031: Security

  1. Jim Randell 21 December 2018 at 7:54 am

    This Python program runs in 85ms.

    Run: [ @repl.it ]

    from enigma import irange, repdigit, divisor_pairs, int2base, is_duplicate, printf
    # consider 7-digit repdigits
    for d in irange(1, 9):
      n = repdigit(7, d)
      # consider divisors of n (as strings)
      for ab in divisor_pairs(n):
        (a, b) = map(int2base, ab)
        # both numbers consist of distinct digits
        if is_duplicate(a) or is_duplicate(b): continue
        # and the digits in a are a subset of those in b
        if not set(a).issubset(b): continue
        # output solution (required answer is b)
        printf("{b} x {a} = {n}")

    Solution: George’s security number is: 37192.

    The number George has memorised is 239.

    239 × 37192 = 8888888

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: