diff options
52 files changed, 281 insertions, 246 deletions
diff --git a/comp/cs-oracle b/comp/cs-oracle -Subproject da2966288031c1f5a9741a3d37b4e537b9239e0 +Subproject 57e0dfaed57469001aaac128fe2649a8c505641 diff --git a/comp/cw/code/ads/ll/lltest.c b/comp/cw/code/ads/ll/lltest.c deleted file mode 100644 index 8aa6514..0000000 --- a/comp/cw/code/ads/ll/lltest.c +++ /dev/null @@ -1,18 +0,0 @@ -#include <stdio.h> - -#include "ll.h" - -int main(){ - ll_t *head = llalloc(); - llsetdata(head, "hello"); - - for (int i = 0; i < 3; i++){ - ll_t *node = llalloc(); - llsetdata(node, "hi"); - llsetnext(head, node); - } - for (int i = 0; i < 4; i++) - printf("%s\n", (char *)llgetat(head, i)); - - llfreeall(head); -} diff --git a/comp/cw/code/parser/parser.o b/comp/cw/code/parser/parser.o Binary files differdeleted file mode 100644 index baccd37..0000000 --- a/comp/cw/code/parser/parser.o +++ /dev/null diff --git a/comp/cw/code/parser/preprocessor.o b/comp/cw/code/parser/preprocessor.o Binary files differdeleted file mode 100644 index fad2c87..0000000 --- a/comp/cw/code/parser/preprocessor.o +++ /dev/null diff --git a/comp/cw/code/parser/readfile.o b/comp/cw/code/parser/readfile.o Binary files differdeleted file mode 100644 index 32bc31d..0000000 --- a/comp/cw/code/parser/readfile.o +++ /dev/null diff --git a/comp/cw/code/tokenizer/ads/dict/Makefile b/comp/cw/code/tokenizer/ads/dict/Makefile deleted file mode 100644 index f224267..0000000 --- a/comp/cw/code/tokenizer/ads/dict/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -all: dict.c - cc dict.c -c -o dict.o -test: all - cc dict.o dicttest.c -o dicttest diff --git a/comp/cw/code/tokenizer/ads/dict/dict.c b/comp/cw/code/tokenizer/ads/dict/dict.c deleted file mode 100644 index 551afca..0000000 --- a/comp/cw/code/tokenizer/ads/dict/dict.c +++ /dev/null @@ -1,29 +0,0 @@ -#include <stdlib.h> -#include <string.h> - -typedef struct dict_t { - int id; - void *data; -}dict_t; - -dict_t *dictalloc(){ - dict_t *output = malloc(sizeof(dict_t)); - return output; -} - -int dictset(dict_t *dict, int id, void *data){ - dict->id = id; - - dict->data = malloc(sizeof(data)); - if (dict->data == NULL) - return 1; - memcpy(dict->data, data, sizeof(data)); - - return 0; -} - -void dictfree(dict_t *dict){ - free(dict->data); - free(dict); -} - diff --git a/comp/cw/code/tokenizer/ads/dict/dict.h b/comp/cw/code/tokenizer/ads/dict/dict.h deleted file mode 100644 index e6ab69d..0000000 --- a/comp/cw/code/tokenizer/ads/dict/dict.h +++ /dev/null @@ -1,9 +0,0 @@ -typedef struct dict_t { - int id; - void *data; -}dict_t; - -dict_t *dictalloc(); -int dictset(dict_t *dict, int id, void *data); -void dictfree(dict_t *dict); - diff --git a/comp/cw/code/tokenizer/ads/dict/dict.o b/comp/cw/code/tokenizer/ads/dict/dict.o Binary files differdeleted file mode 100644 index aefd77a..0000000 --- a/comp/cw/code/tokenizer/ads/dict/dict.o +++ /dev/null diff --git a/comp/cw/code/tokenizer/ads/dict/dicttest b/comp/cw/code/tokenizer/ads/dict/dicttest Binary files differdeleted file mode 100755 index dddf2a0..0000000 --- a/comp/cw/code/tokenizer/ads/dict/dicttest +++ /dev/null diff --git a/comp/cw/code/tokenizer/ads/dict/dicttest.c b/comp/cw/code/tokenizer/ads/dict/dicttest.c deleted file mode 100644 index 4a20870..0000000 --- a/comp/cw/code/tokenizer/ads/dict/dicttest.c +++ /dev/null @@ -1,10 +0,0 @@ -#include <stdio.h> - -#include "dict.h" - -int main(){ - dict_t *dict = dictalloc(); - dictset(dict, 1, "hello"); - printf("%d:%s\n", dict->id, (char *)dict->data); - dictfree(dict); -} diff --git a/comp/cw/code/tokenizer/ads/dll/Makefile b/comp/cw/code/tokenizer/ads/dll/Makefile deleted file mode 100644 index 651681d..0000000 --- a/comp/cw/code/tokenizer/ads/dll/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -all: dll.c - cc dll.c -c -o dll.o - -test: all - cc dll.o dlltest.c -o dlltest diff --git a/comp/cw/code/tokenizer/ads/dll/dll.c b/comp/cw/code/tokenizer/ads/dll/dll.c deleted file mode 100644 index b24b13f..0000000 --- a/comp/cw/code/tokenizer/ads/dll/dll.c +++ /dev/null @@ -1,62 +0,0 @@ -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -typedef struct dll_t dll_t; - -typedef struct dll_t { - void *data; - dll_t *next; - dll_t *prev; -} dll_t; - -dll_t *dllalloc(){ - dll_t *output = malloc(sizeof(dll_t)); - if (output == NULL) - return NULL; - output->next = NULL; - output->prev = NULL; - return output; -} - -void dllsetdata(dll_t *node, void *data){ - node->data = malloc(sizeof(data)); - memcpy(node->data, data, sizeof(data)); -} - -void dllsetnext(dll_t *node, dll_t *next){ - if (node->next == NULL) { - node->next = next; - node->next->prev = node; - } - else - dllsetnext(node->next, next); -} -void dllsetprev(dll_t *node, dll_t *prev){ - if (node->prev == NULL) { - node->prev = prev; - node->prev->next = node; - } - else - dllsetprev(node->prev, prev); -} - -void *dllgetat(dll_t *head, int index){ - if (index == 0) - return head->data; - else { - if (head->next != NULL) { - return dllgetat(head->next, index - 1); - }else { - return NULL; - } - } -} - -void dllfreeall(dll_t *head){ - if (head->next != NULL) - dllfreeall(head->next); - free(head->data); - free(head); -} - diff --git a/comp/cw/code/tokenizer/ads/dll/dll.h b/comp/cw/code/tokenizer/ads/dll/dll.h deleted file mode 100644 index 44940ce..0000000 --- a/comp/cw/code/tokenizer/ads/dll/dll.h +++ /dev/null @@ -1,19 +0,0 @@ -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -typedef struct dll_t dll_t; - -typedef struct dll_t { - void *data; - dll_t *next; - dll_t *prev; -} dll_t; - -dll_t *dllalloc(); -void dllsetdata(dll_t *node, void *data); -void dllsetnext(dll_t *node, dll_t *next); -void dllsetprev(dll_t *node, dll_t *prev); -void *dllgetat(dll_t *head, int index); -void dllfreeall(dll_t *head); - diff --git a/comp/cw/code/tokenizer/ads/dll/dll.o b/comp/cw/code/tokenizer/ads/dll/dll.o Binary files differdeleted file mode 100644 index 2c9a145..0000000 --- a/comp/cw/code/tokenizer/ads/dll/dll.o +++ /dev/null diff --git a/comp/cw/code/tokenizer/ads/dll/dlltest b/comp/cw/code/tokenizer/ads/dll/dlltest Binary files differdeleted file mode 100755 index 83f900c..0000000 --- a/comp/cw/code/tokenizer/ads/dll/dlltest +++ /dev/null diff --git a/comp/cw/code/tokenizer/ads/dll/dlltest.c b/comp/cw/code/tokenizer/ads/dll/dlltest.c deleted file mode 100644 index 4544d2e..0000000 --- a/comp/cw/code/tokenizer/ads/dll/dlltest.c +++ /dev/null @@ -1,20 +0,0 @@ -#include <stdio.h> - -#include "dll.h" - -int main(){ - dll_t *head = dllalloc(); - dllsetdata(head, "hello"); - - for (int i = 0; i < 3; i++){ - dll_t *node = dllalloc(); - dllsetdata(node, "hi"); - dllsetnext(head, node); - } - - for (int i = 0; i < 4; i++) - printf("%s\n", (char *)dllgetat(head, i)); - printf("%s\n", (char *)head->prev->next->data); - - dllfreeall(head); -} diff --git a/comp/cw/code/tokenizer/ads/ll/Makefile b/comp/cw/code/tokenizer/ads/ll/Makefile deleted file mode 100644 index aaf0241..0000000 --- a/comp/cw/code/tokenizer/ads/ll/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -all: ll.c - cc ll.c -c -o ll.o - -test: all - cc ll.o lltest.c -o lltest diff --git a/comp/cw/code/tokenizer/ads/ll/ll.c b/comp/cw/code/tokenizer/ads/ll/ll.c deleted file mode 100644 index c45ab0c..0000000 --- a/comp/cw/code/tokenizer/ads/ll/ll.c +++ /dev/null @@ -1,50 +0,0 @@ -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -typedef struct ll_t ll_t; - -typedef struct ll_t { - void *data; - ll_t *next; -} ll_t; - -ll_t *llalloc(){ - ll_t *output = malloc(sizeof(ll_t)); - if (output == NULL) - return NULL; - output->next = NULL; - return output; -} - -void llsetdata(ll_t *node, void *data){ - node->data = malloc(sizeof(data)); - memcpy(node->data, data, sizeof(data)); -} - -void llsetnext(ll_t *node, ll_t *next){ - if (node->next == NULL) - node->next = next; - else - llsetnext(node->next, next); -} - -void *llgetat(ll_t *head, int index){ - if (index == 0) - return head->data; - else { - if (head->next != NULL) { - return llgetat(head->next, index - 1); - }else { - return NULL; - } - } -} - -void llfreeall(ll_t *head){ - if (head->next != NULL) - llfreeall(head->next); - free(head->data); - free(head); -} - diff --git a/comp/cw/code/tokenizer/ads/ll/ll.h b/comp/cw/code/tokenizer/ads/ll/ll.h deleted file mode 100644 index 30830b1..0000000 --- a/comp/cw/code/tokenizer/ads/ll/ll.h +++ /dev/null @@ -1,15 +0,0 @@ -#include <stdlib.h> -#include <string.h> - -typedef struct ll_t ll_t; - -typedef struct ll_t { - void *data; - ll_t *next; -} ll_t; - -ll_t *llalloc(); -void llsetdata(ll_t *node, void *data); -void llsetnext(ll_t *node, ll_t *next); -void *llgetat(ll_t *head, int index); -void llfreeall(ll_t *head); diff --git a/comp/cw/code/tokenizer/ads/ll/ll.o b/comp/cw/code/tokenizer/ads/ll/ll.o Binary files differdeleted file mode 100644 index b033278..0000000 --- a/comp/cw/code/tokenizer/ads/ll/ll.o +++ /dev/null diff --git a/comp/cw/code/tokenizer/ads/ll/lltest b/comp/cw/code/tokenizer/ads/ll/lltest Binary files differdeleted file mode 100755 index b98c5de..0000000 --- a/comp/cw/code/tokenizer/ads/ll/lltest +++ /dev/null diff --git a/comp/lucas-standen-NEA/code/Makefile b/comp/lucas-standen-NEA/code/Makefile new file mode 100644 index 0000000..a30526c --- /dev/null +++ b/comp/lucas-standen-NEA/code/Makefile @@ -0,0 +1,6 @@ +all: + cd ads; make + cd parser; make + +tests: all + cd ads; make tests diff --git a/comp/lucas-standen-NEA/code/ads/Makefile b/comp/lucas-standen-NEA/code/ads/Makefile new file mode 100644 index 0000000..d6332cb --- /dev/null +++ b/comp/lucas-standen-NEA/code/ads/Makefile @@ -0,0 +1,6 @@ +all: + cd dict; make + cd ll; make +tests: all + cd dict; make test + cd ll; make test diff --git a/comp/cw/code/ads/dict/Makefile b/comp/lucas-standen-NEA/code/ads/dict/Makefile index f224267..f224267 100644 --- a/comp/cw/code/ads/dict/Makefile +++ b/comp/lucas-standen-NEA/code/ads/dict/Makefile diff --git a/comp/cw/code/ads/dict/dict.c b/comp/lucas-standen-NEA/code/ads/dict/dict.c index 551afca..551afca 100644 --- a/comp/cw/code/ads/dict/dict.c +++ b/comp/lucas-standen-NEA/code/ads/dict/dict.c diff --git a/comp/cw/code/ads/dict/dict.h b/comp/lucas-standen-NEA/code/ads/dict/dict.h index e6ab69d..e6ab69d 100644 --- a/comp/cw/code/ads/dict/dict.h +++ b/comp/lucas-standen-NEA/code/ads/dict/dict.h diff --git a/comp/cw/code/ads/dict/dicttest b/comp/lucas-standen-NEA/code/ads/dict/dicttest Binary files differindex dddf2a0..dddf2a0 100755 --- a/comp/cw/code/ads/dict/dicttest +++ b/comp/lucas-standen-NEA/code/ads/dict/dicttest diff --git a/comp/cw/code/ads/dict/dicttest.c b/comp/lucas-standen-NEA/code/ads/dict/dicttest.c index 4a20870..4a20870 100644 --- a/comp/cw/code/ads/dict/dicttest.c +++ b/comp/lucas-standen-NEA/code/ads/dict/dicttest.c diff --git a/comp/cw/code/ads/ll/Makefile b/comp/lucas-standen-NEA/code/ads/ll/Makefile index aaf0241..aaf0241 100644 --- a/comp/cw/code/ads/ll/Makefile +++ b/comp/lucas-standen-NEA/code/ads/ll/Makefile diff --git a/comp/cw/code/ads/ll/ll.c b/comp/lucas-standen-NEA/code/ads/ll/ll.c index c45ab0c..ba0a0df 100644 --- a/comp/cw/code/ads/ll/ll.c +++ b/comp/lucas-standen-NEA/code/ads/ll/ll.c @@ -41,6 +41,13 @@ void *llgetat(ll_t *head, int index){ } } +ll_t *llgetendnode(ll_t *head){ + if (head->next == NULL) + return head; + else + return llgetendnode(head->next); +} + void llfreeall(ll_t *head){ if (head->next != NULL) llfreeall(head->next); diff --git a/comp/cw/code/ads/ll/ll.h b/comp/lucas-standen-NEA/code/ads/ll/ll.h index 30830b1..33b4d57 100644 --- a/comp/cw/code/ads/ll/ll.h +++ b/comp/lucas-standen-NEA/code/ads/ll/ll.h @@ -12,4 +12,5 @@ ll_t *llalloc(); void llsetdata(ll_t *node, void *data); void llsetnext(ll_t *node, ll_t *next); void *llgetat(ll_t *head, int index); +ll_t *llgetendnode(ll_t *head); void llfreeall(ll_t *head); diff --git a/comp/cw/code/ads/ll/lltest b/comp/lucas-standen-NEA/code/ads/ll/lltest Binary files differindex b98c5de..14653f6 100755 --- a/comp/cw/code/ads/ll/lltest +++ b/comp/lucas-standen-NEA/code/ads/ll/lltest diff --git a/comp/cw/code/tokenizer/ads/ll/lltest.c b/comp/lucas-standen-NEA/code/ads/ll/lltest.c index 8aa6514..454acdf 100644 --- a/comp/cw/code/tokenizer/ads/ll/lltest.c +++ b/comp/lucas-standen-NEA/code/ads/ll/lltest.c @@ -13,6 +13,7 @@ int main(){ } for (int i = 0; i < 4; i++) printf("%s\n", (char *)llgetat(head, i)); + printf("%s\n", llgetendnode(head)->data); llfreeall(head); } diff --git a/comp/cw/code/parser/Makefile b/comp/lucas-standen-NEA/code/parser/Makefile index 9325d95..9325d95 100644 --- a/comp/cw/code/parser/Makefile +++ b/comp/lucas-standen-NEA/code/parser/Makefile diff --git a/comp/cw/code/parser/parser b/comp/lucas-standen-NEA/code/parser/parser Binary files differindex 9d996a8..9d996a8 100755 --- a/comp/cw/code/parser/parser +++ b/comp/lucas-standen-NEA/code/parser/parser diff --git a/comp/cw/code/parser/parser.c b/comp/lucas-standen-NEA/code/parser/parser.c index 3162841..3162841 100644 --- a/comp/cw/code/parser/parser.c +++ b/comp/lucas-standen-NEA/code/parser/parser.c diff --git a/comp/cw/code/parser/preprocessor.c b/comp/lucas-standen-NEA/code/parser/preprocessor.c index 92c6127..92c6127 100644 --- a/comp/cw/code/parser/preprocessor.c +++ b/comp/lucas-standen-NEA/code/parser/preprocessor.c diff --git a/comp/cw/code/parser/preprocessor.h b/comp/lucas-standen-NEA/code/parser/preprocessor.h index 855240f..855240f 100644 --- a/comp/cw/code/parser/preprocessor.h +++ b/comp/lucas-standen-NEA/code/parser/preprocessor.h diff --git a/comp/cw/code/parser/readfile.c b/comp/lucas-standen-NEA/code/parser/readfile.c index 391d5a5..391d5a5 100644 --- a/comp/cw/code/parser/readfile.c +++ b/comp/lucas-standen-NEA/code/parser/readfile.c diff --git a/comp/cw/code/parser/readfile.h b/comp/lucas-standen-NEA/code/parser/readfile.h index 12d98ec..12d98ec 100644 --- a/comp/cw/code/parser/readfile.h +++ b/comp/lucas-standen-NEA/code/parser/readfile.h diff --git a/comp/cw/code/parser/sample.zpy b/comp/lucas-standen-NEA/code/parser/sample.zpy index e289d9d..e289d9d 100644 --- a/comp/cw/code/parser/sample.zpy +++ b/comp/lucas-standen-NEA/code/parser/sample.zpy diff --git a/comp/cw/overview b/comp/lucas-standen-NEA/overview index 5f7904e..5f7904e 100644 --- a/comp/cw/overview +++ b/comp/lucas-standen-NEA/overview diff --git a/comp/lucas-standen-NEA/writeup/coverpage.html b/comp/lucas-standen-NEA/writeup/coverpage.html new file mode 100644 index 0000000..a8338b4 --- /dev/null +++ b/comp/lucas-standen-NEA/writeup/coverpage.html @@ -0,0 +1,131 @@ +<!-- Creator : groff version 1.23.0 --> +<!-- CreationDate: Tue Apr 30 14:21:39 2024 --> +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" +"http://www.w3.org/TR/html4/loose.dtd"> +<html> +<head> +<meta name="generator" content="groff -Thtml, see www.gnu.org"> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<meta name="Content-Style" content="text/css"> +<style type="text/css"> + p { margin-top: 0; margin-bottom: 0; vertical-align: top } + pre { margin-top: 0; margin-bottom: 0; vertical-align: top } + table { margin-top: 0; margin-bottom: 0; vertical-align: top } + h1 { text-align: center } +</style> +<title>NEA coverpage</title> + +</head> +<body> + +<h1 align="center">NEA coverpage</h1> + +<a href="#1. Analysis">1. Analysis</a><br> +<a href="#1.1. Overview">1.1. Overview</a><br> +<a href="#1.2. Examples of similar projects">1.2. Examples of similar projects</a><br> +<a href="#1.2.1. Python">1.2.1. Python</a><br> +<a href="#1.2.2. Lisp">1.2.2. Lisp</a><br> +<a href="#1.2.3. Perl">1.2.3. Perl</a><br> +<a href="#2. Design">2. Design</a><br> +<a href="#3. Technical Solution">3. Technical Solution</a><br> +<a href="#4. Testing">4. Testing</a><br> +<a href="#5. Evaluation">5. Evaluation</a><br> + +<hr> + + +<p align="center"><i>Lucas standen</i> <br> +7949</p> + + +<p align="center" style="margin-top: 1em"><i>ABSTRACT</i></p> + +<h2>1. Analysis +<a name="1. Analysis"></a> +</h2> + + +<h3>1.1. Overview +<a name="1.1. Overview"></a> +</h3> + + +<p style="margin-top: 1em"><i><b>Zippy LANG</b></i></p> + +<p style="margin-top: 1em">A next generation language, for +general use. Designed for keeping code simple, neet and +readable. <br> +Zippy will be a modern functional language. It will be +interpreted like python/perl and lisp. Its syntax should be +similar to lisp.</p> + +<p style="margin-top: 1em">Some interesting features that +Zippy will have is treating everthing in functions, scopes +that allow for manual but safe memory management, and +interoperablity with C <br> +libarys</p> + +<h3>1.2. Examples of similar projects +<a name="1.2. Examples of similar projects"></a> +</h3> + + +<h4>1.2.1. Python +<a name="1.2.1. Python"></a> +</h4> + + +<p style="margin-top: 1em">Python is a high level OOP +language that was designed in 1991. It was made to make +programming easy whie still being able to use some of +C’s functions. <br> +Although it has become standard for many usecases, it is +slow and inefficent, and very bloated.</p> + +<h4>1.2.2. Lisp +<a name="1.2.2. Lisp"></a> +</h4> + + +<p style="margin-top: 1em">Lisp is the second ever +programming language, developed at MiT, it is the first +functional language, creating many common features like +higher order functions, <br> +recursion, and garbage collection. It is generally not used +anymore as it feels old compared to other functional +languages, like ocaml or haskell.</p> + +<h4>1.2.3. Perl +<a name="1.2.3. Perl"></a> +</h4> + + +<p style="margin-top: 1em">Perl is scripting lang designed +for use in linux, when bash is too slow, or not suited for +the job. <br> +Perl is often described as the glue of the universe (see +xkcd https://3d.xkcd.com/224/). Its syntax is quite strange +however and it is slow. Making it poorly suited for general +use.</p> + +<h2>2. Design +<a name="2. Design"></a> +</h2> + + +<h2>3. Technical Solution +<a name="3. Technical Solution"></a> +</h2> + + +<h2>4. Testing +<a name="4. Testing"></a> +</h2> + + +<h2>5. Evaluation +<a name="5. Evaluation"></a> +</h2> +<hr> +</body> +</html> diff --git a/comp/lucas-standen-NEA/writeup/coverpage.ms b/comp/lucas-standen-NEA/writeup/coverpage.ms new file mode 100644 index 0000000..d6ab182 --- /dev/null +++ b/comp/lucas-standen-NEA/writeup/coverpage.ms @@ -0,0 +1,46 @@ +.TL +NEA coverpage +.AU +Lucas standen +.AI +7949 +.AB +.NH 1 +Analysis +.NH 2 +Overview +.PP +.B Zippy +.B LANG +.PP +A next generation language, for general use. Designed for keeping code simple, neet and readable. + Zippy will be a modern functional language. It will be interpreted like python/perl and lisp. Its syntax should be similar to lisp. +.PP +Some interesting features that Zippy will have is treating everthing in functions, scopes that allow for manual but safe memory management, and interoperablity with C + libarys +.NH 2 +Examples of similar projects +.NH 3 +Python +.PP +Python is a high level OOP language that was designed in 1991. It was made to make programming easy whie still being able to use some of C's functions. + Although it has become standard for many usecases, it is slow and inefficent, and very bloated. +.NH 3 +Lisp +.PP +Lisp is the second ever programming language, developed at MiT, it is the first functional language, creating many common features like higher order functions, + recursion, and garbage collection. It is generally not used anymore as it feels old compared to other functional languages, like ocaml or haskell. +.NH 3 +Perl +.PP +Perl is scripting lang designed for use in linux, when bash is too slow, or not suited for the job. + Perl is often described as the glue of the universe (see xkcd https://3d.xkcd.com/224/). Its syntax is quite strange however and it is slow. Making it poorly suited for general use. +.NH 1 +Design +.NH 1 +Technical Solution +.NH 1 +Testing +.NH 1 +Evaluation +.AE diff --git a/comp/lucas-standen-NEA/writeup/coverpage.pdf b/comp/lucas-standen-NEA/writeup/coverpage.pdf Binary files differnew file mode 100644 index 0000000..92abc11 --- /dev/null +++ b/comp/lucas-standen-NEA/writeup/coverpage.pdf diff --git a/comp/lucas-standen-NEA/writeup/make.sh b/comp/lucas-standen-NEA/writeup/make.sh new file mode 100755 index 0000000..6f7c53e --- /dev/null +++ b/comp/lucas-standen-NEA/writeup/make.sh @@ -0,0 +1,2 @@ +#!/bin/bash +for i in $(ls | grep .ms); do groff -ms $i -T html > $(echo $i | cut -f1 -d".").html; done diff --git a/comp/work/31/__pycache__/bubble.cpython-312.pyc b/comp/work/31/__pycache__/bubble.cpython-312.pyc Binary files differnew file mode 100644 index 0000000..a91900d --- /dev/null +++ b/comp/work/31/__pycache__/bubble.cpython-312.pyc diff --git a/comp/work/31/__pycache__/merge.cpython-312.pyc b/comp/work/31/__pycache__/merge.cpython-312.pyc Binary files differnew file mode 100644 index 0000000..f390001 --- /dev/null +++ b/comp/work/31/__pycache__/merge.cpython-312.pyc diff --git a/comp/work/31/bubble.py b/comp/work/31/bubble.py new file mode 100644 index 0000000..c45f903 --- /dev/null +++ b/comp/work/31/bubble.py @@ -0,0 +1,22 @@ +import sys + + +def sort(list): + length = len(list) + for i in range(length - 1): + for j in range(length - i - 1): + if list[j] > list[j+1]: + tmp = list[j] + list[j] = list[j+1] + list[j+1] = tmp + return list + + +if __name__ == "__main__": + count = int(sys.argv[1]) + + num = [] + for i in range(count): + num.append(int(input(f"number {i}: "))) + + print(sort(num)) diff --git a/comp/work/31/menu.py b/comp/work/31/menu.py new file mode 100644 index 0000000..8f3c009 --- /dev/null +++ b/comp/work/31/menu.py @@ -0,0 +1,20 @@ +import merge +import bubble + + +while True: + list = [] + inp = "" + print("enter nums, then enter END") + while inp != "END": + inp = input("number: ") + if inp != "END": + list.append(inp) + + sort = int(input("1) bubble, 2) merge: ")) + + if sort == 1: + print(*merge.sort(list), sep=", ") + + else: + print(*bubble.sort(list), sep=", ") diff --git a/comp/work/31/merge.py b/comp/work/31/merge.py new file mode 100644 index 0000000..0947aa4 --- /dev/null +++ b/comp/work/31/merge.py @@ -0,0 +1,39 @@ +def sort(list): + length = len(list) + l1 = [] + l2 = [] + for i in range(length): + if i >= (length / 2): + l2.append(list[i]) + else: + l1.append(list[i]) + if length > 2: + l1 = sort(l1) + l2 = sort(l2) + return merge(l1, l2) + + +def merge(l1, l2): + i = 0 + j = 0 + output = [] + while i < len(l1) and j < len(l2): + if l1[i] < l2[j]: + output.append(l1[i]) + i += 1 + else: + output.append(l2[j]) + j += 1 + + while i < len(l1): + output.append(l1[i]) + i += 1 + while j < len(l2): + output.append(l2[j]) + j += 1 + return output + + +if __name__ == "__main__": + # call split on the list, will return a sorted one + print(sort([1, 4, 2, 4, 2, 5, 6, 2, 7])) |