Website Summary Files Commits Branches @commit @diff @stats
path: root / homework / 81270 / brainf-interpret
diff options
context:
space:
mode:
Commitaeb0d4f887a0c18c36b59acc7b5df08e62020c50 (patch)
Author
 Dimitar Trendafilov <dimitar@coherent-labs.com>
2020-10-11 21:32:48 +0300
Committer
 Dimitar Trendafilov <dimitar@coherent-labs.com>
2020-10-11 21:33:38 +0300
Filesb6abdc6e1810326b587f2a160f39570f1f568f27 /homework/81270/brainf-interpret
IPL-aeb0d4f887a0c18c36b59acc7b5df08e62020c50.tar
IPL-aeb0d4f887a0c18c36b59acc7b5df08e62020c50.tar.gz
IPL-aeb0d4f887a0c18c36b59acc7b5df08e62020c50.zip
Parent154b7cd30f21af1554ca26986ff1643e28857727 (diff)
Removed old homeworks
diff --git a/homework/81270/brainf-interpret/CMakeLists.txt b/homework/81270/brainf-interpret/CMakeLists.txt
deleted file mode 100644
index 7407ada..0000000
--- a/homework/81270/brainf-interpret/CMakeLists.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-cmake_minimum_required(VERSION 3.9)
-project(brainf-interpret)
-
-add_executable(brainf-interpret Interpreter.cpp) \ No newline at end of file
diff --git a/homework/81270/brainf-interpret/Interpreter.cpp b/homework/81270/brainf-interpret/Interpreter.cpp
deleted file mode 100644
index ebca77b..0000000
--- a/homework/81270/brainf-interpret/Interpreter.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-//
-// Created by bmestanov on 15.11.18.
-//
-
-#define TAPE_SIZE 65536
-#define STACK_SIZE 8192
-
-#include <fstream>
-#include <iostream>
-
-void failIf(bool condition, const char *message) {
- if (condition) {
- std::cerr << message;
- exit(1);
- }
-}
-
-int main(int argc, char **argv) {
- argc--;
- argv++;
- char memory[TAPE_SIZE] = {0};
- char *pp = memory; // program pointer
- long stack[STACK_SIZE];
- int sp = 0; // stack pointer
-
- failIf(!argv[0], "No file provided");
-
- std::ifstream file;
- file.open(argv[0]);
-
- failIf(!file, "Error opening file");
-
- while (!file.eof()) {
- auto symbol = static_cast<char>(file.get());
- switch (symbol) {
- case '>': {
- // Allow memory wrap
- pp = memory + (pp - memory + 1) % TAPE_SIZE;
- break;
- }
- case '<': {
- pp = memory + (pp - memory - 1) % TAPE_SIZE;
- break;
- }
- case '+': {
- (*pp)++;
- break;
- }
- case '-': {
- (*pp)--;
- break;
- }
- case '.': {
- std::putchar(*pp);
- break;
- }
- case ',': {
- *pp = static_cast<char>(std::getchar());
- break;
- }
- case '[': {
- if (*pp) {
- failIf(sp == STACK_SIZE, "Stack overflow");
- stack[sp++] = file.tellg();
- } else {
- long move = 1;
- while (move > 0) {
- auto next = static_cast<char>(file.get());
- if (next == '[') move++;
- if (next == ']') move--;
- if (file.eof()) failIf(true, "Invalid syntax");
- }
- }
- break;
- }
- case ']': {
- failIf(sp == 0, "Invalid syntax");
- if (*pp) {
- long top = stack[sp - 1];
- file.seekg(top);
- } else {
- sp--;
- }
- }
- default:;
- }
- }
-
- return 0;
-} \ No newline at end of file
diff --git a/homework/81270/brainf-interpret/hello.b b/homework/81270/brainf-interpret/hello.b
deleted file mode 100644
index a2de5df..0000000
--- a/homework/81270/brainf-interpret/hello.b
+++ /dev/null
@@ -1,3 +0,0 @@
->+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]>++++++++[<++++>-]
-<.#>+++++++++++[<+++++>-]<.>++++++++[<+++>-]<.+++.------.--------.[-]>++++++++[
-<++++>-]<+.[-]++++++++++.
diff --git a/homework/81270/brainf-interpret/primes.b b/homework/81270/brainf-interpret/primes.b
deleted file mode 100644
index 294fc6b..0000000
--- a/homework/81270/brainf-interpret/primes.b
+++ /dev/null
@@ -1,221 +0,0 @@
-===================================================================
-======================== OUTPUT STRING ============================
-===================================================================
->++++++++[<++++++++>-]<++++++++++++++++.[-]
->++++++++++[<++++++++++>-]<++++++++++++++.[-]
->++++++++++[<++++++++++>-]<+++++.[-]
->++++++++++[<++++++++++>-]<+++++++++.[-]
->++++++++++[<++++++++++>-]<+.[-]
->++++++++++[<++++++++++>-]<+++++++++++++++.[-]
->+++++[<+++++>-]<+++++++.[-]
->++++++++++[<++++++++++>-]<+++++++++++++++++.[-]
->++++++++++[<++++++++++>-]<++++++++++++.[-]
->+++++[<+++++>-]<+++++++.[-]
->++++++++++[<++++++++++>-]<++++++++++++++++.[-]
->++++++++++[<++++++++++>-]<+++++++++++.[-]
->+++++++[<+++++++>-]<+++++++++.[-]
->+++++[<+++++>-]<+++++++.[-]
-
-===================================================================
-======================== INPUT NUMBER ============================
-===================================================================
-+ cont=1
-[
- - cont=0
- >,
- ======SUB10======
- ----------
-
- [ not 10
- <+> cont=1
- =====SUB38======
- ----------
- ----------
- ----------
- --------
-
- >
- =====MUL10=======
- [>+>+<<-]>>[<<+>>-]< dup
-
- >>>+++++++++
- [
- <<<
- [>+>+<<-]>>[<<+>>-]< dup
- [<<+>>-]
- >>-
- ]
- <<<[-]<
- ======RMOVE1======
- <
- [>+<-]
- ]
- <
-]
->>[<<+>>-]<<
-
-===================================================================
-======================= PROCESS NUMBER ===========================
-===================================================================
-
-==== ==== ==== ====
-numd numu teid teiu
-==== ==== ==== ====
-
->+<-
-[
- >+
- ======DUP======
- [>+>+<<-]>>[<<+>>-]<
-
- >+<--
-
- >>>>>>>>+<<<<<<<< isprime=1
-
- [
- >+
-
- <-
-
- =====DUP3=====
- <[>>>+>+<<<<-]>>>>[<<<<+>>>>-]<<<
-
- =====DUP2=====
- >[>>+>+<<<-]>>>[<<<+>>>-]<<< <
-
-
- >>>
-
-
- ====DIVIDES=======
- [>+>+<<-]>>[<<+>>-]< DUP i=div
-
- <<
- [
- >>>>>+ bool=1
- <<<
- [>+>+<<-]>>[<<+>>-]< DUP
- [>>[-]<<-] IF i THEN bool=0
- >>
- [ IF i=0
- <<<<
- [>+>+<<-]>>[<<+>>-]< i=div
- >>>
- - bool=0
- ]
- <<<
- - DEC i
- <<
- -
- ]
-
- +>>[<<[-]>>-]<<
- >[-]< CLR div
- =====END DIVIDES====
-
-
- [>>>>>>[-]<<<<<<-] if divides then isprime=0
-
-
- <<
-
- >>[-]>[-]<<<
- ]
-
- >>>>>>>>
- [
- -
- <<<<<<<[-]<<
-
- [>>+>+<<<-]>>>[<<<+>>>-]<<<
-
- >>
-
-
-
-
- ===================================================================
- ======================== OUTPUT NUMBER ===========================
- ===================================================================
- [>+<-]>
-
- [
- ======DUP======
- [>+>+<<-]>>[<<+>>-]<
-
-
- ======MOD10====
- >+++++++++<
- [
- >>>+<< bool= 1
- [>+>[-]<<-] bool= ten==0
- >[<+>-] ten = tmp
- >[<<++++++++++>>-] if ten=0 ten=10
- <<- dec ten
- <- dec num
- ]
- +++++++++ num=9
- >[<->-]< dec num by ten
-
- =======RROT======
- [>+<-]
- < [>+<-]
- < [>+<-]
- >>>[<<<+>>>-]
- <
-
- =======DIV10========
- >+++++++++<
- [
- >>>+<< bool= 1
- [>+>[-]<<-] bool= ten==0
- >[<+>-] ten = tmp
- >[<<++++++++++>>>+<-] if ten=0 ten=10 inc div
- <<- dec ten
- <- dec num
- ]
- >>>>[<<<<+>>>>-]<<<< copy div to num
- >[-]< clear ten
-
- =======INC1=========
- <+>
- ]
-
- <
- [
- =======MOVER=========
- [>+<-]
-
- =======ADD48========
- +++++++[<+++++++>-]<->
-
- =======PUTC=======
- <.[-]>
-
- ======MOVEL2========
- >[<<+>>-]<
-
- <-
- ]
-
- >++++[<++++++++>-]<.[-]
-
- ===================================================================
- =========================== END FOR ===============================
- ===================================================================
-
-
- >>>>>>>
- ]
- <<<<<<<<
-
-
-
- >[-]<
- [-]
- <<-
-]
-
-======LF========
-
-++++++++++.[-] \ No newline at end of file