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?
"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 🤷♂️
Here is (verbose) programmatic version 😀 (no UI)
https://gist.github.com/gpetrioli/cfc05bb447f2706f2de833c9cea4e351
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):
If we assume that 0 ==
space
, then the phrase looks likeIn that case we also know some other letters. Putting them all together we have:
It looks like it is pretty obvious what is missing, so the full solution looks like: