This commit is contained in:
parent
aab2829c9c
commit
f4c682bbea
1 changed files with 39 additions and 14 deletions
53
tennis.c
53
tennis.c
|
@ -15,6 +15,9 @@ typedef uint64_t u64;
|
||||||
#define LEN(a) (sizeof(a) / sizeofel(a))
|
#define LEN(a) (sizeof(a) / sizeofel(a))
|
||||||
|
|
||||||
const char *lut[] = {
|
const char *lut[] = {
|
||||||
|
// characters within the same string are considered the same.
|
||||||
|
// that means the number of choices for a single character
|
||||||
|
// goes down from 36 to 28.
|
||||||
"N", "P", "Q", "R",
|
"N", "P", "Q", "R",
|
||||||
"T", "W", "X", "Y",
|
"T", "W", "X", "Y",
|
||||||
"17I", "2Z", "5S", "8B",
|
"17I", "2Z", "5S", "8B",
|
||||||
|
@ -114,6 +117,7 @@ int decode_data(code_t *code) {
|
||||||
|
|
||||||
if (!check_ranges(code)) return 0;
|
if (!check_ranges(code)) return 0;
|
||||||
|
|
||||||
|
// TODO: refactor so this isn't repeated in encode_data.
|
||||||
const u32 neg1 = (u32)-1;
|
const u32 neg1 = (u32)-1;
|
||||||
if (code->data[2] == neg1 || code->data[2] != code->data[4]); else return 0;
|
if (code->data[2] == neg1 || code->data[2] != code->data[4]); else return 0;
|
||||||
if (code->data[1] < 7 || (code->data[2] != neg1 && code->data[4] != neg1)); else return 0;
|
if (code->data[1] < 7 || (code->data[2] != neg1 && code->data[4] != neg1)); else return 0;
|
||||||
|
@ -197,20 +201,41 @@ int bruteforce() { // with a fixed seed, this is useful for testing.
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
if (argc == 1) {
|
if (argc == 1) {
|
||||||
// self-test.
|
// self-test with codes known before this program was written.
|
||||||
if (!validate_entry("48HWOR482")) return -1;
|
#define TEST(entry) if (!validate_entry(entry)) return -1
|
||||||
if (!validate_entry("5G3LTQ5GN")) return -1;
|
TEST("48HWOR482");
|
||||||
if (!validate_entry("A3W5KQA3C")) return -1;
|
TEST("5G3LTQ5GN");
|
||||||
if (!validate_entry("ARM6JQARU")) return -1;
|
//TEST("5PURGR5PM");
|
||||||
if (!validate_entry("E8ULJRE8M")) return -1;
|
//TEST("6PJEGRGP5");
|
||||||
if (!validate_entry("J6M9PQJ6U")) return -1;
|
//TEST("8GYUHR86F");
|
||||||
if (!validate_entry("LA98JRLAR")) return -1;
|
TEST("A3W5KQA3C");
|
||||||
if (!validate_entry("M1C2YQM1W")) return -1;
|
TEST("ARM6JQARU");
|
||||||
if (!validate_entry("MM55MQMMJ")) return -1;
|
TEST("E880MPE8K");
|
||||||
if (!validate_entry("N24K8QN2P")) return -1;
|
TEST("E8ULJRE8M");
|
||||||
if (!validate_entry("OF9XFQOFR")) return -1;
|
TEST("EPJEGREP5");
|
||||||
if (!validate_entry("UOUFMPUOM")) return -1;
|
TEST("GH4KNQGHP");
|
||||||
if (!validate_entry("V2UFMPUZM")) return -1;
|
TEST("H6L3MPH60");
|
||||||
|
TEST("HH4KNQHHP");
|
||||||
|
TEST("J6M9PQJ6U");
|
||||||
|
TEST("JEP8YQJE4");
|
||||||
|
TEST("LA98JRLAR");
|
||||||
|
TEST("LQM1MPLQU");
|
||||||
|
TEST("LTHWYQLT2");
|
||||||
|
TEST("M1C2YQM1W");
|
||||||
|
TEST("MM55MQMMJ");
|
||||||
|
TEST("N24K8QN2P");
|
||||||
|
TEST("OF9XFQOFR");
|
||||||
|
TEST("P4K6GRP48");
|
||||||
|
TEST("TE6WARTEQ");
|
||||||
|
TEST("TQJEGRTQ5");
|
||||||
|
TEST("UOUFMPUOM");
|
||||||
|
TEST("V2UFMPUZM");
|
||||||
|
TEST("W2HEGRW22");
|
||||||
|
TEST("WQJEGRWQ5");
|
||||||
|
TEST("WRWQARWRC");
|
||||||
|
TEST("YQJEGRYQ5");
|
||||||
|
//TEST("ZKZLZKNNR");
|
||||||
|
#undef TEST
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue