Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Brainfuck
View unanswered posts
View posts from last 24 hours

Goto page 1, 2, 3  Next  
Reply to topic    Gentoo Forums Forum Index Off the Wall
View previous topic :: View next topic  
Author Message
pYrania
Retired Dev
Retired Dev


Joined: 27 Oct 2002
Posts: 650
Location: Cologne - Germany

PostPosted: Fri Dec 13, 2002 1:19 pm    Post subject: Brainfuck Reply with quote

I hope some of you have some basic bf knowledge.
How about a little Brainfuck Coding Contest ?
might be fun 8)

for all those, who never heard about it:

Quote:
A Brainfuck program has an implicit byte pointer, called "the pointer", which is free to move around within an array of 30000 bytes, initially all set to zero. The pointer itself is initialized to point to the beginning of this array.

The Brainfuck programming language consists of eight commands, each of which is represented as a single character.

> Increment the pointer.
< Decrement the pointer.
+ Increment the byte at the pointer.
- Decrement the byte at the pointer.
. Output the byte at the pointer.
, Input a byte and store it in the byte at the pointer.
[ Jump past the matching ] if the byte at the pointer is zero.
] Jump to the matching [.
Back to top
View user's profile Send private message
masseya
Bodhisattva
Bodhisattva


Joined: 17 Apr 2002
Posts: 2602
Location: Baltimore, MD

PostPosted: Fri Dec 13, 2002 2:08 pm    Post subject: Reply with quote

Moving to (Way) Off the Wall. :)
_________________
if i never try anything, i never learn anything..
if i never take a risk, i stay where i am..
Back to top
View user's profile Send private message
uncle_meat
Tux's lil' helper
Tux's lil' helper


Joined: 25 Nov 2002
Posts: 93

PostPosted: Fri Dec 13, 2002 2:16 pm    Post subject: Re: Brainfuck Reply with quote

Quote:
How about a little Brainfuck Coding Contest?


++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++
++++++++++++++.+.>+++++++++++++++
+++++++++++++++++.<+++++.------------.-
------.+++++++++++++.---.++++++++.
Back to top
View user's profile Send private message
BigRedDot
n00b
n00b


Joined: 29 Oct 2002
Posts: 67
Location: Austin

PostPosted: Fri Dec 13, 2002 3:14 pm    Post subject: Reply with quote

The creator of Brainfuck really should be commened for providing the best "do-it-yourself" turing complete language kit ever. By far, the funniest translation I have seen is Ook! although this thread at Ars Technica is pretty amusing, too.
_________________
Even if you are one-in-a-million, there are still 6000 people just like you.
Back to top
View user's profile Send private message
pYrania
Retired Dev
Retired Dev


Joined: 27 Oct 2002
Posts: 650
Location: Cologne - Germany

PostPosted: Fri Dec 13, 2002 4:27 pm    Post subject: Reply with quote

>>++[<+++++>-]<[>+++<-]>[<<+>>-]<<
>>++[<+++++>-]<[>+++<-]>[<<+>>-]<<
>>++[<+++++>-]<[>+++<-]>[<<+>>-]<<
>>++[<+++++>-]<[<+>-]<
>>++[<+++++>-]<[<+>-]<
+++++++++.
>+++[>++++<-]>[<<->>-]<<
---.>>++[<+++++>-]<[<+>-]<+++++++.
>+++[>+++<-]>[<+++>-]<[<->-]<
>+++[>+++<-]>[<+++>-]<[<->-]<
>+++[>+++<-]>[<+++>-]<[<->-]<
--------.
>>++[<+++++>-]<[>+++<-]>[<<+>>-]<<
>>++[<+++++>-]<[>+++<-]>[<<+>>-]<<
>>++[<+++++>-]<[<+>-]<++++++++.
+.
+++++.>+++[>+++<-]>[<+++>-]<[<->-]<
>+++[>++++<-]>[<<->>-]<<
>+++[>++++<-]>[<<->>-]<<--.
>+++[>+++<-]>[<+++>-]<[<->-]<----.
>>++[<+++++>-]<[<+>-]<
>>++[<+++++>-]<[<+>-]<++++++.
>>++[<+++++>-]<[>+++<-]>[<<+>>-]<<++++..
Back to top
View user's profile Send private message
phong
Bodhisattva
Bodhisattva


Joined: 16 Jul 2002
Posts: 778
Location: Michigan - 15 & Ryan

PostPosted: Fri Dec 13, 2002 8:52 pm    Post subject: Reply with quote

I didn't feel like writing a BF program, so I wrote a BF -> C compiler instead. It accepts a BF program on standard input and writes the C equivalent (according to the language spec) to standard out.

This is the first one I came up with:
Code:
#!/usr/bin/perl
print"#include <stdio.h>\nmain(){char m[30000];char*p=m;";
while(<>){s/[-+<>]/$a=ord $&;$b=$a>59&&15+($a*2&4);chr($a-$b)x2 .(!$b?'*p;':'p;')/ge;
s/\./putchar(*p);/g;s/,/*p=getchar();/g;s/\[/while(*p){/g;s/\]/}/g;print;}print"}\n";

Seeing that there were lots of BF programs out there with comments, I modified it a bit to convert those into C comments (vs. producing invalid code as the above version does).
Code:
#!/usr/bin/perl
print"#include <stdio.h>\nmain(){char m[30000];char*p=m;";while(<>){s{[^-+<>,.[\]\n]+}{/*$&*/}g;
s/[-+<>]/$a=ord $&;$b=$a>59&&15+($a*2&4);chr($a-$b)x2 .(!$b?'*p;':'p;')/ge;
s/\./putchar(*p);/g;s/,/*p=getchar();/g;s/\[/while(*p){/g;s/\]/}/g;print;}print"}\n";

This one produces smaller, faster C code:
Code:
#!/usr/bin/perl
print"#include <stdio.h>\nmain(){char m[30000];char*p=m;";while(<>){s{[^-+<>,.[\]\n]+}{/*$&*/}g;
s/(-|\+|<|>)\1*/$a=ord $&;$b=$a>59&&15+($a*2&4);(!$b?'*p':'p').chr($a-$b).'='.length($&).';'/ge;
s/\./putchar(*p);/g;s/,/*p=getchar();/g;s/\[/while(*p){/g;s/\]/}/g;print;}print"}\n";

I haven't spent as much time on the second to, so forgive me if they aren't as good.
_________________
"An empty head is not really empty; it is stuffed with rubbish. Hence the difficulty of forcing anything into an empty head."
-- Eric Hoffer
Back to top
View user's profile Send private message
pYrania
Retired Dev
Retired Dev


Joined: 27 Oct 2002
Posts: 650
Location: Cologne - Germany

PostPosted: Sat Dec 14, 2002 4:07 am    Post subject: Reply with quote

yeah nice one :)

i wrote a brainfuck interpreter in brainfuck a while ago

i may give it a try again, after some hours of sleep..
(just came home from 7 hours techno clubbing :? )
Back to top
View user's profile Send private message
pilla
Administrator
Administrator


Joined: 07 Aug 2002
Posts: 7584
Location: Pelotas, BR

PostPosted: Sat Dec 14, 2002 4:16 am    Post subject: Reply with quote

That' s something interesting to use in CS classes :twisted:
Back to top
View user's profile Send private message
uncle_meat
Tux's lil' helper
Tux's lil' helper


Joined: 25 Nov 2002
Posts: 93

PostPosted: Sat Dec 14, 2002 4:49 am    Post subject: Reply with quote

Just think, someone could add BrainFuck byte code generation to gcc. Then you could compile C programs to BrainFuck and back to C again. Job security!
Back to top
View user's profile Send private message
pYrania
Retired Dev
Retired Dev


Joined: 27 Oct 2002
Posts: 650
Location: Cologne - Germany

PostPosted: Sat Dec 14, 2002 1:15 pm    Post subject: Reply with quote

There is a great Apache modul for creating webpages with brainfuck ;)
mod_bf

Quote:
mod_bf is a brainfuck module for the Apache webserver, providing several handlers for brainfuck code. You can easily create your dynamic webpages with brainfuck now. Besides that, mod_bf also (sort of) aims to be simple example of various uses of the Apache API, much simpler than the mod_example included with the apache distribution. Please see the information in the mod_bf distribution for more information.
Back to top
View user's profile Send private message
DMK
n00b
n00b


Joined: 17 Sep 2002
Posts: 34
Location: Germany BW

PostPosted: Sat Dec 14, 2002 4:53 pm    Post subject: brainfuck coding question Reply with quote

what is the syntax for the , operator?

,dec?
,+++++++++++++++++++++++++?

is there the possibility to insert another byte from the array?
(like ,>>>>? where does it end?)

is there a tutorial?

greets,
dmk

p.s.:
no thanks
why not? ://
(or am i mistaken?)
_________________
Kurzum, das interaktive Medium ist weder Fluch noch Segen; es bildet schlicht und einfach die Geistesverfassung seiner Teilnehmer ab. (H.M.Enzensberger ueber das Internet
Back to top
View user's profile Send private message
DMK
n00b
n00b


Joined: 17 Sep 2002
Posts: 34
Location: Germany BW

PostPosted: Sat Dec 14, 2002 5:50 pm    Post subject: Reply with quote

++++++++[->++++++++<]>+++++++++.<++++++[->------<]>-----.<++++++ ++[->++++++++<]>++++++++.-------.<++++[->++++<]>+++++.<++++[->-- --<]>-.<++++++++[->--------<]>-----.<++++++++[->++++++++<]>+++++ +++++.<+++[->+++<]>++.--.+.<+++++++++[->---------<]>---.<+++++++ ++[->+++++++++<]>++.<+++[->---<]>-----.----.<++++[->++++<]>+.<++ +[->---<]>------.+++++.---.-.<++++++++[->--------<]>----.<++++++ ++[->++++++++<]>+++++++.++++++++..--------.+++++.-------.<++++++ ++[->--------<]>-----.<++++++++[->++++++++<]>+.<++++++++[->----- ---<]>-.<++++++++[->++++++++<]>++.+++++++.<+++[->+++<]>++.<+++++ ++++[->---------<]>---.<++++++++[->++++++++<]>+.+.<+++[->+++<]>+ +++.++++++.-.<+++++++++[->---------<]>---.<++++++++[->++++++++<] >++.<++++[->++++<]>.<++++[->----<]>-.++++++++.+++++.--------.<++ +[->+++<]>++++++.<++++[->----<]>--.++++++++.<++++++++[->-------- <]>-----------.<++++++++[->++++++++<]>+.<+++[->+++<]>++++.<+++[- >---<]>-.<++++++++[->--------<]>----.<++++++++[->++++++++<]>++++ +++.++++++++.+++++.<+++++++++[->---------<]>---.<++++++++[->++++ ++++<]>+.<++++++++[->--------<]>-.<++++++++[->++++++++<]>+++.<++ +[->+++<]>+++..---.<++++++++[->--------<]>------------.<++++++++ [->++++++++<]>++++++++++++.---.+++++.---.<++++++++[->--------<]> -----------.<++++++++[->++++++++<]>++++++.+++++++++.+++.<+++++++ ++[->---------<]>-.<++++++++[->++++++++<]>+.<++++++++[->-------- <]>-.<++++++++[->++++++++<]>++++++++++++++++.--------.++++++++.< ++++++++[->--------<]>---.<+++++++[->+++++++<]>++++.++++.<++++++ +[->-------<]>--------.<+++++++[->+++++++<]>+++++.<+++[->+++<]>+ ++.--.+++.-------.+++.-------.<+++[->+++<]>++++.<+++++++++[->--- ------<]>-.<+++++++++[->+++++++++<]>++++++.<+++[->---<]>-----.<+ ++[->+++<]>++.<+++[->---<]>---.<++++++++[->--------<]>--------.< ++++++++[->++++++++<]>++++++++.+++++++.++++++++.---.-----.<+++++ +++[->--------<]>-....<+++[->---<]>-----.<+++++[->+++++<]>+.<+++ +[->----<]>-.<
_________________
Kurzum, das interaktive Medium ist weder Fluch noch Segen; es bildet schlicht und einfach die Geistesverfassung seiner Teilnehmer ab. (H.M.Enzensberger ueber das Internet
Back to top
View user's profile Send private message
pYrania
Retired Dev
Retired Dev


Joined: 27 Oct 2002
Posts: 650
Location: Cologne - Germany

PostPosted: Sat Dec 14, 2002 9:19 pm    Post subject: Reply with quote

>++++++++++[<++++++++++>-]<+++++.---.>++++++++[<-------->-]<------.>+++++++++[<+++++++++>-]<++++++++.>+++[<--->-]<-.>++[<+++>-]<.>+++++++++[<--------->-]<----.>++++++++[<+++++++++>-]<++++++.>+++[<--->-]
<..-.>++++++++[<-------->-]<----.>++++++++[<++++++++>-]<+.>++++++++[<-------->-]<-.>++++++++[<++++++++>-]<++.>++++[<++++>-]<.>++++[<---->-]<-.>++[<++++>-]<.>++[<++>-]<+.>++[<---->-]<.>+++[<+++++>-]<.>++
++[<---->-]<--.>++[<++++>-]<.>++++++++[<--------->-]<---.>++++++++[<+++++++++>-]<+.>++[<++>-]<+.>++[<+++>-]<.>+++[<----->-]<.>+++[<++++>-]<+.--.++.>+++[<---->-]<-.>+++[<+++++>-]<.>+++[<----->-]<.>+++[<+
+++>-]<+.>++++++++[<-------->-]<------.>+++[<---->-]<.>++++++++[<++++++++>-]<++++++.-..>++[<+++>-]<+.>++++++++[<--------->-]<----.>++++++++[<++++++++>-]<++++++.>+++[<++++>-]<.>+++[<---->-]<-..>++++++++[
<-------->-]<-----.>+++++++++[<+++++++++>-]<+++.>++[<-->-]<-.>++++++++[<--------->-]<-------.>+++++++++[<+++++++++>-]<++++.--.>+++[<---->-]<--.>++++++++[<-------->-]<-----.>++++++++[<+++++++++>-]<+++++.
>+++[<++++>-]<.>+++++++++[<--------->-]<--------.>++++++++[<++++++++++>-]<.>++[<---->-]<.>++[<++++>-]<.>++++++++[<---------->-]<.>+++++++++[<+++++++++>-]<+++++.>++++[<---->-]<-.>+++[<++++>-]<+.+.>+++[<-
-->-]<-.>++[<+++>-]<.-.>++++++++[<--------->-]<------.>++++++++[<++++++++>-]<+.>++++[<++++>-]<+++.>+++++++++[<--------->-]<---.>++++++++[<+++++++++>-]<.>+++[<++++>-]<..----.>+++++++[<------->-]<-----.>+
++[<--->-]<--..>++++++++[<+++++++++>-]<...>++++++++[<--------->-]<-.+++.++..++++.>+++[<--->-]<-.>++++[<+++++>-]<+++.>+++++[<++++++>-]<+++.>+++[<++++>-]<++.>+++[<--->-]<-.--.>++[<+++>-]<+.>+++[<++++>-]<.
>++++++++[<--------->-]<----.>+++++++[<+++++++>-]<+++++.+.>+++++++[<------->-]<-----.>+++++++[<+++++++>-]<++.>++++[<++++>-]<.>++++[<---->-]<-.>++[<++++>-]<.>++[<++>-]<+.>++[<---->-]<.>+++[<+++++>-]<.>++
++[<---->-]<--.>++[<++++>-]<.>+++++++[<-------->-]<-----.>++++++++[<++++++++>-]<++.>++[<---->-]<.>++[<++++>-]<.>++++++++[<-------->-]<--..>+++[<---->-]<--.>++++++++[<++++++++>-]<+++.>++++[<++++>-]<++.--
-..>+++[<---->-]<-.>+++[<+++>-]<.>++[<+++>-]<.>++[<---->-]<.>+++[<++++>-]<+.>+++++++++[<--------->-]<--------.>++++++++[<+++++++++>-]<+.>++++++++[<--------->-]<-.>++++++++[<++++++++>-]<+.>+++[<++++>-]<.
>++++++++[<--------->-]<-----.>++++++++[<+++++++++>-]<+.>++[<++>-]<+.>++[<++>-]<+.+.>++++[<---->-]<---.>+++[<+++>-]<++..---.>++[<++>-]<+.>++[<--->-]<-.>++++++++[<-------->-]<-------.>++++++++[<+++++++++
>-]<+++++.++.>+++[<--->-]<--.>++[<-->-]<-.+++.++++.>++++++++[<-------->-]<------.>+++++++++[<+++++++++>-]<+++.>++[<-->-]<-.>++++++++[<--------->-]<-------.>++++++++[<+++++++++>-]<+++++.>+++[<++++>-]<.>+
++++++++[<--------->-]<--------.>+++++++++[<+++++++++>-]<++++++.>++++[<---->-]<--.---.>++++[<++++>-]<+.>+++[<---->-]<--.>+++[<++++>-]<+.++++.>++++[<---->-]<-.>+++[<++++>-]<+.>+++++++++[<--------->-]<-.>
+++++++++[<+++++++++>-]<+++.>++[<-->-]<-.>++++++++[<--------->-]<-------.>++++++++[<++++++++>-]<+++.>+++[<+++++>-]<.>+++[<---->-]<-.----.>++++[<++++>-]<+++.>+++[<----->-]<.>++++++++[<-------->-]<-----.>
++++++++[<++++++++>-]<+.>++++++++[<-------->-]<-.>+++++++++[<+++++++++>-]<++.>+++[<--->-]<-.>+++[<+++>-]<++.>+++[<----->-]<.>++++++++[<-------->-]<-----.>++++++++[<++++++++>-]<+.+.>+++[<++++>-]<+.>++[<+
++>-]<.-.>+++++++++[<--------->-]<---.>++++++++[<++++++++>-]<++.>++++[<++++>-]<.>++++[<---->-]<-.>++[<++++>-]<.>++[<++>-]<+.>++[<---->-]<.>+++[<+++++>-]<.>++++[<---->-]<--.>++[<++++>-]<.>+++++++[<------
--->-]<.>+++[<---->-]<.>+++++++++[<+++++++++>-]<++++++.>++[<-->-]<-.>+++[<--->-]<.>+++[<+++>-]<++..>+++[<----->-]<.>+++[<+++>-]<.>++++++++[<--------->-]<------.>++++++++[<+++++++++>-]<+.>++[<++>-]<+.>++
++++++[<--------->-]<------.>++++++++[<++++++++>-]<++.>++++[<++++>-]<.>++++[<---->-]<-.>++[<++++>-]<.>++[<++>-]<+.>++[<---->-]<.>+++[<+++++>-]<.>++++[<---->-]<--.>++[<++++>-]<.>+++++++[<-------->-]<----
-.>+++[<---->-]<--.>+++++++++[<+++++++++>-]<+++.>+++[<---->-]<.+.>+++[<+++>-]<+.>+++++++++[<--------->-]<--.>++++++++[<++++++++++>-]<.++.---.>++[<-->-]<-.>++[<-->-]<-.--.>++++[<++++>-]<+.>+++++++++[<---
------>-]<---.>++++++++[<+++++++++>-]<+++++++.>++[<+++>-]<.>+++[<---->-]<--.+.>+++[<++++>-]<.>+++++++++[<--------->-]<---.>+++++++++[<+++++++++>-]<+++.>++[<-->-]<-.>++++++++[<--------->-]<-------.>+++++
+++[<++++++++>-]<++.+++.>++++++++[<-------->-]<-----.>++++++++[<++++++++>-]<+++.>+++[<++++>-]<..---.>++++++++[<--------->-]<----.>+++++[<+++++>-]<+.>+++++++[<+++++++>-]<+++++.>++++++++++[<---------->-]<
--.
_________________
Markus Nigbur


Last edited by pYrania on Sat Dec 14, 2002 9:41 pm; edited 1 time in total
Back to top
View user's profile Send private message
jonemi
Tux's lil' helper
Tux's lil' helper


Joined: 16 Apr 2002
Posts: 78
Location: Utah, USA

PostPosted: Sat Dec 14, 2002 9:38 pm    Post subject: Reply with quote

Do we have a little too much time on our hands? :-P
Back to top
View user's profile Send private message
pYrania
Retired Dev
Retired Dev


Joined: 27 Oct 2002
Posts: 650
Location: Cologne - Germany

PostPosted: Sat Dec 14, 2002 9:43 pm    Post subject: Reply with quote

yeah, got plenty of it :D

emerge -u xfree || emerge openoffice
there you get your personal spare time :)
_________________
Markus Nigbur
Back to top
View user's profile Send private message
pYrania
Retired Dev
Retired Dev


Joined: 27 Oct 2002
Posts: 650
Location: Cologne - Germany

PostPosted: Sat Dec 14, 2002 9:54 pm    Post subject: Re: brainfuck coding question Reply with quote

DMK wrote:
what is the syntax for the , operator?

,dec?
,+++++++++++++++++++++++++?


, - fills the memory cell under the memory pointer with the ASCII value of next character from the input

DMK wrote:
is there a tutorial?


There are several good tutorials out there.
one of them


DMK wrote:
p.s.:
no thanks
why not? ://
(or am i mistaken?)


that's right :)
_________________
Markus Nigbur
Back to top
View user's profile Send private message
pilla
Administrator
Administrator


Joined: 07 Aug 2002
Posts: 7584
Location: Pelotas, BR

PostPosted: Sun Dec 15, 2002 3:42 am    Post subject: Reply with quote

Well, that's a hard-to-moderate thread. I'll trust you're keeping it in the topic :wink:
Back to top
View user's profile Send private message
phong
Bodhisattva
Bodhisattva


Joined: 16 Jul 2002
Posts: 778
Location: Michigan - 15 & Ryan

PostPosted: Sun Dec 15, 2002 4:56 am    Post subject: Reply with quote

Alright, time to kick this one up a notch. I decided to solve a classic Computer Science problem. I haven't put too much effort into making it particularly small or elegant (it's more than 5k of BF source).

My entry

It will accept numbers up to 255, but the output is on the order of 2^n, so try some more reasonable numbers first, like 4. :)
_________________
"An empty head is not really empty; it is stuffed with rubbish. Hence the difficulty of forcing anything into an empty head."
-- Eric Hoffer
Back to top
View user's profile Send private message
carambola5
Apprentice
Apprentice


Joined: 10 Jul 2002
Posts: 214
Location: Madtown, WI

PostPosted: Sun Dec 15, 2002 7:33 pm    Post subject: Reply with quote

phong wrote:
Alright, time to kick this one up a notch. I decided to solve a classic Computer Science problem. I haven't put too much effort into making it particularly small or elegant (it's more than 5k of BF source).

My entry

It will accept numbers up to 255, but the output is on the order of 2^n, so try some more reasonable numbers first, like 4. :)


Doing my part.... I'm currently timing my machine's execution of phong's entry with an input of 255.

Off to lunch! And probably dinner!
_________________
Get Firefox!

Proper Web Development

I'm done at 999.
Back to top
View user's profile Send private message
phong
Bodhisattva
Bodhisattva


Joined: 16 Jul 2002
Posts: 778
Location: Michigan - 15 & Ryan

PostPosted: Sun Dec 15, 2002 8:37 pm    Post subject: Reply with quote

I just tried it on a pentium4 2.53Ghz, compiled with the C converter above (the third one) and 24 levels took about 42 seconds (which isn't bad considering it involves more than 4 million moves (Edit: correction, 16 million moves)). It uses an iterative solution (of my own design) with a stack (which is basically what the BF memory structure is). An optimized C version using the trivial (and fast) recursive solution takes about 10.3 seconds on the same number of levls.

With my BF version, 33 or 34 levels would take roughly a year. By my calculation, 255 levels would require 4592766030452310680664241675787053974366659328199169697898858237 (4.95*10^63) years (yes, that's the actual calculation, rounded to the nearest year). That's roughly 255153668358461704481346759765947443020369962677731650 (2.55*10^53) times longer than the current high estimates for the age of the universe.

It'll be a bit longer than dinner, in other words.
_________________
"An empty head is not really empty; it is stuffed with rubbish. Hence the difficulty of forcing anything into an empty head."
-- Eric Hoffer
Back to top
View user's profile Send private message
carambola5
Apprentice
Apprentice


Joined: 10 Jul 2002
Posts: 214
Location: Madtown, WI

PostPosted: Sun Dec 15, 2002 10:58 pm    Post subject: Reply with quote

phong wrote:
I just tried it on a pentium4 2.53Ghz, compiled with the C converter above (the third one) and 24 levels took about 42 seconds (which isn't bad considering it involves more than 4 million moves (Edit: correction, 16 million moves)). It uses an iterative solution (of my own design) with a stack (which is basically what the BF memory structure is). An optimized C version using the trivial (and fast) recursive solution takes about 10.3 seconds on the same number of levls.

With my BF version, 33 or 34 levels would take roughly a year. By my calculation, 255 levels would require 4592766030452310680664241675787053974366659328199169697898858237 (4.95*10^63) years (yes, that's the actual calculation, rounded to the nearest year). That's roughly 255153668358461704481346759765947443020369962677731650 (2.55*10^53) times longer than the current high estimates for the age of the universe.

It'll be a bit longer than dinner, in other words.


I figured it might take a while... also, I removed all the "putchar(*p)" entries so that IO wasn't really an issue. Maybe that isn't the limiting factor? :D
_________________
Get Firefox!

Proper Web Development

I'm done at 999.
Back to top
View user's profile Send private message
phong
Bodhisattva
Bodhisattva


Joined: 16 Jul 2002
Posts: 778
Location: Michigan - 15 & Ryan

PostPosted: Mon Dec 16, 2002 1:49 am    Post subject: Reply with quote

Um, if you're able to calculate one move per CPU cycle on the aforementioned P4, you're still talking about 725144247415405552311415453330334787611593325311616422381930 years of CPU time. I'm guessing each move involves no fewer than 30 (probably more like 100) cycles in the C version, about 4 times that on the BF version. 2^255 is a big fat number. Really big. Really fat.
_________________
"An empty head is not really empty; it is stuffed with rubbish. Hence the difficulty of forcing anything into an empty head."
-- Eric Hoffer
Back to top
View user's profile Send private message
carambola5
Apprentice
Apprentice


Joined: 10 Jul 2002
Posts: 214
Location: Madtown, WI

PostPosted: Wed Dec 18, 2002 9:01 pm    Post subject: Reply with quote

BigRedDot wrote:
The creator of Brainfuck really should be commened for providing the best "do-it-yourself" turing complete language kit ever.


Hmm, turing complete, eh? How about this:

Implement Brainfuck with two instructions. Increment the current command, and execute the command.

Here's an example:
Code:
o is defined as increment the current command ('o' because it's like pushing a button).
x is defined as execute the current command ('x' = execute).

Wraparound at the eighth increment.
Indices are defined as:
Code:

0 = +
1 = -
2 = >
3 = <
4 = .
5 = ,
6 = [
7 = ]

An example of the brainfuck translation of '>++++++++++[<++++++++++>-]' would be:
Code:

ooxooooooxxxxxxxxxxooooooxoooooxoooooxxxxxxxxxxooxoooooooxoooooox

How's that for obfuscated?
_________________
Get Firefox!

Proper Web Development

I'm done at 999.
Back to top
View user's profile Send private message
Yarrick
Bodhisattva
Bodhisattva


Joined: 05 Jun 2002
Posts: 304
Location: Malmö, Sweden

PostPosted: Thu Dec 19, 2002 11:24 am    Post subject: Reply with quote

this guy at my school does code brainfuck. his page:
http://www.df.lth.se/~lft/brainfuck/index.html
Back to top
View user's profile Send private message
BigRedDot
n00b
n00b


Joined: 29 Oct 2002
Posts: 67
Location: Austin

PostPosted: Thu Dec 19, 2002 3:08 pm    Post subject: Reply with quote

Quote:
How's that for obfuscated?


Pretty sweet. But how about this:

Code:

**_  for increment the current command ('_' specifies the next location to scan)

*
*   for execute the current command ('_' specifies the next location to scan)
_


together with your wraparound instruction queue. Then your example would become something like:

Code:

*****
    *
    *************
                *
                *
                *
                *
                *
                *
                *
                *
                *
                *
                *
                *
                *
                *
                *
                *
                *
                *
                *
                *************
                            *
                            ********** ... (more I am too lazy to do)
 


If anyone can get it down to no lexical elements, I will be impressed. :)

If you wanted to make it worse, let the queue auto-increment while parsing and only allow "execute" and "do nothing" so you have to add many "do nothing" commands to wait until the command you really want comes back around.
_________________
Even if you are one-in-a-million, there are still 6000 people just like you.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Off the Wall All times are GMT
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum