Last active
October 29, 2017 23:10
-
-
Save primo-ppcg/fd6c6a8dd7dca95c4df2347276adeee6 to your computer and use it in GitHub Desktop.
brainfuck 99 bottles of beer
This file contains 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
; 99 bottles of beer in 835 instructions | |
; Author: Mike Tryczak (aka primo) | |
; | |
; Complete lyrics version | |
; byte sequence | |
; \n _ _ _ _ d \n comma space d o t l T | |
>++++++++++>> | |
>->+>----->--->---->+>++>++>++ | |
>+[+++++[>++++++++++++++<-]<+] | |
>>>---->>++++>>->++>----[<++<] | |
c = 0 | |
n = 100 | |
N = '100' | |
> | |
while(n) | |
[ | |
<< | |
N = str(int(N) minus 1) | |
; first time \n _ becomes 9 9 | |
++++++[<++++++++>-]<[<[<]>[->]<] | |
+<[>-]>[-<++++++++++<->>>] | |
++++++[<-------->-]<[<[<]>[+>]<] | |
<->>> | |
if(c) | |
[ | |
n = n minus 1 | |
>- | |
if(n) | |
[ | |
'Take one down and' | |
[>]<.<<<<---.>>>-.<<<++++.<.>>.-.<.<.>-.>+.>+++.<-.<<.>---.>.<+++. | |
' pass it around' comma space | |
<.>>++.<---.>>----..<<<.>>>>--.+++<+.<<<.>.>>--.<-.>+++.-<-.+<+++.<<.>.<<<<-< | |
]> | |
else | |
[ | |
N = '9' | |
'Go to the store and' | |
[>]<-------.<<<.<<.>>>.<.<<.>>>.<<++++.---.<.>>>-.+.<.>--.<<.<.>----.>-.<+++. | |
' buy some more' comma space N | |
<.>--.>>+++.++++.<<<.>>>------.<+.--.<+++.<.>>.++.>-.++<<.-<<.>.<<<<-<<<.>>> | |
] | |
<+> | |
] | |
c = c plus 2 | |
<++ | |
while(c) | |
[ | |
>>- | |
if(n minus 1) | |
[ | |
N | |
<<<<[<]>[.>]>> | |
]<< | |
else | |
[-- | |
if(c minus 2) | |
[ | |
'n' | |
>>>>>>>-.+[<]<<< | |
]>>> | |
else | |
[ | |
'N' | |
[>]<------.[<] | |
] | |
'o more' | |
>>>>>.<<.>>--.++.>--.++<<+.-[<] | |
<<++< | |
] | |
>>> | |
' bottle' | |
>>>.>--.>.>..->.<<<+++.<<<< | |
if(n minus 2) 's' | |
-[>>>>>>.[<]]<[>]>++ | |
' of beer' | |
>>>.>>.<+.<.>----.+++..->>-.++ | |
<[<<]<- | |
if(c minus 1) | |
[ | |
' on the wall' | |
>>>>>.>>.-.+<<.>>>.<<++++.---.<.>>>+++.---<<----.+++>>>..[<<] | |
] | |
<<[>]>- | |
if(c minus 2) | |
[ | |
period newline | |
>>>>++.--<.<<<+ | |
if(c minus 1) newline | |
[>>>.<<<<]>[>]<-< | |
]>> | |
else | |
[ | |
comma space | |
>>.>.<<<< | |
] | |
if(not n) c = c minus 2 | |
>[<<++>] | |
c = c minus 1 | |
<[>]<- | |
] | |
c = 1 | |
>+> | |
] |
This file contains 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
; 99 bottles of beer in 744 instructions | |
; Author: Mike Tryczak (aka primo) | |
; | |
; Canonical codegolf version | |
; requires 8 bit wrapping cells | |
>++++++++++>>--->++++>------>-->>++>+>>+>->++[[>+++++++[>++>+>+<<<-]<-]+<+++]>>>>>- | |
->>-->>++>->+++[<]>[-<<+[<->-----]<---[<[<]>[->]<]+<[>-]>[-<++++++++++<->>>]-[<->-- | |
---]<+++[<[<]>[+>]<]<->>>[>[[>]<<<<.<<<<---.>>>-.<<<++++.<.>>>.-.<<.<.>-.>>+.<+++.> | |
-.<<<.>---.>>.<<+++.<.>>>++.<<---.>----..<<.>>>>--.+++<<+.<<.>.>--.>-.<+++.->-.+<<+ | |
++.<<.>.<<<<-<]>[[>]<<<-.<<<.<<<.>>.>. < < <.>>.<++++.---.<.>>-.+.>.<--.<.<.>----.> | |
>-.<<+++.<.>--.>+++.++++.<<.>>------.>+.--.<<+++.<.>>>.++.<-.++<.-<<.>.<<<<-<<<++++ | |
+++++.>>>]<+>]<++[<<[<]>[.>]>>>>>>.>--.>>.<..->>.<<<+++.<<<<-[>>>>>.[<]]<[>]>+>>>.> | |
>>.<<+.<.>----.+++..->-.++[<<]<-[>>>>>.>>>.-.+<<<.>>.<++++.---.<.>>+++.---<----.+++ | |
>>>..[<<]]<<[>]>-[>>>>++.--<.<<<+[>>>.<<<<]>[>]<-<]>>[>>.>.<<<<]>[<<++>]<[>]<-]>+>] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment