When writing a message with fridge magnets, you'll often find yourself substituting a 1
for an I
. In this challenge, your goal is to find out if a message can be written using the letters of another message. The allowed substitutions are:
A = 4
B = 8
C = U
E = M = W = 3
G = 6 = 9
I = 1
L = 7
N = Z
O = 0
R = 2
S = 5
For example, the message CIRCA 333
can be rearranged to spell ICE CREAM
, where the first two 3
s are rotated 180 degrees to make two E
s, and the last 3
is rotated 90 degrees counterclockwise to make an M
. Whitespaces can be included in the messages, but they should not be accounted for in your solution, as they're made by placing the magnets on the fridge.
Input
Two strings (or character arrays). All messages will match ^[A-Z0-9 ]+$
Output
Truthy if the two input strings are valid rearrangements of each other, falsey otherwise.
Examples
["CIRCA 333", "ICE CREAM"] => true
["DCLV 00133", "I LOVE CODE"] => true
["WE ARE EMISSARIES", "33 423 3315542135"] => true
["WE WANT ICE CREAM", "MET CIRCA 334 MEN"] => true
["I HAVE ICE CREAM", "HAVE 2 ICE CREAMS"] => false
More thruthy examples
These are all the 15+ letter words that map to another word. Some are trivial substitutions, but I included all that I found.
["ANTHROPOMORPHISE","ANTHROPOMORPHISM"]
["ANTIPHILOSOPHIES","ANTIPHILOSOPHISM"]
["CIRCUMSTANTIALLY","ULTRAMASCULINITY"]
["DECENTRALIZATION","DENEUTRALIZATION"]
["DIMETHYLNITROSAMINE","THREEDIMENSIONALITY"]
["INSTITUTIONALISE","INSTITUTIONALISM"]
["INTERCRYSTALLINE","INTERCRYSTALLIZE"]
["INTERNATIONALISE","INTERNATIONALISM"]
["OVERCENTRALIZATION","OVERNEUTRALIZATION"]
["OVERCENTRALIZING","OVERNEUTRALIZING"]
["PREMILLENNIALISE","PREMILLENNIALISM"]
["TRANSCENDENTALIZE","TRANSCENDENTALIZM"]
As this is a code golf challenge, the shortest solution wins! I will accept the shortest solution in 7 days from posting. Happy golfing!
Related
EDIT: Made an error in the substitutions, had G = 6
and 6 = 9
as separate substitutions, merged them into one.
T
andL
are not exchangeable, I can't addT = 7
. The same goes forN = Z = 2
, which would imply thatN = Z = R = 2
. However, the kind of substitutions you suggest would make for a more difficult version of this challenge, which I might post at a later time. I just wanted to see if these kinds of challenges would be well received first. \$\endgroup\$false
. \$\endgroup\$