[color=yellow]char[/color] *strings[] = {
"caab",
"bccd",
"bada",
"bdbc",
"bdcc",
"badc",
"caab",
"aabc",
"bdba",
"baaa",
"bdcc",
"caab",
"bcba",
"bdcc",
"bdcb",
"badc",
"\0" };
[color=yellow]#include[/color] <stdio.h>
[color=yellow]void[/color] main()
{
[color=yellow]int[/color] i;
[color=yellow]int[/color] i1, i2, i3, i4, o1, o2, o3, o4;
[color=yellow]int[/color] add=0;
[color=yellow]int[/color] num;
[color=yellow]int[/color] alnum;
[color=yellow]int[/color] lowest, highest;
[color=yellow]char[/color] result[17];
[color=yellow]char[/color] resultb[17];
[color=yellow]printf[/color]("kmga order add cls lo hi diff result backwards\n");
[color=red]// i's (potion -> number)[/color]
[color=yellow]for[/color] (i1=0;i1<4;i1++)
[color=yellow]for[/color] (i2=0;i2<4;i2++)
[color=yellow]if[/color] (i2 != i1)
[color=yellow]for[/color] (i3=0;i3<4;i3++)
[color=yellow]if[/color] ((i3 != i2) && (i3 != i1))
[color=yellow]for[/color] (i4=0;i4<4;i4++)
[color=yellow]if[/color] ((i4 != i3) && (i4 != i2) && (i4 != i1))
[color=red]// o's (order)[/color]
[color=yellow]for[/color] (o1=0;o1<4;o1++)
[color=yellow]for[/color] (o2=0;o2<4;o2++)
[color=yellow]if[/color] (o2 != o1)
[color=yellow]for[/color] (o3=0;o3<4;o3++)
[color=yellow]if[/color] ((o3 != o2) && (o3 != o1))
[color=yellow]for[/color] (o4=0;o4<4;o4++)
[color=yellow]if[/color] ((o4 != o3) && (o4 != o2) && (o4 != o1))
[color=red]// add number (caesar)[/color]
[color=yellow]for[/color] (add=0;add<256;add++)
{
alnum = 0; [color=red]// how many alphanumeric chars are there ?[/color]
highest = 0; [color=red]// highest number[/color]
lowest = 9999; [color=red]// lowers "[/color]
[color=yellow]for[/color] (i=0;strings[i][0] != '\0';i++)
{
[color=yellow]int[/color] numbers[4];
[color=yellow]switch[/color](strings[i][o1])
{
[color=yellow]case[/color] 'a': numbers[0] = i1; [color=yellow]break[/color];
[color=yellow]case[/color] 'b': numbers[0] = i2; [color=yellow]break[/color];
[color=yellow]case[/color] 'c': numbers[0] = i3; [color=yellow]break[/color];
[color=yellow]case[/color] 'd': numbers[0] = i4; [color=yellow]break[/color];
}
[color=yellow]switch[/color](strings[i][o2])
{
[color=yellow]case[/color] 'a': numbers[1] = i1; [color=yellow]break[/color];
[color=yellow]case[/color] 'b': numbers[1] = i2; [color=yellow]break[/color];
[color=yellow]case[/color] 'c': numbers[1] = i3; [color=yellow]break[/color];
[color=yellow]case[/color] 'd': numbers[1] = i4; [color=yellow]break[/color];
}
[color=yellow]switch[/color](strings[i][o3])
{
[color=yellow]case[/color] 'a': numbers[2] = i1; [color=yellow]break[/color];
[color=yellow]case[/color] 'b': numbers[2] = i2; [color=yellow]break[/color];
[color=yellow]case[/color] 'c': numbers[2] = i3; [color=yellow]break[/color];
[color=yellow]case[/color] 'd': numbers[2] = i4; [color=yellow]break[/color];
}
[color=yellow]switch[/color](strings[i][o4])
{
[color=yellow]case[/color] 'a': numbers[3] = i1; [color=yellow]break[/color];
[color=yellow]case[/color] 'b': numbers[3] = i2; [color=yellow]break[/color];
[color=yellow]case[/color] 'c': numbers[3] = i3; [color=yellow]break[/color];
[color=yellow]case[/color] 'd': numbers[3] = i4; [color=yellow]break[/color];
}
num = 64*numbers[0] + 16*numbers[1] + 4*numbers[2] + numbers[3];
num += add;
[color=red]// num -= 94;[/color]
[color=yellow]while[/color] (num>256) num-=256;
[color=yellow]while[/color] (num<0) num+=256;
[color=yellow]if[/color] (num>highest) highest = num;
[color=yellow]if[/color] (num<lowest) lowest = num;
[color=red]// printf("%3d ", num);[/color]
result[i] = num;
resultb[15-i] = num;
[color=yellow]if[/color] ((num>=97) && (num<=122)) alnum+=2; [color=red]// a-z[/color]
[color=yellow]if[/color] ((num>=65) && (num<=90)) alnum++; [color=red]// A-Z[/color]
[color=yellow]if[/color] ((num>=48) && (num<=57)) alnum++; [color=red]// 0-9[/color]
[color=yellow]if[/color] (num < 32) alnum = -32;
[color=yellow]if[/color] (num == 127) alnum = -32;
[color=red]// if ((num>=144) && (num<=195)) alnum = -32;[/color]
[color=yellow]if[/color] (num>=127) alnum-=2;
}
result[16] = '\0';
resultb[16] = '\0';
[color=yellow]if[/color] (alnum >= 0) [color=red]// >= 16)[/color]
{
[color=yellow]printf[/color]("\n%d%d%d%d %d%d%d%d %3d %+3d (%3d-%3d|%3d): ",
i1, i2, i3, i4, o4, o3, o2, o1, add, alnum, lowest, highest, (highest-lowest));
[color=yellow]printf[/color]("%s", result);
[color=yellow]printf[/color](" %s\n", resultb);
}
}
}