Enigmatic Code

Programming Enigma Puzzles

Enigma 1368: Dutch squares

From New Scientist #2527, 26th November 2005

Een, vier and negen are the Dutch for 1, 4 and 9; so it is appropriate that I can make the following statement:

EEN, VIER and NEGEN are perfect squares.

In this statement digits have been consistently replaced by capital letters, different letters being used for different digits. No number starts with a zero.

Find the numerical value of the square root of (EEN × VIER × NEGEN).



One response to “Enigma 1368: Dutch squares

  1. Jim Randell 1 December 2013 at 7:58 am

    This Python program runs in 35ms.

    from itertools import permutations
    from enigma import irange, is_square, printf
    digits = set('0123456789')
    # find 3-digit squares matching EEN
    for i in irange(10, 31):
      EEN = str(i * i)
      (E, E2, N) = EEN
      if not(E == E2 and E != N): continue
      # now consider values for NEGEN
      d1 = digits.difference([E, N])
      for G in d1:
        NEGEN = int(N + E + G + E + N)
        j = is_square(NEGEN)
        if j is None: continue
        # and VIER
        d2 = d1.difference([G])
        for (V, I, R) in permutations(d2, 3):
          VIER = int(V + I + E + R)
          k = is_square(VIER)
          if k is None: continue
          # compute the answer
          s = i * j * k
          printf("s={s} [EEN={EEN} NEGEN={NEGEN} VIER={VIER}]")

    Solution: The square root of (EEN × VIER × NEGEN) is 144837

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: