Created
October 25, 2016 16:55
-
-
Save krlohnes/f1fd3c8378737ecff53ef51cfd949676 to your computer and use it in GitHub Desktop.
BubbleSort in brainfuck
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BF BubbleSort v0_0 | |
=========================constraints============================= | |
|arrays of nonzero numbers (could easily fix this by initially | | |
|incrementing everything, then decrementing at end, but wont) | | |
|five cells at end three containing size less 1 | | |
|seven cells workspace at beginning | | |
================================================================= | |
+>>>>>>>workspace | |
++++>+++>++>+>+++++>>>++++>++++>+++ create array | |
<< | |
[ | |
[ first loop | |
<<<[<]>>second index | |
[-<<<<<<+>+>>>>>]<<<<<[->>>>>+<<<<<]>>>> second index to 4 | |
[-<<<<+>+>>>]<<<[->>>+<<<]<< first index to 5 | |
[->-[>]<<] | |
<[>>[-]>>>>>[>]>>[>]<-<<<<<[<]] decrement no swap counter | |
<[->>>>>>>[-<+>]>[-<+>]<<[->>+<<]<<<<<<+>>>[-]>>] swap | |
>>first index | |
copy first to last plus 2 | |
[-<+<+>>]<[->+<]<[[>]>[>]>+<<[<]<-]>>[-] | |
shift all | |
>[[<+>-]>] | |
copy moved first to last | |
>[<<+>>-] | |
>- decrement comparison counter | |
] | |
<<<<[<]> | |
copy first to last plus 2 | |
[-<+<+>>]<[->+<]<[[>]>[>]>+<<[<]<-]>>[-] | |
shift all | |
>[[<+>-]>] | |
copy moved first to last | |
>[<<+>>-] | |
>>>[[-]<[-<+<+>>>+<]<<[->>+<<]]> | |
] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment