From 3af9b11229f79d3e6347a2e628772a729c644016 Mon Sep 17 00:00:00 2001 From: thing1 Date: Thu, 6 Feb 2025 12:09:43 +0000 Subject: did some interesting work --- comp/work/43/photo.png | Bin 0 -> 18115 bytes comp/work/43/q1.py | 38 ++++++++++++++++++++++++++++++++++++++ comp/work/44/fsn | 3 +++ comp/work/44/regex | Bin 0 -> 15736 bytes comp/work/44/regex.c | 15 +++++++++++++++ comp/work/44/sheet | 11 +++++++++++ comp/work/44/starter | 27 +++++++++++++++++++++++++++ comp/work/44/task1 | 6 ++++++ 8 files changed, 100 insertions(+) create mode 100644 comp/work/43/photo.png create mode 100644 comp/work/43/q1.py create mode 100644 comp/work/44/fsn create mode 100755 comp/work/44/regex create mode 100644 comp/work/44/regex.c create mode 100644 comp/work/44/sheet create mode 100644 comp/work/44/starter create mode 100644 comp/work/44/task1 (limited to 'comp') diff --git a/comp/work/43/photo.png b/comp/work/43/photo.png new file mode 100644 index 0000000..5786a78 Binary files /dev/null and b/comp/work/43/photo.png differ diff --git a/comp/work/43/q1.py b/comp/work/43/q1.py new file mode 100644 index 0000000..acd5f93 --- /dev/null +++ b/comp/work/43/q1.py @@ -0,0 +1,38 @@ +def isvowel(char): + if char in "aeoiu": + return True; + return False + +def tolist(string): + list = [] + for i in string: + list.append(i) + return list + +def stripvowels(string): + out = "" + vowels = "" + for i in string: + if isvowel(i): + out += "." + vowels += i + else: + out += i + + vowels = tolist(reversed(vowels)) + return out, vowels + +def swap(string, vowels): + final = "" + for i in string: + if i == ".": + final += vowels.pop(0) + else: + final += i + return final + + +string = input("input a string: ") + +string, vowels = stripvowels(string) +print(swap(string, vowels)) diff --git a/comp/work/44/fsn b/comp/work/44/fsn new file mode 100644 index 0000000..1d09a23 --- /dev/null +++ b/comp/work/44/fsn @@ -0,0 +1,3 @@ +s1 = s2(a) +s2 = s3(b) +(s3) = done , s1(a) diff --git a/comp/work/44/regex b/comp/work/44/regex new file mode 100755 index 0000000..5a3fde4 Binary files /dev/null and b/comp/work/44/regex differ diff --git a/comp/work/44/regex.c b/comp/work/44/regex.c new file mode 100644 index 0000000..6697836 --- /dev/null +++ b/comp/work/44/regex.c @@ -0,0 +1,15 @@ +#include +#include +#include + +void eprint(char *msg){ +fprintf(stderr, "%s\n", msg); +exit(1); +} + +int main(){ +regex_t expr; +if (regcomp(&expr, "(1|0)+", 0) != 0) eprint("regcomp failed!"); +int ret = regexec(&expr, "1010", 0, NULL, 0); +printf("%d\n", ret); +} diff --git a/comp/work/44/sheet b/comp/work/44/sheet new file mode 100644 index 0000000..5226997 --- /dev/null +++ b/comp/work/44/sheet @@ -0,0 +1,11 @@ +RE | req + +(1|0) | 1 or 0 +1+ | all 1's +(1|0)+ | all binary strings +(1|0)*1 | binary string ending with 1 +1(1|0)* | binary string starting with 1 +(1|0)*00 | binary string ending 00 +(0|1)*1(0|1)*1(0|1)*(0|1) | binary string with at least 3 1's, with the ones being between 4 binary strings that can contain anything and can be empty, exepct at the end, where it is a final 1, or 0, and nothing else +111*((0|1)*|111)*(111)* | binary string with at least 3 consecutive 1's +(0|1)*110(0|1)* | any binary string with 110 in the middle of it (or the start or end if the first terms occur 0 times) diff --git a/comp/work/44/starter b/comp/work/44/starter new file mode 100644 index 0000000..64dc05b --- /dev/null +++ b/comp/work/44/starter @@ -0,0 +1,27 @@ +a+b +accept: +ab, aab +reject: +a, b, baa + +(bc)*a +accept: +a, bca, bcbca +reject: +bcaa, bcabca + +LL?D?D +accept: +SO14, BH12, DT6, W1 +reject: +gu13, 1CH87 + +0(0|1)* +accept: +0, 00, 01, 000, 001, 010 +reject: +101 +(01)+ +10+1 +(0|1)* +(10001|1000|1011|10111) diff --git a/comp/work/44/task1 b/comp/work/44/task1 new file mode 100644 index 0000000..3179baa --- /dev/null +++ b/comp/work/44/task1 @@ -0,0 +1,6 @@ +(c|b+)a* + +s1 = s2(c), s3(b) +(s2) = done, s4(a) +(s3) = done, s3(b), s4(a) +(s4) = done, s4(a) -- cgit v1.2.3