Created
October 22, 2015 20:09
-
-
Save sandeep048/7d2d991ac986b581dbc1 to your computer and use it in GitHub Desktop.
Indian Numerology Calculator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
chmap = {} | |
for alph, num in [(chr(x+65), x+1) for x in range(26)]: | |
chmap[alph] = num | |
def rsum(numlist): | |
value = sum(int(x) for x in numlist) | |
if value > 0 and value < 10: | |
return value | |
else: | |
return rsum(str(value)) | |
def getnumber(name): | |
return (name, rsum([chmap.get(x) for x in name])) | |
print [getnumber(x) for x in ('SANDEEP', 'ANUSHA', 'SAKETH')] | |
# [('SANDEEP', 1), ('ANUSHA', 1), ('SAKETH', 1)] | |
print [getnumber(x) for x in ('PRADEEP', 'SAMEERA', 'DHRUV')] | |
# [('PRADEEP', 2), ('SAMEERA', 8), ('DHRUV', 1)] | |
print [getnumber(x) for x in ('SATYANARAYANA', 'KRISHNAVENI', 'SANDEEP', 'SAMEERA')] | |
# [('SATYANARAYANA', 6), ('KRISHNAVENI', 4), ('SANDEEP', 1), ('SAMEERA', 8)] | |
print [getnumber(x) for x in ('SEETARAMUNAIDU', 'SUBHADRA', 'ANUSHA', 'TARUN')] | |
# [('SEETARAMUNAIDU', 8), ('SUBHADRA', 2), ('ANUSHA', 1), ('TARUN', 2)] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment