Author: Sean Colombo Date: 10/9/04 Apparently my second BF program is a contest! Yay! This program will reverse a string of arbitrary length that will already exist on the tape The string will be preceeded by a zero; can contain any values from 1 to 255 inclusive and is terminated by 0s Eventually this program will have to be optimized to be best (lowest) for the following criteria of: (Code Length) * (Instructions Executed) * (Cells Used) = Score Where "Code Length" is the number of bytes in the source And "Instructions Executed" is the number of instructions executed during the run on the test file (which will be around 1024 bytes in length) And "Cells Used" is the number of spots that the pointer goes to so to speak (see site for better description) Competition described here: http://info1(dot)info(dot)tampere(dot)fi/~lhetuhe/bfcc/comp1(dot)html You'll need to replace (dot) with an actual dot: I can't do that here becuase dots are valid BF code and wouldn't be read as comment START CODE // Shift the whole string to the right one character >[>]<[[>+<-]<] // While the middle has not been reached (checks if the two 0s are adjacent) >>[ // Swap first character with the 0 before it [<+>-] // Swap the last character with the 0 after it >[>]<[[>+<-]<[<]]> ] // Shift everything to the right of the center (including the center if odd length) to the right one cell >[>]<[[>+<-]<] // While the string is not sorted (while the number before the first of the three zeros is not a 0) <<[ // Move the number from the left of the first 0 to the middle 0 spot >>[>]+[<]<-[>>[>]<+[<]<-] // If there is a non 0 to the right of the third 0 >>[>]>[ // Move the number from the right of the last 0 to the middle 0 spot <<[<]+[>]>-[<<[<]>+[>]>-] ] // Bring the cursor back to the spot before the first 0 (if done: bring to location 1) <<[<<]< ] // If there is only one 0 to be deleted: shift the whole thing to the right >>[[[>]<[>+<-]<]>] // Shift the whole string to the left two characters >[[<<+>>-]>] // Return pointer to first cell <<<[<] EOF Code hashed to: 504a72636bfbcd49248d52fc6eca6009