Skip to content

Instantly share code, notes, and snippets.

@graingert
Created May 29, 2012 21:32
Show Gist options
  • Select an option

  • Save graingert/2830859 to your computer and use it in GitHub Desktop.

Select an option

Save graingert/2830859 to your computer and use it in GitHub Desktop.
Finding a communications tree 4
doF()
if waitB is 0 and no unlabelled pins
send B to Parent //Tell parent we’re done
else
send F down next unlabelled pin //Move onto the next child pin
label pin Child
waitB++ //Now we have to wait for yet another pin to finish
return
CASE F: //Only accept parenthood if we haven’t already got a parent
if no Parent pin labelled //we should not have child pins either here.
label incoming pin Parent
waitB=0
doF()
else
label incoming pin Unused //We already have a parent GTFO
send X to incoming pin
return
CASE B:
waitB--
doF()
return
CASE X:
label incoming port Unused
waitB--
doF()
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment