From 52a71d5facc1bb100ec84760d5dca0a35adcf6a2 Mon Sep 17 00:00:00 2001 From: Augusto Date: Thu, 2 May 2019 18:08:58 +0100 Subject: [PATCH] brainfuck exam exercise readme --- subjects/brainfuck.en.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 subjects/brainfuck.en.md diff --git a/subjects/brainfuck.en.md b/subjects/brainfuck.en.md new file mode 100644 index 00000000..896dd633 --- /dev/null +++ b/subjects/brainfuck.en.md @@ -0,0 +1,34 @@ +## brainfuck + +### Instructions + +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. + +And its output : + +```console +student@ubuntu:~/student/brainfuck$ go build +student@ubuntu:~/student/brainfuck$ ./brainfuck "++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>." | cat -e +Hello World!$ +student@ubuntu:~/student/brainfuck$ ./brainfuck "+++++[>++++[>++++H>+++++i<<-]>>>++\n<<<<-]>>--------.>+++++.>." | cat -e +Hi$ +student@ubuntu:~/student/brainfuck$ ./brainfuck | cat -e +$ +student@ubuntu:~/student/brainfuck$ +```