diff options
author | thing1 <thing1@seacrossedlovers.xyz> | 2025-03-12 11:30:18 +0000 |
---|---|---|
committer | thing1 <thing1@seacrossedlovers.xyz> | 2025-03-12 11:30:18 +0000 |
commit | fed4285a51b874113c41d9a9e78810640d71e5dc (patch) | |
tree | 1ad99a238c1d3b59be90a6a9728bb81930ab1c16 /comp/work | |
parent | 2ac42fa825d403e6285a58e08a62e6d549c86fa1 (diff) |
to much work
Diffstat (limited to 'comp/work')
-rw-r--r-- | comp/work/46/test.mac | 3 | ||||
-rwxr-xr-x | comp/work/46/turing | bin | 0 -> 20304 bytes | |||
-rw-r--r-- | comp/work/46/turing.c | 69 | ||||
-rw-r--r-- | comp/work/47/flatten.py | 10 | ||||
-rw-r--r-- | comp/work/47/ispal.py | 5 | ||||
-rw-r--r-- | comp/work/47/matrix | 17 |
6 files changed, 104 insertions, 0 deletions
diff --git a/comp/work/46/test.mac b/comp/work/46/test.mac new file mode 100644 index 0000000..3b3dca3 --- /dev/null +++ b/comp/work/46/test.mac @@ -0,0 +1,3 @@ +0 1 0 0 1 0 +0 0 1 0 1 0 +1 * 1 0 0 1 diff --git a/comp/work/46/turing b/comp/work/46/turing Binary files differnew file mode 100755 index 0000000..2b60bfe --- /dev/null +++ b/comp/work/46/turing diff --git a/comp/work/46/turing.c b/comp/work/46/turing.c new file mode 100644 index 0000000..cc41451 --- /dev/null +++ b/comp/work/46/turing.c @@ -0,0 +1,69 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <stdbool.h> + +typedef struct transfer { + int id; + char input; + int next; + char output; + int move; + bool end; +} transfer; + +transfer transfers[128]; +int transferptr = 0; +int count = 0; + +char tape[4096] = {0}; +char *head = tape; + +int main() { + FILE *f = fopen("test.mac", "r"); + + strcat(tape, "1110"); + + char *line = malloc(128); + while (fgets(line, 128, f) != NULL) { + char *tok = strtok(line, " "); // input + transfers[count].id = atoi(tok); + + tok = strtok(NULL, " "); + if (tok[0] == '*') transfers[count].input = -1; + else transfers[count].input = tok[0]; + + tok = strtok(NULL, " "); // next + transfers[count].next = atoi(tok); + + tok = strtok(NULL, " "); // output + transfers[count].output = tok[0]; + + tok = strtok(NULL, " "); // offset + transfers[count].move = atoi(tok); + + tok = strtok(NULL, " "); // end + transfers[count].end = atoi(tok); // must be 1 or 0 + + count++; + + line = malloc(128); + } + + for (;;) { + for (int i = 0; i < count; i++) { + if (transfers[i].id == transferptr) { + if (transfers[i].input == -1 || *head == transfers[i].input) { + *head = transfers[i].output; + head += transfers[i].move; + transferptr = transfers[i].next; + if (transfers[transferptr].end) break; + break; + } + } + } + } + printf("%s\n", tape); + return 0; +} + diff --git a/comp/work/47/flatten.py b/comp/work/47/flatten.py new file mode 100644 index 0000000..2e1958c --- /dev/null +++ b/comp/work/47/flatten.py @@ -0,0 +1,10 @@ +def flatten(l): + out = [] + for i in l: + if hasattr(i, "__len__"): + for j in flatten(i): out.append(j) + else: out.append(i) + + return out + +print(flatten([1, [[4, 6], 5], 2])) diff --git a/comp/work/47/ispal.py b/comp/work/47/ispal.py new file mode 100644 index 0000000..92111a4 --- /dev/null +++ b/comp/work/47/ispal.py @@ -0,0 +1,5 @@ +def ispal(word): + if word[::-1] == word: return True; + else: return False + +print(ispal("racecar")) diff --git a/comp/work/47/matrix b/comp/work/47/matrix new file mode 100644 index 0000000..3569f93 --- /dev/null +++ b/comp/work/47/matrix @@ -0,0 +1,17 @@ +0 5 1 +1 6 2 +2 10 5 +5 2 0 +5 7 4 +4 12 7 +4 5 6 +6 5 4 +5 4 3 +2 3 3 +each node has at most 2 child nodes, the nodes are unweighted and directional +mouse -> fox -> cat -> dog +mouse -> fox -> goat +but can yours work on a reciet role +ed was made for running on paper teletypes +and all of original unix was made with it +emacs wasnt a thing until 85 |