Voting

Category

esoteric language

Bookmarking

Del.icio.us Digg Diigo DZone Earthlink Google Kick.ie
Windows Live LookLater Ma.gnolia Reddit Rojo StumbleUpon Technorati

Language Brainfuck

(slightly improved version)

Date:07/01/05
Author:Mark Hurd
URL:http://www.ozemail.com.au/~markhurd/
Comments:2
Info:n/a
Score: (3.29 in 24 votes)
##########################
###
### Severely updated version!
### (now says "1 bottle" and
### contains no extra "0" verse)
### with further edits to not rely on typeover
###
##########################
### 99 Bottles of Beer ###
### coded in Brainfuck ###
### with explanations  ###
##########################
#
# This Bottles of Beer program
# was written by Andrew Paczkowski
# Coder Alias: thepacz
# three_halves_plus_one@yahoo.com
# Edited by Mark Hurd
# markehurd@gmail.com
#####

>                             0 in the zeroth cell
+++++++>++++++++++[<+++++>-] 57 in the first cell or "9"
+++++++>++++++++++[<+++++>-] 57 in second cell or "9"
++++++++++                   10 in third cell
>+++++++++                    9 in fourth cell

##########################################
### create ASCII chars in higher cells ###
##########################################

>>++++++++[<++++>-]               " "
>++++++++++++++[<+++++++>-]        b
+>+++++++++++[<++++++++++>-]       o
++>+++++++++++++++++++[<++++++>-]  t
++>+++++++++++++++++++[<++++++>-]  t
>++++++++++++[<+++++++++>-]        l
+>++++++++++[<++++++++++>-]        e
+>+++++++++++++++++++[<++++++>-]   s
>++++++++[<++++>-]                " "
+>+++++++++++[<++++++++++>-]       o
++>++++++++++[<++++++++++>-]       f
>++++++++[<++++>-]                " "
>++++++++++++++[<+++++++>-]        b
+>++++++++++[<++++++++++>-]        e
+>++++++++++[<++++++++++>-]        e
>+++++++++++++++++++[<++++++>-]    r
>++++++++[<++++>-]                " "
+>+++++++++++[<++++++++++>-]       o
>+++++++++++[<++++++++++>-]        n
>++++++++[<++++>-]                " "
++>+++++++++++++++++++[<++++++>-]  t
++++>++++++++++[<++++++++++>-]     h
+>++++++++++[<++++++++++>-]        e
>++++++++[<++++>-]                " "
++>+++++++++++++[<+++++++++>-]     w
+>++++++++++++[<++++++++>-]        a
>++++++++++++[<+++++++++>-]        l
>++++++++++++[<+++++++++>-]        l
>+++++[<++>-]                      LF
+++++++++++++>                     CR
++>+++++++++++++++++++[<++++++>-]  t
+>++++++++++++[<++++++++>-]        a
+++>+++++++++++++[<++++++++>-]     k
+>++++++++++[<++++++++++>-]        e
>++++++++[<++++>-]                " "
+>+++++++++++[<++++++++++>-]       o
>+++++++++++[<++++++++++>-]        n
+>++++++++++[<++++++++++>-]        e
>++++++++[<++++>-]                " "
>++++++++++[<++++++++++>-]         d
+>+++++++++++[<++++++++++>-]       o
++>+++++++++++++[<+++++++++>-]     w
>+++++++++++[<++++++++++>-]        n
>++++++++[<++++>-]                " "
+>++++++++++++[<++++++++>-]        a
>+++++++++++[<++++++++++>-]        n
>++++++++++[<++++++++++>-]         d
>++++++++[<++++>-]                " "
++>+++++++++++[<++++++++++>-]      p
+>++++++++++++[<++++++++>-]        a
+>+++++++++++++++++++[<++++++>-]   s
+>+++++++++++++++++++[<++++++>-]   s
>++++++++[<++++>-]                " "
+>+++++++++++++[<++++++++>-]       i
++>+++++++++++++++++++[<++++++>-]  t
>++++++++[<++++>-]                " "
+>++++++++++++[<++++++++>-]        a
>+++++++++++++++++++[<++++++>-]    r
+>+++++++++++[<++++++++++>-]       o
>+++++++++++++[<+++++++++>-]       u
>+++++++++++[<++++++++++>-]        n
>++++++++++[<++++++++++>-]         d
>+++++[<++>-]                      LF
+++++++++++++                      CR

[<]>>>>      go back to fourth cell

#################################
### initiate the display loop ###
#################################

[           loop
 <-          back to cell 3
 [+          loop
  [>]<<       go to last cell and back to LF
  .>.<.>.     output 2 newlines
  [<]>        go to first cell

 ###################################
 #### begin display of characters###
 ###################################
 #
  .>.>>>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>
 #X X     b o t t l e s   o f   b e e r  
  .>.>.>.>.>.>.>.>.>.>.>.>.
 #o n   t h e   w a l l N L
  [<]>    go to first cell
  .>.>>>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>>>>>>>>>>>>>.>.>
 #X X     b o t t l e s   o f   b e e r             N L
  .>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>
 #t a k e   o n e   d o w n   a n d   p a s s   
  .>.>.>.>.>.>.>.>.>.>.
 #i t   a r o u n d N L
 #####

  [<]>>      go to cell 2
  -          subtract 1 from cell 2
  <          go to cell 1

 ########################
 ### display last line ##
 ########################
 #
  .>.>>>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>
 #X X     b o t t l e s   o f   b e e r  
  .>.>.>.>.>.>.>.>.>.>.
 #o n   t h e   w a l l
 #####

  [<]>>>--    go to cell 3/subtract 1
 ]+           end loop when cell 3 is 0

 [>]<<       go to last cell and back to LF
 .>.<.>.     output 2 newlines
 [<]>        go to first cell

 ###################################
 #### begin display of characters###
 ###################################
 #
  .>.>>>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>
 #X X     b o t t l e s   o f   b e e r  
  .>.>.>.>.>.>.>.>.>.>.>.>.
 #o n   t h e   w a l l N L
  [<]>    go to first cell
  .>.>>>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>>>>>>>>>>>>>.>.>
 #X X     b o t t l e s   o f   b e e r             N L
  .>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>
 #t a k e   o n e   d o w n   a n d   p a s s   
  .>.>.>.>.>.>.>.>.>.>.
 #i t   a r o u n d N L
 #####

 [<]>-        cell 1 subtract 1
 >+++++++++   add 9 to cell 2
 >+++++++++   cell 3 add 9
 <<          go to first line

########################
### correct last line ##
########################
#
 .>.>>>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>
#X 9     b o t t l e s   o f   b e e r  
 .>.>.>.>.>.>.>.>.>.>.
#o n   t h e   w a l l
#####

 [<]>>>>-    go to cell 4/subtract 1
]           end loop when cell 4 is 0

##############################################################
### By this point verses 99\10 are displayed but to work   ###
### with the lower numbered verses in a more readable way  ###
### we initiate a new loop for verses 9{CODE} that will not    ###
### use the fourth cell at all                             ###
##############################################################

+           add 1 to cell four (to keep it non\zero)
<---        back to cell 3/subtract 2

[+           loop
 [>]<<       go to last cell and back to LF
 .>.<.>.     output 2 newlines
 [<]>        go to first cell

 ###################################
 #### begin display of characters###
 ###################################
 #
  >.>>>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>
 # X     b o t t l e s   o f   b e e r  
  .>.>.>.>.>.>.>.>.>.>.>.>.
 #o n   t h e   w a l l N L
  [<]>    go to first cell
  >.>>>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>>>>>>>>>>>>>.>.>
 # X     b o t t l e s   o f   b e e r             N L
  .>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>
 #t a k e   o n e   d o w n   a n d   p a s s   
  .>.>.>.>.>.>.>.>.>.>.
 #i t   a r o u n d N L
 #####

 [<]>>       go to cell 2
 -           subtract 1 from cell 2

 ########################
 ### display last line ##
 ########################
 #
  .>>>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>
 #X     b o t t l e s   o f   b e e r  
  .>.>.>.>.>.>.>.>.>.>.
 #o n   t h e   w a l l
 #####

 [<]>>>--    go to cell 3/subtract 1
]+           end loop when cell 3 is 0

 [>]<<       go to last cell and back to LF
 .>.<.>.     output 2 newlines
 [<]>        go to first cell

 ###################################
 #### begin display of characters###
 ###################################
 #
  >.>>>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>
 # 2     b o t t l e s   o f   b e e r  
  .>.>.>.>.>.>.>.>.>.>.>.>.
 #o n   t h e   w a l l N L
  [<]>    go to first cell
  >.>>>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>>>>>>>>>>>>>.>.>
 # 2     b o t t l e s   o f   b e e r             N L
  .>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>
 #t a k e   o n e   d o w n   a n d   p a s s   
  .>.>.>.>.>.>.>.>.>.>.
 #i t   a r o u n d N L
 #####

 [<]>>       go to cell 2
 -           subtract 1 from cell 2

#+            add 1 to cell 3 to keep it non\zero

#[>]<<.>.     go to last line/carriage return
<#[<]>         go to first line

########################
### correct last line ##
########################
#
 >.>>>.>.>.>.>.>.>.>>.>.>.>.>.>.>.>.>.>
# 1     b o t t l e    o f   b e e r  
 .>.>.>.>.>.>.>.>.>.>.<<<<.
#o n   t h e   w a l l
#####

[>]<<       go to last cell and back to LF
.>.<.>.     output 2 newlines
[<]>        go to first line

#########################
### the final verse    ##
#########################
#
 >.>>>.>.>.>.>.>.>.>>.>.>.>.>.>.>.>.>.>
# 1     b o t t l e    o f   b e e r  
 .>.>.>.>.>.>.>.>.>.>.>.>.
#o n   t h e   w a l l N L
 [<]>        go to first cell
 >.>>>.>.>.>.>.>.>.>>.>.>.>.>.>.>.>.>>>>>>>>>>>>>.>.>
# 1     b o t t l e    o f   b e e r             N L
 .>.>.>.>.> > > > > > > > > > > > > > > > > > >
#t a k e   (o n e   d o w n   a n d   p a s s  )
 .>.<<              < < < < < < < < < < < < < <
#i t
 .>.>.>.>.>.>.>.>.>.>.>.>.>.>.>
#  d o w n   a n d   p a s s   
 .>.>.>.>.>.>.>.>.>.>.
#i t   a r o u n d N L
 [>]<       go to last line
 <<<.<<.
#   n  o    
 [<]>>>>     go to fourth cell
 >.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>
#   b o t t l e s   o f   b e e r  
 .>.>.>.>.>.>.>.>.>.>.>.>.
#o n   t h e   w a l l N L
#####fin##

Download Source | Write Comment

Alternative Versions

VersionAuthorDateCommentsRate
original versionAndrew Paczkowski05/30/0524
lean and meanAki Rossi06/29/075
Exact and complete lyricsRaphaël Bois03/07/083

Comments

>>  Gachl said on 03/05/10 11:53:16

Gachl I'd like to file a bug
This version prints out (at the end)

2 bottles of beer on the wall
2 bottles of beer
take one down and pass it around

2 bottle of beer on the wall

2 bottle of beer on the wall
2 bottle of beer
take it down and pass it around
no bottles of beer on the wall

which doesn't seem to be correct.

>>  uggbootscheapuk said on 09/04/10 09:06:46

uggbootscheapuk A brace of blubberyugg boots,UGG Bailey Button Boots withugg classicugg boots saleugg boots ukugg boots cheap,snow cubangzhenugg classic bootsugg classic tall,aberrant covering and braided scaletall ugg bootsuggs bootsugg classic tall greyugg classic short chestnut, it is the activity of Japanese Street.Chooseugg classic short sale,ugg classic short metallic,ugg classic cardy boots grey,a brace of atramentous snowugg classic cardy grey,ugg classic cardy black,boots are absolutely in chargeugg classic cardy boots black,ugg classic cardy tall,ugg classic cardy sale,of a lot of courage,fortunatelyugg bailey button triplet,ugg bailey button bomber,ugg bailey button side bootsugg bailey button uk, with a analogously absorbingugg bailey button bomber boots,ugg bailey button greyugg bailey button sale,ugg bailey boots,atramentous cubangzhen aberrant continued sweater to balanceugg button bootsbailey button uggs,bailey button chestnut ugg boots,.Women's anxiety cool,especially during autumn and winter acclimate does not assure anxietybailey button boots,button ugg boots,ugg boots sundance,ugg bailey button chestnut,not alone accessible to put the bottom freezing,easier affecting women's health, fall/winter division baddest a brace of balmy clothes and Ugg Boots is actual important,a acclaimedugg krinkle,bailey button ugg boots uk,chestnut bailey button ugg boots,women's bailey buttonbailey button krinkle,uggs short sand, is autumn and winter snow boots in against balmy style,the winter a bifold ensures anxiety adequate and warm,UGG boots in autumn 2010 new snow is added than in the accomplished appearance with snow UGG Classic Cardy Boots easier!

Download Source | Write Comment

Add Comment

Please provide a value for the fields Name, Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.

Please don't post large portions of code here! Use the form to submit new examples or updates instead!

Name:

eMail:

URL:

Security Code:
  
Comment: