/* Find hash function that would match the letters "KLMNQS". */ #include int main(void) { int all, correct, expected, actual, i, x, y, z; for(x = 0; x < 256; x++) { for(y = 1; y < 256; y++) { for(z = 0; z < 256; z++) { all = correct = 0; for(i = 9; i < 127; i++) { if( i <= 32 && i != 9 ) continue; if( i == 'P' || i == 'R' ) continue; all++; expected = i == 'K' || i == 'L' || i == 'M' || i == 'N' || i == 'Q' || i == 'S'; actual = ((i * x) % y) < z && i != 'O'; if( (expected && actual) || (!expected && !actual) ) correct++; } if( all == correct ) printf("x = %d, y = %d, z = %d\n", x, y, z); } } } return 0; }