RE: CTRL+V THREAD
03-12-2016, 09:43 PM
;move to last digit
moveR 0 * r moveR
moveR 1 * r moveR
moveR _ * l check
;check if last digit is even or odd
check 0 _ l check ;if even delete last 0 and try again
check 1 * l check1 ;if odd check if one
check1 _ * * halt ;if one halt
check1 * * r odd1 ;if not one reset pos
odd1 * * r odd
;multiply by three
odd _ 1 l odd
odd * * l oddd
oddd 0 0 r oddd0
oddd 1 1 r oddd1
oddd _ * r moveR_add
oddd0 * * l odd
oddd1 0 1 l odd
oddd1 1 o l odd
moveR_add 0 * r moveR_add
moveR_add 1 * r moveR_add
moveR_add _ * l add
moveR_add o 0 l moveR_addCarry
moveR_addCarry 1 0 l moveR_addCarry
moveR_addCarry 0 1 r moveR_add
moveR_addCarry _ 1 r moveR_add
;add one
add 1 0 l addCarry
add 0 1 r moveR
addCarry 0 1 r moveR
addCarry 1 0 l addCarry
addCarry _ 1 r moveR
moveR 0 * r moveR
moveR 1 * r moveR
moveR _ * l check
;check if last digit is even or odd
check 0 _ l check ;if even delete last 0 and try again
check 1 * l check1 ;if odd check if one
check1 _ * * halt ;if one halt
check1 * * r odd1 ;if not one reset pos
odd1 * * r odd
;multiply by three
odd _ 1 l odd
odd * * l oddd
oddd 0 0 r oddd0
oddd 1 1 r oddd1
oddd _ * r moveR_add
oddd0 * * l odd
oddd1 0 1 l odd
oddd1 1 o l odd
moveR_add 0 * r moveR_add
moveR_add 1 * r moveR_add
moveR_add _ * l add
moveR_add o 0 l moveR_addCarry
moveR_addCarry 1 0 l moveR_addCarry
moveR_addCarry 0 1 r moveR_add
moveR_addCarry _ 1 r moveR_add
;add one
add 1 0 l addCarry
add 0 1 r moveR
addCarry 0 1 r moveR
addCarry 1 0 l addCarry
addCarry _ 1 r moveR