Karthik Selvakumar Bhuvaneswaran is a Software Engineer working on Saas(RoR) and PaaS(Salesforce.com) applications. He beleives on day starts at night and requires nothing more than Music, a cup of cofee and a fully charged laptop.
© 2016 karthikselva. Distributed with an MIT license.
def get_max_sum(num) if num < 1 return 0 else return (26**num)+get_max_sum(num-1) end end def cal_sum(st) sum = get_max_sum(st.length - 1) st.length.times do |i| sum += (st[i]-97)*(26**(st.length-i-1)) end return sum end p cal_sum('abc')