Enigmatic Code

Programming Enigma Puzzles

Enigma 1590: Return to starter

From New Scientist #2755, 10th April 2010 [link]

If we take the three-digit number 999 and write it in words as NINE HUNDRED AND NINETY-NINE we can see that its four elements have 4, 7, 3 and 10 letters. If we multiply 4 × 7 × 3 × 10 we get 840, which is some way away from the 999 that we started with.

I invite you to find a three-digit number such that if you multiply together the number of letters in each of its four elements you get the number that you started with.

What is that three-digit number?

[enigma1590]

Advertisements

3 responses to “Enigma 1590: Return to starter

  1. jimrandell 23 January 2012 at 3:24 pm

    The following Python program runs in 34ms.

    # <a> hundred and <b>
    
    # len('hundred') = 7 and len('and') = 3, so we're looking for a 3 digit
    # multiple of 21
    
    from enigma import irange, printf
    
    numbers = {
      0: '',
      1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine',
      10: 'ten', 11: 'eleven', 12: 'twelve', 13: 'thirteen', 14: 'fourteen', 15: 'fifteen'
    }
    
    tens = {
      0: '', 1: 'teen', 2: 'twenty', 3: 'thirty', 4: 'forty',
      5: 'fifty', 6: 'sixty', 7: 'seventy', 8: 'eighty', 9: 'ninety'
    }
    
    for i in irange(5, 47):
      n = i * 21
      h = len(numbers[n // 100])
      if i % h: continue
      c = n % 100
      if c in numbers:
        l = len(numbers[c])
      else:
        l = len(tens[c // 10]) + len(numbers[c % 10])
      if l !=  i // h: continue
    
    
      (h, t, u) = (numbers[n // 100], tens[c // 10], numbers[c % 10])
      printf("{n}: {h} hundred and {t}-{u} -> {lh} x 7 x 3 x {lc} = {p}", lh=len(h), lc=len(t)+len(u), p=21*len(h)*(len(t)+len(u)))
    

    Solution: The number is 693.

  2. myrandommeanderings 31 March 2012 at 9:42 pm

    Hey, I blogged this problem also! Loved it – see my blog for my thoughts and workings :0) x

    • Jim Randell 6 April 2012 at 8:52 pm

      That’s neat. Enigma puzzles are – of course – meant to be solved without a computer, but I like to use them as a weekly programming challenge that’s shouldn’t take up too much time, although sometimes there are Enigma puzzles published that are easier to solve with a pencil and paper than a computer (usually those involving cutting up or folding pieces of paper). But I try to make a program that produces a constructive solution, and usually does an exhaustive search of the solution space to make sure I’ve found a possible solutions.

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: