From: "Peña, Botp" Date: 2008-08-01T12:57:47+09:00 Subject: Re: Help me with this Numerology code please... From: webreservoir@gmail.com [mailto:webreservoir@gmail.com] # tough for me to understand yiour code at this stage. # May be after more homework, perhaps i will be able to do it. sometimes, it's easy if you just code what you think. I assume you read maps :) You are basically, mapping, so just use a map. A linear map of string is very visible to the eye and head eg, M1="ABCDEFGHIJKLMNOPQRSTUVWXYZ" M2="12345678912345678912345678" class String def getM2(map) M2[map.index(self)].chr.to_i end def getM2sum(map) sum=0 each_byte do |c| sum += c.chr.getM2(map) end sum end def numerology getM2sum(M1).to_s.getM2sum(M2) end end p "RUBY".numerology 3 #=> nil in essence, i just mapped M1 to M2, and fr there, mapped again the result using M2 to M2 (mapping to self). In ruby1.9 it becomes simpler since you do not need the #chr conversion. hth. kind regards -botp