Winning Student Solutions for PS7
Grand prize – 13 rules
; Vahan and Edik
; Number of rules: 13
; Check the first symbol
0 < 0 * halt-reject
0 * * * 1
; Move to the right edge
1 _ _ l s1
1 * * r 1
; Subtract right by 1
s1 0 1 l s1
s1 1 0 l move
; Move from right to left
move 0 0 l move
move 1 1 l move
move < < l s2
; Substract left by 1
s2 0 1 l s2
s2 1 0 r 1
s2 _ 1 * halt-accept
; Everything else = reject
* * 0 * halt-reject
Runner-up – 14 rules
;Dymonte, Ryan, and Jason
;14 rules used
;Checks for no left number
init < 0 * halt-reject
init * * * state0
;moves to lsb of right num
state0 _ _ l subr
state0 * * r state0
;does the sub on rhs... rejects if anything other than 1 or 0 is seen
subr 0 1 l subr
subr 1 0 l seekl
subr * 0 * halt-reject
;moves to lsb of lhs
seekl * * l seekl
seekl < < l subl
seekl _ 0 * halt-reject
;does the sub on lhs... accepts on a space.. rejects on anything else
subl 0 1 l subl
subl 1 0 r state0
subl _ 1 * halt-accept
subl * 0 * halt-reject
Runner-up – 14 rules
;Eugene and Daniel, 14 rules
0 < 0 * halt ;check if string starts w/ '<' -> reject
0 * * r goright ;else start
;go right until first blank(end of string)
goright * * r goright
goright _ _ l subright
;subtract 1 from rightmost bit string
subright * 0 * halt ;nothing left to subtract from right bit string -> rej
subright 0 1 l subright
subright 1 0 l goleft
subleft _ 1 * halt ;normal completion, no errors and no more to sub from left bit string -> acc
subleft 0 1 l subleft
subleft 1 0 r goright
subleft < 0 * halt ;too many '<' -> reject
;go left until first '<' (from the right)
goleft * * l goleft
goleft < < l subleft
goleft _ 0 * halt ; no '<' -> reject
Phillip Rogaway’s homepage