Created
November 4, 2013 13:44
-
-
Save jsrn/7302650 to your computer and use it in GitHub Desktop.
Conceal Brainfuck in ASCII artwork
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
#!/usr/bin/env ruby | |
brainfuck = File.open("helloworld.bf", "rb").read | |
ascii_art = File.open("animaniacs.art", "rb").read | |
if brainfuck.length > ascii_art.gsub(" ","").length | |
abort "The supplied brainfuck will not fit inside the ASCII art." | |
end | |
output = "" | |
ascii_art.split("").each do |i| | |
if brainfuck != "" | |
if i != " " and i != "\n" | |
i = brainfuck[0,1] | |
brainfuck = brainfuck[1..-1] | |
end | |
end | |
output << i | |
end | |
File.open( "hidden.bf", "w" ) do |file| | |
file.write( output ) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
By only using the >, +, and - characters. if a program finishes running it doesn't need those values anymore, it doesn't generate syntax errors, and it doesn't go out of bounds left. The only thing that can happen is that it goes out of bounds right. It always halts after running those instructions because it doesn't create a loop, and it doesn't freeze because it's never asking for user input. It also doesn't mess up the output because it never prints anything.