From: jazzez ravi Date: 2008-07-31T20:40:58+09:00 Subject: Re: Help me with this Numerology code please... Web Reservoir wrote: > Hi, > > I am planning to implement a Numerology code like this. > > Every alphabet in Numerology is given a number like this... > > -------------------------------------------------------------- > 1 2 3 4 5 6 7 8 9 > > A B C D E F G H I > > J K L M N O P Q R > > S T U V W X Y Z > ---------------------------------------------------------- > > Or you can even say that > > 1 = A, J, S > 2 = B, K, T > 3 = C, L, U > 4 = D, M, V > 5 = E, N, W > 6 = F, O, X > 7 = G, P, Y > 8 = H, Q, Z > 9 = I, R > > Now when you type RUBY you should get the total as 9+3+2+7 = (21) 2+1 = > 3 > where R = 9, U = 3, B = 2 and y = 7 ( as shown above ) > > Have a look at the working example here... > > http://www.numerology.googlepages.com/Numerology_nameNumberdetails.htm > > and > > http://www.numerology.googlepages.com/Numerology_nameNumber.htm > > I would like to code this in Ruby. Pl. help me with this code. > Hi Reservoir, i think this code satisfy your need... class Reservoir def main a="mahalingam" # your name val={"a"=>1,"j"=>1,"s"=>1, "b"=>2,"k"=>2,"t"=>2, "c"=>3,"l"=>3,"u"=>3, "d"=>4,"m"=>4,"v"=>4, "e"=>5,"n"=>5,"w"=>5, "f"=>6,"o"=>6,"x"=>6, "g"=>7,"p"=>7,"y"=>7, "h"=>8,"q"=>8,"z"=>8, "i"=>9,"r"=>9} num=[] i=0 while i < a.length do num << val[a[i,1]] i+=1 end mind(num) end def mind(num) no=[] no=num j=0 final=0 while j < no.length final +=num[j].to_i j+=1 end output= final.to_s if output.length !=1 output2=output.split(//) mind(output2) else puts final end end end res=Reservoir.new res.main Regards, P.Raveendran RF,Chennai http://raveendran.wordpress.com -- Posted via http://www.ruby-forum.com/.