Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reference implementation fails "Hello World!" #6

Open
rdebath opened this issue Sep 17, 2018 · 0 comments
Open

Reference implementation fails "Hello World!" #6

rdebath opened this issue Sep 17, 2018 · 0 comments

Comments

@rdebath
Copy link

rdebath commented Sep 17, 2018

This translation from BF should print "Hello World!"

pf*gasp*b*gasp*tbl*gasp**pomf*bpf*gasp*bpfpfpfb*gasp*pfpfpfpfpfpfpfpfpfpfpfb*pomf**gasp*b*pomf*bl*gasp*t*pomf*bbl*pomf**pomf*pfpfpfpfpfpfpfpfpfpft*pomf*bbbbbbblblblbl!ttpfpfpf!tbl!!pfpfpf!tbl!bbb!tt!pfpfpf!blblblblblbl!bbl!ttpf!t!

This implmentation does print "Hello World!" as does Lunar Fire

#!/usr/bin/ruby

h = {
    'b' => 'p+=1;',
    't' => 'p-=1;',
    'pf' => 'm[p]+=1;',
    'bl' => 'm[p]-=1;',
    '!' => 'putc m[p];',
    '?' => 'm[p]=STDIN.getbyte if !STDIN.eof;',
    '*gasp*' => '(',
    '*pomf*' => ')while((m[p]&=255)!=0);'
}

r = Regexp.union(Regexp.union(h.keys.sort{|a,b|b.length<=>a.length}),/./);
eval 'm=Hash.new(p=0);'+ARGF.read.gsub(/[\n\t ]+/," ").gsub(r,h);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant