Sunday Times Teaser 3078 – Digital Daisy-Chains
by Victor Bryant
Published Sunday September 19 2021 (link)
The number 798 is a “digital daisy-chain”; ie, if you spell out each of its digits as a word, then the last letter of each digit is the first letter of the next. Furthermore, the number 182 is a “looped” digital daisy-chain because, in addition, the last letter of its last digit is the first letter of its first digit.
I have written down a large looped digital daisy-chain (with fewer than a thousand digits!). The total of its digits is itself a digital daisy-chain.
What is that total?
2 Comments
Leave one →
-
Brian Gladman permalink12345678910111213141516171819202122232425262728293031323334353637dw = 'zero one two three four five six seven eight nine'.split()links = set((i, j) for j in range(10) for i in range(10) if dw[i][-1] == dw[j][0])# Allowed digit to digit transitions:## 0 -> 1 ; 1 -> 8; 2 -> 1; 3 -> 8; 5 -> 8; 7 -> 9; 8 -> 2 / 3; 9 -> 8## Looped digital daisy-chains (LDDCs) can only consist of two different# links: 8->2->1 and 8->3; since these both have a digit sum of eleven,# the digit sums of all LDDCs are multiples of eleven# 1. Look for digital daisy-chains in multiples of elevenn, dc = 0, 0while True:n += 11# find the digits ...dts = tuple(int(x) for x in str(n))# ... and check that each digit can follow its predecessorif all((x, y) in links for x, y in zip(dts, dts[1:])):print(f"Total = {n}.")# the looped daisy-chain has less than 1000 digits and# each multiple of 11 is the sum of at least two digitsif (dc := dc + 2) > 1000:break# 2. Alternatively consider two/three digit digital daisy-chainsfor (i, j) in links:m = 10 * i + jif not m % 11:print(f"Total = {m}.")for (k, l) in links:n = 10 * m + lif j == k and not n % 11:print(f"Total = {n}.")
-
Erling Torkildsen permalink123456789101112131415161718192021222324# Valid links in a 'daisy-chain'OK = {"01", "18", "21", "38", "58", "79", "82", "83", "98"}def is_daisy(n):s, l, j = str(n), len(str(n)), set()for i in range(l - 1):j.add(s[i] + s[i + 1] in OK)return all(j)# Structure 'looped daisy-chains' are head + body + tail## body = (8 + 3)*n or (8 + 2 + 1)*n ie allways 11*n## 1 + 11*n + 8 + 2 |# 2 + 1 + 11*n + 8 |# 3 + 11*n + 8 > 11*(n + 1)# 11*n + 8 + 3 |#for n in range(501):if is_daisy(11*(n + 1)):print("Total:", 11*(n + 1))