5 min read

Can You Decipher The Secret Message?

Table of Contents

Riddler Express

Max the Mathemagician is calling for volunteers. He has a magic wand of length 1010 that can be broken anywhere along its length (fractional and decimal lengths are allowed). After the volunteer chooses these breakpoints, Max will multiply the lengths of the resulting pieces. For example, if they break the wand near its midpoint and nowhere else, the resulting product is 5Γ—55Γ—5, or 2525. If the product is the largest possible, they will win a free backstage pass to his next show. (Amazing, right?)

You raise your hand to volunteer, and you and Max briefly make eye contact. As he calls you up to the stage, you know you have this in the bag. What is the maximum product you can achieve?

Extra credit: Zax the Mathemagician (no relation to Max) has the same routine in his show, only the wand has a length of 100100. What is the maximum product now?

Solution

Let LL be the length of the wand and let x1,x2,…,xnx_1,x_2,\dots,x_n be the lengths of the nn resulting pieces after the volunteer chooses the breakpoints. Using the famous Arithmetic-Geometric mean inequality AMβ‰₯GMAM \geq GM, we have

x1+β‹―+xnnβ‰₯(x1x2β‹―xn)1/nβ€…β€ŠβŸΉβ€…β€Š(Ln)nβ‰₯x1x2β‹―xn\begin{aligned} \frac{x_1+\dots+x_n}{n} &\geq (x_1x_2 \cdots x_n)^{1/n} \\\\ \implies \left(\frac{L}{n}\right)^n &\geq x_1x_2 \cdots x_n \end{aligned}

The equality is achieved when all the pieces are equal.

The function f(x)=(Lx)xf(x) = \left(\frac{L}{x}\right)^x attains its maximum value at x=Lex = \frac{L}{\mathrm{e}}. This can be verified using basic calculus.

As the wand can only be broken into an integral number of pieces, the maximum product is obtained at nβˆ—=⌊LeβŒ‹n^* = \left\lfloor \frac{L}{\mathrm{e}}\right\rfloor or nβˆ—=⌈LeβŒ‰n^* = \left\lceil \frac{L}{\mathrm{e}} \right\rceil.

The number of equal pieces required to achieve the maximum product when L=10L=10 is nβˆ—=⌈10eβŒ‰=4n^* = \left\lceil \frac{10}{\mathrm{e}} \right\rceil = 4 and the maximum product that can be achieved is (10/4)4=39.0625(10/4)^4 = \bf{39.0625}.

The number of equal pieces required to achieve the maximum product when L=100L=100 is nβˆ—=⌈100eβŒ‰=37n^* = \left\lceil \frac{100}{\mathrm{e}} \right\rceil = 37 and the maximum product that can be achieved is (100/37)37β‰ˆ9474061716781824(100/37)^{37} \approx \bf{9474061716781824}.

Riddler Classic

This week’s Classic comes courtesy of Alexander Zhang of Lynbrook High School, California. Alexander won first place in the mathematics category at this year’s International Science and Engineering Fair for his work at the intersection of topology and medicine. He developed his own highly efficient algorithms to detect and remove defects (like β€œhandles” or β€œtunnels”) from three-dimensional scans (e.g., MRI). Alexander has long had an interest in topology, which just might be related to his submitted puzzle.

Consider the following image showing a particular uppercase sans serif font:

Alexander thinks many of these letters are equivalent, but he leaves it to you to figure out how and why. He also has a message for you:

It may not look like much, but Alexander assures me that it is equivalent to exactly one word in the English language.

What is Alexander’s message?

Solution

Partitioning scheme 1

If alphabets are partitioned into equivalence classes such that two alphabets are in the same class when one can be continuously deformed into another, we have the following equivalence classes:

1 continous line - C,G,I,J,M,N,S,U,V,W,Z
1 hole with 1 dead end - P,Q
1 hole with 2 dead ends - A,R
2 holes - B
1 hole - D,O
3 dead ends - E,F,T,Y
4 dead ends - H,K,X

Partitioning scheme 2

If alphabets are partitioned into equivalence classes based on the number of non-overlapping continous strokes, we have the following three equivalence classes:

1 continuous stroke - C,D,G,I,J,L,M,N,O,P,Q,S,U,V,W,Z
2 non-overlapping continuous strokes - A,B,E,F,R,T,X,Y
3 non-overlapping continuous strokes - H,K

Using the code below, we see that YIRTHA can be decoded as EUREKA under partitioning scheme 1. Under paritioning scheme 2, YIRTHA can be decoded as APATHY, TWEAKY or EUREKA.

import urllib.request
DICT_URL = "https://norvig.com/ngrams/enable1.txt"

def load_dictionary(url):
    response = urllib.request.urlopen(url)
    return [l.decode('utf-8').strip().upper() for l in response.readlines()]

ALL_WORDS = load_dictionary(DICT_URL)

target_word = "YIRTHA"
relevant_words = [w for w in ALL_WORDS if len(w)==len(target_word)]
scheme1 = ['AR','B','CGIJMNSUVWZ','DO','EFTY','HKX','PQ']
scheme2 = ['ABEFRTXY','CDGIJLMNOPQSUVWZ','HK']

def decode(grouping):
    target_subgroups = []
    for l in target_word:
        for sg in grouping:
            if l in sg:
                target_subgroups.append(sg)
    matches = set()
    for word in relevant_words:
        if all([c in sg for c, sg in zip(word, target_subgroups)]):
                matches.add(word)
    return matches
    
print(decode(scheme1))
print(decode(scheme2))