Add GEB pq checker.

This commit is contained in:
Kyle Isom 2018-12-28 20:46:51 -08:00
parent 2f086a2c28
commit f4645e0598
1 changed files with 54 additions and 0 deletions

View File

@ -0,0 +1,54 @@
#include <stdio.h>
int
is_theorem_valid(char *candidate)
{
int x = 0;
int y = 0;
int z = 0;
int l = 0;
char *p = candidate;
while (*p != 0) {
if (*p == '-') {
switch (l) {
case 0:
x++;
break;
case 1:
y++;
break;
case 2:
z++;
break;
default:
return 0;
}
}
else if (*p == 'p') {
l = 1;
}
else if (*p == 'q') {
l = 2;
}
p++;
}
if ((x + y) == z) {
return 1;
}
return 0;
}
int
main(int argc, char *argv[])
{
for (int i = 1; i < argc; i++) {
if (is_theorem_valid(argv[i])) {
printf(" VALID: %s\n", argv[i]);
}
else {
printf("INVALID: %s\n", argv[i]);
}
}
}