Enigmatic Code

Programming Enigma Puzzles

Enigma 1701: Lit up

From New Scientist #2868, 9th June 2012 [link]

The display on my calculator shows 9876543210.

As usual, up to seven illuminated strips are used to display each digit – the 8 using all seven, for example. There is just one special 10-figure number with the property that it is a perfect power of the total number of illuminated strips that it uses.

With a little calculator effort it is possible to answer the following: How many illuminated strips does this special 10-figure number use?

[enigma1701]

6 responses to “Enigma 1701: Lit up”

1. Jim Randell 6 June 2012 at 6:51 pm

The following Python program runs in 38ms.

In order to get a solution I have to assume a 3-segment “7” (rather than the 4-segment “7” that my old Casio calculator actually displays). Choosing 5-segment “6” and “9” digits (rather than the more usual 6-segment display) does not affect the solution.

```from itertools import count
from math import log, ceil
from enigma import irange, printf

# map digits to the number of segments used
#           0  1  2  3  4  5  6  7  8  9
segment = [ 6, 2, 5, 5, 4, 5, 6, 3, 7, 6 ]

# the minimum segment sum for a 10-digit number is 20
# and the maximum is 70
for a in irange(20, 70):
for b in count(int(ceil(log(1000000000, a)))):
n = str(pow(a, b))
if len(n) > 10: break

s = sum(segment[int(x)] for x in n)
if s != a: continue

printf("s = {s} [n = {n} = {a}^{b}]")
```

Solution: The number illuminates 41 segments of the display.

• arthurvause 6 June 2012 at 8:25 pm

I was puzzled as to why I wasn’t getting any solution with a 4-segment 7.
I get the same result: one solution with a 3-segment 7, no solution with 4-segment 7.

```for s in range(2,71):
for n in range(2,40):
num=s**n
st=str(num)
if len(st)==10 :
seg=0
for i in range(10):
if st[i]=='1': seg+=2
if st[i]=='2': seg+=5
if st[i]=='3': seg+=5
if st[i]=='4': seg+=4
if st[i]=='5': seg+=5
if st[i]=='6': seg+=6
if st[i]=='7': seg+=3
if st[i]=='8': seg+=7
if st[i]=='9': seg+=6
if st[i]=='0': seg+=6
if seg == s:
print num
```
• Jim Randell 8 June 2012 at 3:45 pm

Now I have my paper copy of the magazine there is a diagram showing the digits, and it makes clear that a 3-segment “7” is used (and 6-segment “6” and “9”). I have updated the question to the show the arrangement of the digits.

• arthurvause 8 June 2012 at 7:31 pm

Ah, that explains it. I was wondering whether the original specified the display.

• Hugh Casement 18 March 2016 at 7:23 am

Looking at numbers with fewer than ten digits I found
130691232 = 42^5
1336336 = 34^4, 1500625 = 35^4, 2560000 = 40^4.
These don’t depend on a three-segment 7 (normal for clocks but not calculators, for reasons that are lost on me).  I’ve never heard them called “illuminated strips”!

2. Brian Gladman 6 June 2012 at 9:40 pm

Here is mine:

```
# map digits to the number of lit segments
d = { '0':6, '1':2, '2':5, '3':5, '4':4, '5':5, '6':6, '7':3, '8':7, '9':6 }
# consider the possible numbers of lit strips for a 10 digit number
for lit in range(20, 71):
# now compute powers of 'lit' and check any 10 digit results
nbr, pwr = 1, 0
while nbr < 10 ** 10:
nbr, pwr = nbr * lit, pwr + 1
# does this number have 10 digits and the right number of lit strips?
if nbr >= 10 ** 9 and sum(d[c] for c in str(nbr)) == lit:
print('{0:d} ({0:d}^{1:d} -> {2:d})'.format(lit, pwr, nbr))
```