Code:
char alfabet[] = { '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'};
char name[] = "dutchmeata";
int number = 0,a,j;
int strl = strlen( name ); //9 in this case.
for (a=0; a<30; a++) {
for (j = 0; j < 26; j++) {
if (name[a] == alfabet[j])
number += j;
}
}
if (number == 86 && strl == 9 ){
printf("Woohoo! we have a correct name\n");
}else{
printf("The name is incorrect.\n");
}
Explanation:
Every name has it's own number, for example amxx has the number '23' (a = 0, + a = 0 + x=23)
//new alfabet[][] = { "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"}
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
In this case the 'name number' is 86.
So if the 'name number' is correct, there's a second check to match the length of the name.
This is C++, and not small, but you can easily port it if you need it...
I hope someone find it useful.
__________________