aboutsummaryrefslogtreecommitdiff
path: root/exam_final/subjects/12-0-brainfuck
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2019-07-26 23:17:36 +0200
committerCharles <sircharlesaze@gmail.com>2019-07-26 23:17:36 +0200
commit8ec5431354bdb582455e8c32758098c5a0fdada2 (patch)
tree480c68814f822439850029df0e0249a2cafb8177 /exam_final/subjects/12-0-brainfuck
parent475449dd4b1f3308bac6f72c34d87812216a0738 (diff)
downloadpiscine-8ec5431354bdb582455e8c32758098c5a0fdada2.tar.gz
piscine-8ec5431354bdb582455e8c32758098c5a0fdada2.tar.bz2
piscine-8ec5431354bdb582455e8c32758098c5a0fdada2.zip
exam final
Diffstat (limited to 'exam_final/subjects/12-0-brainfuck')
-rw-r--r--exam_final/subjects/12-0-brainfuck/examples.txt6
-rw-r--r--exam_final/subjects/12-0-brainfuck/subject.en.txt32
-rw-r--r--exam_final/subjects/12-0-brainfuck/subject.fr.txt32
3 files changed, 70 insertions, 0 deletions
diff --git a/exam_final/subjects/12-0-brainfuck/examples.txt b/exam_final/subjects/12-0-brainfuck/examples.txt
new file mode 100644
index 0000000..b5bc38a
--- /dev/null
+++ b/exam_final/subjects/12-0-brainfuck/examples.txt
@@ -0,0 +1,6 @@
+$>./brainfuck "++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>." | cat -e
+Hello World!$
+$>./brainfuck "+++++[>++++[>++++H>+++++i<<-]>>>++\n<<<<-]>>--------.>+++++.>." | cat -e
+Hi$
+$>./brainfuck | cat -e
+$
diff --git a/exam_final/subjects/12-0-brainfuck/subject.en.txt b/exam_final/subjects/12-0-brainfuck/subject.en.txt
new file mode 100644
index 0000000..a926e71
--- /dev/null
+++ b/exam_final/subjects/12-0-brainfuck/subject.en.txt
@@ -0,0 +1,32 @@
+Assignment name : brainfuck
+Expected files : *.c, *.h
+Allowed functions: write, malloc, free
+--------------------------------------------------------------------------------
+
+Write a Brainfuck interpreter program.
+The source code will be given as first parameter.
+The code will always be valid, with no more than 4096 operations.
+Brainfuck is a minimalist language. It consists of an array of bytes
+(in our case, let's say 2048 bytes) initialized to zero,
+and a pointer to its first byte.
+
+Every operator consists of a single character :
+- '>' increment the pointer ;
+- '<' decrement the pointer ;
+- '+' increment the pointed byte ;
+- '-' decrement the pointed byte ;
+- '.' print the pointed byte on standard output ;
+- '[' go to the matching ']' if the pointed byte is 0 (while start) ;
+- ']' go to the matching '[' if the pointed byte is not 0 (while end).
+
+Any other character is a comment.
+
+Examples:
+
+$>./brainfuck "++++++++++[>+++++++>++++++++++>+++>+<<<<-]
+>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>." | cat -e
+Hello World!$
+$>./brainfuck "+++++[>++++[>++++H>+++++i<<-]>>>++\n<<<<-]>>--------.>+++++.>." | cat -e
+Hi$
+$>./brainfuck | cat -e
+$
diff --git a/exam_final/subjects/12-0-brainfuck/subject.fr.txt b/exam_final/subjects/12-0-brainfuck/subject.fr.txt
new file mode 100644
index 0000000..2a15973
--- /dev/null
+++ b/exam_final/subjects/12-0-brainfuck/subject.fr.txt
@@ -0,0 +1,32 @@
+Assignment name : brainfuck
+Expected files : *.c, *.h
+Allowed functions: write, malloc, free
+--------------------------------------------------------------------------------
+
+Écrire un programme capable d'interpréter du Brainfuck.
+Le code source sera passé en premier paramètre.
+Le code transmis sera toujours valide, et ne comportera pas plus de 4096 opérations.
+Le Brainfuck est un langage minimaliste constitué d'un tableau d'octets
+(dans le cadre de cet exercice, 2048 octets) tous initialisés à 0,
+et d'un pointeur sur son premier octet.
+
+Voici les différents opérateurs du Brainfuck :
+- '>' incrémente le pointeur ;
+- '<' décrémente le pointeur ;
+- '+' incrémente l'octet pointé ;
+- '-' décrémente l'octet pointé ;
+- '.' affiche l'octet pointé sur la sortie standard ;
+- '[' va au ']' correspondant si l'octet pointé est égal à 0 (début de boucle) ;
+- ']' va au '[' correspondant si l'octet pointé est différent de 0 (fin de boucle).
+
+Tout autre caractère est un commentaire.
+
+Exemples:
+
+$>./brainfuck "++++++++++[>+++++++>++++++++++>+++>+<<<<-]
+>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>." | cat -e
+Hello World!$
+$>./brainfuck "+++++[>++++[>++++H>+++++i<<-]>>>++\n<<<<-]>>--------.>+++++.>." | cat -e
+Hi$
+$>./brainfuck | cat -e
+$