aboutsummaryrefslogtreecommitdiff
path: root/console
diff options
context:
space:
mode:
Diffstat (limited to 'console')
-rw-r--r--console/input14
-rw-r--r--console/v2.py2
-rw-r--r--console/voerbak.c35
3 files changed, 51 insertions, 0 deletions
diff --git a/console/input b/console/input
new file mode 100644
index 0000000..1243fe0
--- /dev/null
+++ b/console/input
@@ -0,0 +1,14 @@
+7 6
+4
+3
+3
+2
+1
+2
+2
+7
+1
+7
+1
+7
+1
diff --git a/console/v2.py b/console/v2.py
index 6531fff..16fae64 100644
--- a/console/v2.py
+++ b/console/v2.py
@@ -75,6 +75,8 @@ def main():
while True:
gert.print()
column = int(input("column?: ")) - 1
+ if column not in range(gert.width):
+ continue
os.system("clear")
gert.drop_fisje(column, DISC_A if disc_a else DISC_B)
disc_a = not disc_a
diff --git a/console/voerbak.c b/console/voerbak.c
new file mode 100644
index 0000000..4eeabc5
--- /dev/null
+++ b/console/voerbak.c
@@ -0,0 +1,35 @@
+#include <stdio.h>
+#include <memory.h>
+
+#define DISC_A "\x1b[31mo\x1b[39m"
+#define DISC_B "\x1b[34mo\x1b[39m"
+#define EMPTY "\x1b[90m_\x1b[39m"
+
+void printBoard(int board[], int width, int height) {
+ for (int y = height - 1; y > -1; y--) {
+ for (int x = 0; x < width; x++) {
+ int val = board[x + y * width];
+ char *print =
+ val == 0 ? EMPTY :
+ val == 1 ? DISC_A :
+ val == 2 ? DISC_B :
+ EMPTY;
+ printf("%s ", print);
+ }
+ printf("\n");
+ }
+}
+
+int main() {
+ int width, height;
+ scanf("%d %d", &width, &height);
+
+ int board[width * height];
+ memset(board, 0, sizeof board);
+
+ board[2] = 1;
+ board[3] = 2;
+ printBoard(board, width, height);
+
+ return 0;
+}