This is a response to the kumite to show that it has an elegant solution for ruby using the compiled bash utility "tr"

It's my first kumite so I'm not sure if this is how to use it. Don't mind if I do!

  • def pattern a,b,b)==b &&,a)==a
    • def pattern(p,st):
    • def encode(s):
    • dic={} # dictionary to hold values from the input string
    • num=0
    • sn="" # a numerical string to hold the encoding
    • for i in s:
    • if i not in dic:
    • dic[i]=num
    • num+=1
    • sn+=str(dic[i])
    • return sn
    • return encode(st)==encode(p)
    • def pattern a,b
    •,b)==b &&,a)==a
    • end