Enigmatic Code

Programming Enigma Puzzles

Enigma 315: Phoney situations

From New Scientist #1463, 4th July 1985 [link]

I recently met a Continental employer who applies a painless IQ screening test to all prospective employees. His advertisements require that all candidates must ring-in on an ex-directory telephone — but the number to ring is published in a clandestine form.

Recruitment will soon be extended to Britain. New Scientist readers are privileged to preview this statement of the telephone number to be used:

(1) The international telephone number comprises three discrete groups of numerals. No group commences with the digit 0.

(2) The decimal number represented by the first group to be dialled is equal to the sum of all other digits in the number. The decimal number represented by the second group is the square root of the third group number.

(3) The first 10 numerals to be dialled include all the available digits from 0 to 9; the 11th (last) numeral repeats the 10th numeral.

Good luck with your applications! Please let us know the complete telephone number in correct dialling sequence before you sail.

[enigma315]

Advertisements

One response to “Enigma 315: Phoney situations

  1. Jim Randell 16 October 2015 at 8:13 am

    A bit of analysis brings the search space down to a reasonable size.

    This Python program runs in 38ms.

    # consider the number in the following groups:
    #
    #   n1 n2 n3
    #
    # altogether there are 11 digits, with one of the digits repeated
    #
    # n1 is the sum of the digits in n2 and n3
    #
    # so:
    #
    #   n1 < 45 + 9 = 54
    #
    #   n1 >= 45 - 18 = 27
    #
    # so n1 is two digits leaving 9 digits for n2 and n3
    # where n3 is the square of n2
    #
    # if n2 is 1 digit  then n3 is 1 or 2 digits (too short)
    # if n2 is 2 digits then n3 is 3 or 4 digits (too short)
    # if n2 is 3 digits then n3 is 5 or 6 digits (possible, 3 and 6)
    # if n2 is 4 digits than n3 is 7 ir 8 digits (too long)
    #
    # so n2 is 3 digits and n3 is 6 digits
    
    from enigma import irange, printf
    
    # start with n2
    for n2 in irange(317, 987):
      # n3 = n2 squared
      n3 = n2 * n2
    
      # n3 ends in 2 repeats of the same digit
      s3 = str(n3)
      if s3[-1] != s3[-2]: continue
    
      # n1 = sum of digits in n2 and n3
      s2 = str(n2)
      n1 = sum(int(d) for d in s2 + s3)
      s1 = str(n1)
    
      # altogether they are pandigital
      if len(set(s1 + s2 + s3)) != 10: continue
    
      printf("{n1} {n2} {n3}")
    

    Solution: The phone number is 38 712 506944.

    International calling code +387 is currently the number for Bosnia and Herzegovina. But when the puzzle was set in 1985 the +38 code was assigned to Yugoslavia.

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: