Fridge magnet substitution

Python 2, 145 131 130 129 125 bytes

lambda*a:all(len({sum(map(w.count,x))for w in a})<2for x in'A4 B8 CU EMW3 G69 I1 L7 NZ O0 R2 S5'.split()+list('DFHJKPQTVXY'))

Try it online!

Alt:

Python 2, 125 bytes

lambda*a:len({(x,sum(map(w.count,x)))for x in'A4 B8 CU EMW3 G69 I1 L7 NZ O0 R2 S5'.split()+list('DFHJKPQTVXY')for w in a})<23

Try it online!


Ruby, 99 72 71 bytes

->a{!!a.map{|x|x.tr("0-9UZMW","OIREASGLBGCNE").chars.sort-[" "]}.uniq!}

Try it online!

Takes an array of strings, assumes input in uppercase as in all test cases.

-1 byte golfed by benj2240.


JavaScript (ES6), 102 100 bytes

Takes input as two arrays of characters in currying syntax (a)(b). Returns a boolean.

a=>b=>(g=s=>s.map(c=>'648UD3F6H1JK73Z0PQ25TUV3'[parseInt(c,36)-9]||c).sort().join``.trim())(a)==g(b)

Try it online!

How?

Using the helper function g(), for each input s:

  • Digits 0 to 8 and letters X, Y and Z are left unchanged. Everything else is explicitly translated.

    0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ
             ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
    .........648UD3F6H1JK73Z0PQ25TUV3...
    

    Code:

    s.map(c => '648UD3F6H1JK73Z0PQ25TUV3'[parseInt(c, 36) - 9] || c)
    
  • We sort the characters (which brings all spaces at the beginning), join them and remove all leading whitespace.

    Code:

    .sort().join``.trim()
    

Finally, we compare both outputs.