Website Summary Files Commits Branches @commit @diff @stats
path: root / homework / 81270 / brainf-interpret / primes.b
diff options
context:
space:
mode:
Commit8e84b639815b291d4c4e4041e4c5611202e012c1 (patch)
Author
 Bilyal Mestanov <bmestanov@gmail.com>
2018-11-28 12:43:19 +0200
Committer
 dtrendafilov <trendafilov.dn@gmail.com>
2018-11-28 12:43:19 +0200
Filesc4ab2a5bc325eabe1e70214e3966c0c6802852ef /homework/81270/brainf-interpret/primes.b
IPL-8e84b639815b291d4c4e4041e4c5611202e012c1.tar
IPL-8e84b639815b291d4c4e4041e4c5611202e012c1.tar.gz
IPL-8e84b639815b291d4c4e4041e4c5611202e012c1.zip
Parentb98a9799f15c8ad0275175a1d8d013c4f6e0176f (diff)
Add brainf interpreter (#58)
1 files changed, 221 insertions, 0 deletions
-rw-r--r--homework/81270/brainf-interpret/primes.b221
diff --git a/homework/81270/brainf-interpret/primes.b b/homework/81270/brainf-interpret/primes.b
new file mode 100644
index 0000000..294fc6b
--- /dev/null
+++ b/homework/81270/brainf-interpret/primes.b
@@ -0,0 +1,221 @@
+===================================================================
+======================== 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