Instantly share code, notes, and snippets.

# codepo8/OldschoolTypes.md

Last active November 23, 2023 09:57
Show Gist options
• Save codepo8/9e7dcabb2a9b0c8f3c19441563c6318c to your computer and use it in GitHub Desktop.

# Thumbs up for the old school

If `44-33-555-555-666` is `hello` and `9-666-777-555-3` is `world`, what is:

`9-33-0-2-777-33-0-3-33-888-33-555-666-7-33-777-7777` = ???

Can you do an encoder/decoder for this way of writing?

### fboerncke commented Nov 23, 2023

GPT-4 did the work for me after I uploaded a screenshot of the puzzle:

The image you've uploaded appears to be a puzzle that uses numbers to represent letters, most likely following the convention of T9 predictive text input, which was commonly used on phones to type out text messages using the numeric keypad.

In T9 text input, each number from 2 to 9 corresponds to a set of letters:

• 2 corresponds to ABC
• 3 corresponds to DEF
• 4 corresponds to GHI
• 5 corresponds to JKL
• 6 corresponds to MNO
• 7 corresponds to PQRS
• 8 corresponds to TUV
• 9 corresponds to WXYZ

The number of times a number is repeated could indicate the position of the letter within that group. For example, the number "2" pressed once would be "A", pressed twice would be "B", and pressed three times would be "C".

Using this logic, let's decipher the given codes:

• For "hello", the sequence is 44-33-555-555-666. Deciphered, this means:

• "44" corresponds to "H"
• "33" corresponds to "E"
• "555" corresponds to "L"
• "555" again for "L"
• "666" corresponds to "O"
• For "world", the sequence is 9-666-777-555-3. Deciphered, this means:

• "9" corresponds to "W"
• "666" corresponds to "O"
• "777" corresponds to "R"
• "555" corresponds to "L"
• "3" corresponds to "D"

Now, let's decipher the last sequence using the same logic:

• 9-33-0-2-777-33-0-3-33-888-33-555-666-7-33-777-7777.

I will now decrypt this sequence for you.

The decrypted message from the puzzle is "WE ARE DEVELOPERS". Each series of numbers corresponds to a letter, similar to how T9 predictive text input works on a numeric keypad.

### GeorgeNikitinNV commented Nov 23, 2023

It is pretty obvious, that numbers between dashes encode letters, knowing the first two words, we can easily figure that the phrase is (? == unknown letter):

``````?-e-?-?-r-e-?-d-e-?-e-l-o-?-e-r-?
``````

If we assume that 0 == `space`, then the phrase looks like

``````we are developers
``````

In that case we also know some other letters. Putting them all together we have:

``````A=2
B=
C=
D=3
E=33
F=
G=
H=44
I=
J=
K=
L=555
M=
N=
O=666
P=7
Q=
R=777
S=7777
T=
U=
V=888
W=9
X=
Y=
Z=
``````

It looks like it is pretty obvious what is missing, so the full solution looks like:

``````<SPACE>=0
A=2
B=22
C=222
D=3
E=33
F=333
G=4
H=44
I=444
J=5
K=55
L=555
M=6
N=66
O=666
P=7
Q=77
R=777
S=7777
T=8
U=88
V=888
W=9
X=99
Y=999
Z=9999
``````
```key = {
" ": 0,
"A": 2,
"B": 22,
"C": 222,
"D": 3,
"E": 33,
"F": 333,
"G": 4,
"H": 44,
"I": 444,
"J": 5,
"K": 55,
"L": 555,
"M": 6,
"N": 66,
"O": 666,
"P": 7,
"Q": 77,
"R": 777,
"S": 7777,
"T": 8,
"U": 88,
"V": 888,
"W": 9,
"X": 99,
"Y": 999,
"Z": 9999,
}

string = input("Enter a string: ")

output = []
for l in string:
try:
code = key[l.upper()]
except KeyError:
code = "?"
output.append(code)

print("-".join(str(x) for x in output))```

### codepo8 commented Nov 23, 2023

``````"W": 9,
"X": 99,
"Y": 999,
"Z": 9999,
``````

}

string = input("Enter a string: ")

output = []
for l in string:
try:
code = key[l.upper()]
except KeyError:
code = "?"
output.append(code)

print("-".join(str(x) for x in output))

Love the lazy approach of not trying to detect the order in the string, but use a lookup table instead :)

it works 🤷‍♂️

### gpetrioli commented Nov 23, 2023

Here is (verbose) programmatic version 😀 (no UI)
https://gist.github.com/gpetrioli/cfc05bb447f2706f2de833c9cea4e351