From e649b1a3bd45346a342ee122180228013f20da1f Mon Sep 17 00:00:00 2001 From: Rose Apollo Date: Sat, 30 Nov 2024 22:13:38 +0000 Subject: [PATCH] fix bug --- src/logic.c | 2 +- src/logic_karn.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/logic.c b/src/logic.c index 9de351b..2293d13 100644 --- a/src/logic.c +++ b/src/logic.c @@ -7,7 +7,7 @@ int main(int argc, char** argv) { int x, y; - char d[] = "((Bo((-A^-C)o(A^C)))v(A^B^C))^((DvA)o(-D^C))"; + char d[] = "(D^B)v(B^-C)v(B^(-C^-D))v(A^C^D)v(-C^D^-A^-B)"; bool* c = logic_karn_run(d, 4, &x, &y); logic_karn_render(c, x, y); diff --git a/src/logic_karn.c b/src/logic_karn.c index 2dd96d2..2f8cf3a 100644 --- a/src/logic_karn.c +++ b/src/logic_karn.c @@ -83,24 +83,24 @@ bool* logic_karn_run(char* equ, int args, int *x, int *y) { if (*x == 2) { - bargs[0] = logic_karn_1_gray[ix]; + bargs[((*y) / 2) + 0] = logic_karn_1_gray[ix]; } else { - bargs[0] = logic_karn_2_gray[ix] & (1 << 0); - bargs[1] = logic_karn_2_gray[ix] & (1 << 1); + bargs[((*y) / 2) + 0] = logic_karn_2_gray[ix] & (1 << 0); + bargs[((*y) / 2) + 1] = logic_karn_2_gray[ix] & (1 << 1); } for (int iy = 0; iy < *y; iy++) { if (*y == 2) { - bargs[((*x) / 2) + 0] = logic_karn_1_gray[iy]; + bargs[0] = logic_karn_1_gray[iy]; } else { - bargs[((*x) / 2) + 0] = logic_karn_2_gray[iy] & (1 << 0); - bargs[((*x) / 2) + 1] = logic_karn_2_gray[iy] & (1 << 1); + bargs[0] = logic_karn_2_gray[iy] & (1 << 0); + bargs[1] = logic_karn_2_gray[iy] & (1 << 1); } *dp = logic_run_runner(equ, args, bargs);