(=================================) (========Edward Martin============) (** This program will count the **) (** Parenthenses in a line and **) (** determine if they are **) (** matching pairs; **) (** input is considered over **) (** when a \n is encountered **) (=================================) jump to cell 1 (where we take out inputs) > set our constants we are looking for (set cell 2 to a '(' ) (set cell 3 to a ')' ) >[-]>[-]+> (zero 2 and 3 and set 3 to 1) ++++++++++[-<+++<+++>>] (set 2 and 3 correctly) <<< back to 1 ,---------- (get the character and subtract 10 for a newline char) [ (==========================================) (===========Check Left=====================) (==========================================) check if 1==2 and store in 5 [->>>>+>+>>+<<<<<<<]>>>>>[-<<<<<+>>>>>]<<<< (copy 1 to 5 and 8) [->>>>+>+>>+<<<<<<<]>>>>>[-<<<<<+>>>>>]<<<<< at 2; (copy 2 to 6 and 9) and 5 and 6; save in 7 >>>[>[->+<]<[-]]>[-]< at 5; >>[[-] zero 7; then subtract from 8 and 9 copy 8 and 9 to 5 and 6; then and 5 and 6 to 7 >->- dec 8 and 9 [->+<<<<<+>>>>]>[-<+>]<< copy 9 to 5 (use 10 for temp) [->>+<<<<+>>]>>[-<<+>>] at 10; copy 8 to 6 (use 10 for temp) and 5 and 6 save in 7 <<<<<[>[->+<]<[-]]>[-]> ] >[-<+>]>[-<<+>>]<< or 8 and 9 to 7 (was 5 and 6 to 7) not 7 into 5 <<+>>[<<->>[-]] at 7; 8 and 9 need to get zeroed >[-]>[-]<< should have the equals in 5 now; everything else zeroed; go back to 1 (do check here on 5) <<[ (this code executes when a '(' was seen on the input [-]<<<<<+>>>>> ]<<<< (====================================================================) ok we have checked if its a '(' and added to the counter as needed we now need to check if its a ')' and subtract from the counter as needed (code here is pretty much a copy/paste of whats above) (==================================) (===========Check Right===========) (==================================) check if 1==3 and store in 5 [->>>>+>+>>+<<<<<<<]>>>>>[-<<<<<+>>>>>]<<< (copy 1 to 5 and 8) [->>>+>+>>+<<<<<<]>>>>[-<<<<+>>>>]<<<<< at 2; (copy 3 to 6 and 9) and 5 and 6; save in 7 >>>[>[->+<]<[-]]>[-]< at 5; >>[[-] zero 7; then subtract from 8 and 9 copy 8 and 9 to 5 and 6; then and 5 and 6 to 7 >->- dec 8 and 9 [->+<<<<<+>>>>]>[-<+>]<< copy 9 to 5 (use 10 for temp) [->>+<<<<+>>]>>[-<<+>>] at 10; copy 8 to 6 (use 10 for temp) and 5 and 6 save in 7 <<<<<[>[->+<]<[-]]>[-]> ] >[-<+>]>[-<<+>>]<< or 8 and 9 to 7 (was 5 and 6 to 7) not 7 into 5 <<+>>[<<->>[-]] at 7; 8 and 9 need to get zeroed >[-]>[-]<< should have the equals in 5 now; everything else zeroed; go back to 1 (do check here on 5) <<[[-] (this code executes when a ')' was seen on the input we should set 1 to zero if 0 is zero copy zero to 5 (we will not this later; 5 should always be zero) <<<<<[->>>>>+>+<<<<<<]>>>>>>[-<<<<<<+>>>>>>]< not 5 to 4 <+>[[-]<->] <<<<<->>>>> ]+ set 5 to 1 subtract 4 from 5 <[[-]>-<]> <<<<[-]>>>> zero 1 [[-] if 5; zero it and input the next char <<<< input the next char ,---------->>>>] <<<< to 1 ] < this is just saying if its valid [[-]>>>>>no! not valid so put 'Not' at 5;6;7 >[-]++++++++++[<+++++++>-]< ++++++++.(N) >++++++++++[<+++>-]< +++.(o) +++++.(t) [-] >+++++[<+++++++++>-]<.(dash) <<<<< ] >>>>> [-] >[-]++++++++[<+++++++++++>-]<--.(V) >++[<+++++>-]<+.(a) >++[<+++++>-]<+.(l) ---.(i) -----.(d)