Merge branch 'master' of https://github.com/dopefishh/sws1
authorChris <mail@chriskamphuis.com>
Sun, 8 Feb 2015 21:28:24 +0000 (22:28 +0100)
committerChris <mail@chriskamphuis.com>
Sun, 8 Feb 2015 21:28:24 +0000 (22:28 +0100)
17 files changed:
.gitignore [new file with mode: 0644]
ass1/chris/sws1-s4109503-s4202015.tar.gz [deleted file]
ass1/mart/s4109503-s4202015-sws1.tar.gz [deleted file]
ass1/mart/sws1-s4109503-s4202015/exercise2/Makefile
ass1/mart/sws1-s4109503-s4202015/exercise2/parsegenome.c
ass2/assignment2.pdf [new file with mode: 0644]
ass2/mart/sws1-s4109503-s4202015/Makefile [new file with mode: 0644]
ass2/mart/sws1-s4109503-s4202015/exercise1a.txt [new file with mode: 0644]
ass2/mart/sws1-s4109503-s4202015/exercise1b [new file with mode: 0755]
ass2/mart/sws1-s4109503-s4202015/exercise1b.c [new file with mode: 0644]
ass2/mart/sws1-s4109503-s4202015/exercise1c [new file with mode: 0644]
ass2/mart/sws1-s4109503-s4202015/exercise1d [moved from ass1/chris/sws1-s4109503-s4202015/exercise2/parsegenome with 62% similarity]
ass2/mart/sws1-s4109503-s4202015/exercise1d.c [new file with mode: 0644]
ass2/mart/sws1-s4109503-s4202015/exercise1d.txt [new file with mode: 0644]
ass2/mart/sws1-s4109503-s4202015/exercise1e.txt [new file with mode: 0644]
ass2/mart/sws1-s4109503-s4202015/exercise2 [new file with mode: 0755]
ass2/mart/sws1-s4109503-s4202015/exercise2.c [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..10d00b5
--- /dev/null
@@ -0,0 +1 @@
+*.gz
diff --git a/ass1/chris/sws1-s4109503-s4202015.tar.gz b/ass1/chris/sws1-s4109503-s4202015.tar.gz
deleted file mode 100644 (file)
index d769324..0000000
Binary files a/ass1/chris/sws1-s4109503-s4202015.tar.gz and /dev/null differ
diff --git a/ass1/mart/s4109503-s4202015-sws1.tar.gz b/ass1/mart/s4109503-s4202015-sws1.tar.gz
deleted file mode 100644 (file)
index 6a7d149..0000000
Binary files a/ass1/mart/s4109503-s4202015-sws1.tar.gz and /dev/null differ
index fa18e55..9adc5d1 100644 (file)
@@ -5,4 +5,4 @@ all: parsegenome.c
        $(CC) $(CFLAGS) parsegenome.c -o parsegenome
 
 clean:
-       rm -vf parsegenome
+       $(RM) parsegenome
index 9acb1cf..aaf6471 100644 (file)
@@ -1,6 +1,6 @@
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
+#include <stdint.h>    /* We save the all the frequencies in a 64 bit int */
+#include <stdio.h>     /* We extract/add them using bitshifts */
+#include <stdlib.h>    /* When no filepath is specified assume stdin */
 #include <string.h>
 
 int main(int argc, char* argv[])
diff --git a/ass2/assignment2.pdf b/ass2/assignment2.pdf
new file mode 100644 (file)
index 0000000..b4db285
Binary files /dev/null and b/ass2/assignment2.pdf differ
diff --git a/ass2/mart/sws1-s4109503-s4202015/Makefile b/ass2/mart/sws1-s4109503-s4202015/Makefile
new file mode 100644 (file)
index 0000000..5802a0e
--- /dev/null
@@ -0,0 +1,14 @@
+CC=gcc
+CFLAGS=-std=c99 -Wall -Wextra
+
+all: exercise1 exercise2
+
+exercise2: exercise2.c
+       $(CC) $(CFLAGS) -O3 exercise2.c -o exercise2
+
+exercise1: exercise1b.c exercise1d.c
+       $(CC) $(CFLAGS) exercise1b.c -o exercise1b
+       $(CC) $(CFLAGS) exercise1d.c -o exercise1d
+
+clean:
+       $(RM) exercise1b exercise1d exercise2
diff --git a/ass2/mart/sws1-s4109503-s4202015/exercise1a.txt b/ass2/mart/sws1-s4109503-s4202015/exercise1a.txt
new file mode 100644 (file)
index 0000000..ff19321
--- /dev/null
@@ -0,0 +1,6 @@
+/dev/random generates random bytes from a 4096 bits entropy pool and will only
+use fresh entropy.
+
+/dev/urandom generates random bytes from a 4096 bits entropy pool too but it
+reuses entropy while the entropy pool is filled. Because of the reuse
+/dev/urandom is much faster then /dev/random
diff --git a/ass2/mart/sws1-s4109503-s4202015/exercise1b b/ass2/mart/sws1-s4109503-s4202015/exercise1b
new file mode 100755 (executable)
index 0000000..663e25a
Binary files /dev/null and b/ass2/mart/sws1-s4109503-s4202015/exercise1b differ
diff --git a/ass2/mart/sws1-s4109503-s4202015/exercise1b.c b/ass2/mart/sws1-s4109503-s4202015/exercise1b.c
new file mode 100644 (file)
index 0000000..1f8a43e
--- /dev/null
@@ -0,0 +1,14 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(void)
+{
+       FILE *f = fopen("/dev/urandom", "r");
+       char c;
+       do {
+               c = fgetc(f);
+               printf("%i %u %x\n", c, c, c);
+       } while(c != 42);
+       fclose(f);
+       return 0;
+}
diff --git a/ass2/mart/sws1-s4109503-s4202015/exercise1c b/ass2/mart/sws1-s4109503-s4202015/exercise1c
new file mode 100644 (file)
index 0000000..5dc9dbd
--- /dev/null
@@ -0,0 +1,16 @@
+-82 4294967214 ffffffae
+91 91 5b
+-63 4294967233 ffffffc1
+-41 4294967255 ffffffd7
+-22 4294967274 ffffffea
+103 103 67
+-33 4294967263 ffffffdf
+-115 4294967181 ffffff8d
+-90 4294967206 ffffffa6
+108 108 6c
+60 60 3c
+-42 4294967254 ffffffd6
+-55 4294967241 ffffffc9
+-26 4294967270 ffffffe6
+25 25 19
+42 42 2a
similarity index 62%
rename from ass1/chris/sws1-s4109503-s4202015/exercise2/parsegenome
rename to ass2/mart/sws1-s4109503-s4202015/exercise1d
index 602189d..89a79b9 100755 (executable)
Binary files a/ass1/chris/sws1-s4109503-s4202015/exercise2/parsegenome and b/ass2/mart/sws1-s4109503-s4202015/exercise1d differ
diff --git a/ass2/mart/sws1-s4109503-s4202015/exercise1d.c b/ass2/mart/sws1-s4109503-s4202015/exercise1d.c
new file mode 100644 (file)
index 0000000..07dfa41
--- /dev/null
@@ -0,0 +1,15 @@
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(void)
+{
+       FILE *f = fopen("/dev/urandom", "r");
+       uint16_t c;
+       do {
+               c = fgetc(f)+fgetc(f)*256;
+               printf("%04x\n", c);
+       } while(c != 42);
+       fclose(f);
+       return 0;
+}
diff --git a/ass2/mart/sws1-s4109503-s4202015/exercise1d.txt b/ass2/mart/sws1-s4109503-s4202015/exercise1d.txt
new file mode 100644 (file)
index 0000000..651c337
--- /dev/null
@@ -0,0 +1,10 @@
+271325
+40516
+65532
+23964
+41888
+95550
+234585
+50847
+85879
+87536
diff --git a/ass2/mart/sws1-s4109503-s4202015/exercise1e.txt b/ass2/mart/sws1-s4109503-s4202015/exercise1e.txt
new file mode 100644 (file)
index 0000000..6c4b271
--- /dev/null
@@ -0,0 +1 @@
+{ for ((i=0;i<10;i++)); do ./exercise1d | wc -l; done; } > exercise1d.txt
diff --git a/ass2/mart/sws1-s4109503-s4202015/exercise2 b/ass2/mart/sws1-s4109503-s4202015/exercise2
new file mode 100755 (executable)
index 0000000..fda7b35
Binary files /dev/null and b/ass2/mart/sws1-s4109503-s4202015/exercise2 differ
diff --git a/ass2/mart/sws1-s4109503-s4202015/exercise2.c b/ass2/mart/sws1-s4109503-s4202015/exercise2.c
new file mode 100644 (file)
index 0000000..c05c0ed
--- /dev/null
@@ -0,0 +1,27 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+void print(char *address, unsigned int size)
+{
+       printf("address: %p, size: %u, psize: %u\n", address, size, sizeof(address));
+       for(unsigned char i=0; i<size; i++)
+       {
+               int value = *((char*)(address+i));
+               printf("%p %x %u\n", address+i, value, value);
+       }
+}
+
+int main(void)
+{
+       short i = 0x1234;
+       char x = -127;
+       long sn1 = 4109503;/*
+       long sn2 = 4202015;
+       int y[2] = {0x11223344, 0x443332211};*/
+       printf("address   content (hex)  content(dec)\n");
+
+       print((char *)&i, sizeof(i));
+       print((char *)&x, sizeof(x));
+       print((char *)&sn1, sizeof(sn1));
+       return 0;
+}