From 37173a7008807f133c92d64109b079ec209a34a2 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Sat, 22 Aug 2015 09:58:20 +0200 Subject: Better testing material for bf.prn --- fibonacci.bf | 9 ++++++ kerstboom.bf | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ test.bf | 3 ++ 3 files changed, 106 insertions(+) create mode 100644 fibonacci.bf create mode 100644 kerstboom.bf diff --git a/fibonacci.bf b/fibonacci.bf new file mode 100644 index 0000000..1b61292 --- /dev/null +++ b/fibonacci.bf @@ -0,0 +1,9 @@ +>++++++++++>+>+[ + [+++++[>++++++++<-]>.<++++++[>--------<-]+<<<]>.>>[ + [-]<[>+<-]>>[<<+>+>-]<[>+<-[>+<-[>+<-[>+<-[>+<-[>+<- + [>+<-[>+<-[>+<-[>[-]>+>+<<<-[>+<-]]]]]]]]]]]+>>> + ]<<< +] +This program doesn't terminate; you will have to kill it. +Daniel B Cristofani (cristofdathevanetdotcom) +http://www.hevanet.com/cristofd/brainfuck/ \ No newline at end of file diff --git a/kerstboom.bf b/kerstboom.bf new file mode 100644 index 0000000..1db1e22 --- /dev/null +++ b/kerstboom.bf @@ -0,0 +1,94 @@ +Read in two digit number: +0 1 2 3 4 +N0 N N0cp 10 N1 + +,------------------------------------------------[>+>+<<-]>>[<<+>>-]>>,+[-<<<[-]>>>------------------------------------------------<++++++++++ [<<<[->+>+<<]>>[-<<+>>]>-] >[-<<<+>>>] ]<<<< +# +Now at 0 + +[-] (Clear N0) +>[<+>-]< + + +Layout now: N in 0 + + +Place 'minus' in 1: +>+++++++++++++++++++++++++++++++++++++++++++++< + +Place 'star' in 2: +>>++++++++++++++++++++++++++++++++++++++++++<< + + +Set line counter in 7: +>>>>>>>+<<<<<<< + +Move N from 0 to 9 and 10: +[>>>>>>>>>+>+<<<<<<<<<<-] +Move N from 9 to 0 (leaving N in 10): +>>>>>>>>>[<<<<<<<<<+>>>>>>>>>-]<<<<<<<<< + +Loop on (decreasing) N in 10: +>>>>>>>>>>[<<<<<<<<<< + + + + Move decreasing N from 10 to 3 4 and 5: + >>>>>>>>>>[<<<<<+<+<+>>>>>>>-]<<<<<<<<<< + Move N from 5 to 10: + >>>>>[>>>>>+<<<<<-]<<<<< + + Set 3 and 4 to decreasing N minus 1: + >>>->-<<<< + + Print 'minus' (in 1) times in 3 (which is N minus 1) while zeroing 3: + >>>[<<.>>-]<<< + + + Move line counter from 7 to 8 and 9: + >>>>>>>[>+>+<<-]<<<<<<< + + Add line counter from 9 onto 7 and 8: + >>>>>>>>>[<+<+>>-]<<<<<<<<< + + Now 7 holds line counter and 8 holds 2*line counter + + Subtract 1 from 8 to let it hold 2*line counter minus 1: + >>>>>>>>-<<<<<<<< + + Print 'star' (in 2) times in 8 (which is 2*line counter minus 1) while zeroing 8: + >>>>>>>>[<<<<<<.>>>>>>-]<<<<<<<< + + Print 'minus' (in 1) times in 4 (which is N minus 1) while zeroing 4: + >>>>[<<<.>>>-]<<<< + + + Add 1 to line counter (in 7): + >>>>>>>+<<<<<<< + + Subtract 1 from decreasing N in 10: + >>>>>>>>>>-<<<<<<<<<< + + >>>++++++++++.[-]<<< + + + +Loop on (decreasing) N in 10 +>>>>>>>>>>]<<<<<<<<<< + +Move N from 0 to 3 and 4: +[>>>+>+<<<<-] + +Subtract 1 from 3 and 4 to let them contain N minus 1: +>>>->-<<<< + +Print 'minus' (in 1) times in 3 (which is N minus 1) while zeroing 3: +>>>[<<.>>-]<<< + +Print 'star' (in 2) one time: +>>.<< + +Print 'minus' (in 1) times in 4 (which is N minus 1) while zeroing 4: +>>>>[<<<.>>>-]<<<< + +++++++++++. diff --git a/test.bf b/test.bf index cb6719f..4a1dd26 100644 --- a/test.bf +++ b/test.bf @@ -1 +1,4 @@ ++++++++++[>++++++++++++<-]>----.<+++[>-----<-]>.<++[>+++++++<-]>.+.<++++++++++. +[-]>[-]< ++++++++++++>+++++++ +<#[->[->+>+<<]>>[-<<+>>]<<<#] -- cgit v1.2.3-70-g09d2