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

(lean and mean)

Date:06/29/07
Author:Aki Rossi
URL:n/a
Comments:4
Info:http://www.muppetlabs.com/~breadbox/bf/
Score: (2.67 in 48 votes)
################################################
#                                              #
# 99 bottles of beer in 976 bytes of Brainfuck #
# Composed by Aki Rossi                        #
# aki dot rossi at iki dot fi                  #
#                                              #
################################################

#
# Set beer counter to 99
#
>>>>>>>>>
>++++++++++[-<++++++++++>]<-
<<<<<<<<<

#
# Create output registers
#
++++++++++[->++++>++++>++++>++++<<<<]	add 0x28 to all from (1) to (4)
++++++++[->>>++++++++>++++++++<<<<]	add 0x40 to all from (3) and (4)
++++[->>>>++++<<<<]			add 0x10 to (4)
++++++++++				set (0) to LF
>--------				set (1) to SP
>++++					set (2) to comma

>>>>>>>			go to beer counter (9)
[
	# Verse init
	<<<<
	+++	state 1 in (5)
	>+	state 2 in (6)
	>++	state 3 in (7)
	<<	go to (5)
	[
		#####################
		# N bottles of beer #
		#####################
		>>>>		go to (9)
		[
			# Print the number in (9)
			# (conversion routine uncommented to save space)
			[->+>+<<]>>[-<<+>>]<[>++++++++++[->>+>+<<<]
			<[>>>[-<<<-[>]>>>>[<[>]>[---------->>]<++++
			++[-<++++++++>]<<[<->[->-<]]>->>>[>]+[<]<<[
			->>>[>]<+[<]<<]<>>]<<]<+>>[->+<<+>]>[-<+>]<
			<<<<]>>[-<<+>>]<<]>[-]>>>>>>[>]<[.[-]<]
			<<<<<<
			# and remain in (10) which is empty
		]>+<<	inc (11) and go to (9)
		[>]>>	if (9) empty go to (11) else (12)
		[
			<<<<<<<		go to (3)
			++++++.+.	no
			-------		reset (3)
			>>>>>>>		go to (11)
			>>		go to (12)
		]
		<[-]<[-]<		empty (11) and go to (9)
		<<<<<<<<.	SP
		>>------.	b
		+++++++++++++.	o
		>----..		tt
		<---.		l
		-------.	e
		>>>>>>->>>+<<<	dec (9) inc (11)
		[>]>>
		[	now in (12)
			<<<<<<<<	go to (4)
			-.+		s
			>>>>>>>		go to (11)
		]
		>-<<<+<<<<<
		<<<.		SP
		>>>-----.	o
		<+.		f
		<<.		SP
		>>----.		b
		+++..		ee
		>+++.		r
		<+++>++++++	reset registers

		>>		go to (6)

		###############
		# on the wall #
		###############
		[
			<<<<<.		SP
			>>+++++++.-.	on
			<<.		SP
			>>>----.	t
			<------.---.	he
			<<.		SP
			>>>+++.		w
			<----.		a
			+++++++++++..	ll
			---->+>>	reset and go to (6)
			-		dec (6)
		]

		#
		# comma LF
		#
		<<<<.
		<<.
		
		####################################
		# take one down and pass it around #
		####################################
		>>>>>>>		go to (7)
		-		dec (7)
		[>]>>		if not blank then skip loop
		[
			-		dec (9)
			<<<<<		go to (4)
			----.		t
			<-------.	a
			>---------.	k
			<++++.		e
			<<.		SP
			>>>++++.-.<.	one
			<<.		SP
			>>-.>+.		do
			++++++++.	w
			---------.	n
			<<<.		SP
			>>---.>.<+++.	and
			<<.		SP
			>>>++.<---.	pa
			>+++..		ss
			<<<.		SP
			>>++++++++.>+.	it
			<<<.		SP
			>>--------.	a
			>--.---.	ro
			++++++.		u
			-------.	n
			<+++.		d
			++++>++++++++++	reset registers
			<<.		comma
			<<.		LF
			>>-----------	set (2) to excl mark
			>>>>+		inc (6)
			>>>>		go to (10)
		]
		<<<
		<<		go to (5)
		-		dec (5)
	]
	>>+		inc (7)
	<<<<<<<.	LF
	>>+++++++++++	reset comma
	>>>>>>>		go to beer counter (9)
]

Download Source | Write Comment

Alternative Versions

VersionAuthorDateCommentsRate
bottle shapedMichal Wojciech Tarnowski11/13/100
Exact and complete lyricsRaphaŽl Bois03/07/084
original versionAndrew Paczkowski05/30/0529
slightly improved versionMark Hurd07/01/051

Comments

>>  SirBe said on 08/03/07 15:20:58

SirBe Brainfuck is so sexy.

>>  medard said on 08/08/07 23:48:46

medard great!!:D i can't find any compiler :(

>>  Ian Osgood said on 12/02/07 21:09:21

Ian Osgood Try my interpreter at the link. To make it finish more quickly, replace the second line

>++++++++++[-<++++++++++>]<-

with something smaller, like

+++

>>  Ukuk said on 07/13/09 19:13:43

Ukuk Try +++++[>+++++<-]>[-<++++>]<- instead, to get 99, it is 1 char shorter (:

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: