Adding Numbers to get a single Number.
Posted: Mon Nov 14, 2011 3:12 am
Hi , I am new to scripting I am looking for a batch script to take input from a test file(Names.txt) having names & last names and converting each names & last names "alphabets" to its predefined below shown "numeric" value and then adding this numeric value to finally get ONE digit numeric value.
To make it more clear I would like to explain with an example .The Mapping between "Alphabets" & "Number" which I'll be using is as below.
"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""1", "2", "3", "4", "5", "8", "3", "5", "1", "1", "2", "3", "4", "5", "7", "8", "1", "2", "3", "4", "6", "6", "6", "5", "1","7"
Rozer Gorth =>Equivalent Numeric value: 2775237245 ==>Individually adding each number(2+7+7+5+2+3+7+2+4+5): 44 ==> Final ONE numeric digit(4+4): 8 Jimy Dacy =>Equivalent Numeric value: 11414131 ==>Individually adding each number(1+1+4+1+4+1+3+1): 16 ==>Final ONE numeric digit(1+6): 7Peter Pace =>Equivalent Numeric value: 854522135 ==>Individually adding each number(8+5+4+5+2+2+1+3+5): 35 ==>Final ONE numeric digit(3+5): 8
So result will be dumped into another file(Result.txt) as
Rozer Gorth : 8Jimy Dacy : 7Peter Pace : 8
I shall be very thankful for any suggestion and help.
To make it more clear I would like to explain with an example .The Mapping between "Alphabets" & "Number" which I'll be using is as below.
"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""1", "2", "3", "4", "5", "8", "3", "5", "1", "1", "2", "3", "4", "5", "7", "8", "1", "2", "3", "4", "6", "6", "6", "5", "1","7"
Rozer Gorth =>Equivalent Numeric value: 2775237245 ==>Individually adding each number(2+7+7+5+2+3+7+2+4+5): 44 ==> Final ONE numeric digit(4+4): 8 Jimy Dacy =>Equivalent Numeric value: 11414131 ==>Individually adding each number(1+1+4+1+4+1+3+1): 16 ==>Final ONE numeric digit(1+6): 7Peter Pace =>Equivalent Numeric value: 854522135 ==>Individually adding each number(8+5+4+5+2+2+1+3+5): 35 ==>Final ONE numeric digit(3+5): 8
So result will be dumped into another file(Result.txt) as
Rozer Gorth : 8Jimy Dacy : 7Peter Pace : 8
I shall be very thankful for any suggestion and help.