Tell me more ×
Programming Puzzles & Code Golf Stack Exchange is a question and answer site for programming puzzle enthusiasts and code golfers. It's 100% free, no registration required.

Given a file named hello_world that contains 2-100 bytes of printable ASCII, create a Turing-complete language in which hello_world is a valid program that prints "Hello World!". The output should be two files: a compiler or interpreter, and a text file with the language spec.

Rules

  • Shortest code wins. Length of (any of the) output doesn't matter.
  • The generated compiler/interpreter must tokenize hello_world into at least two tokens, neither of which are ignored, and can't care about the filename.
  • Your program can't use external resources (no cloning its own compiler).
  • The generated code can be in any language, and can compile to any language.
share|improve this question
1  
I doubt if you'll get anything interesting. It's just too hard. Most likely, any solution will just be a way to cheat your rules (e.g. "Compile" the first character to print "Hello, world", the second to a comment delimiter, map all else to BrainF**k). – ugoren Nov 18 '12 at 19:14
That's basically what I'm picturing--although I'd consider treating something as a comment delimiter to be ignoring it. It's still non-trivial because you have to avoid collisions between the arbitrary input file and your BrainF**k syntax. And of course writing the shortest possible program that outputs an interpreter isn't, as far as a I know, a solved problem even without the additional constraints. – histocrat Nov 18 '12 at 19:24
Given that hello_world can be 2 bytes, any solution pretty much has to bake "Hello World!" into the language definition (or be unnecessarily long to choose not to in the greater-than-that case). How about requiring that the input has at least 13 (string length + 1) distinct characters? (I think this is an interesting problem regardless of whether that change is made.) – Kevin Reid Nov 18 '12 at 21:11
Also, this definition encourages the language spec to be written gratuitously tersely. How about allowing the spec to be derived from a separate template file whose length is not counted? To avoid gimmicks, the requirement would be that no information in the template file is used in the generation of the interpreter/compiler. – Kevin Reid Nov 18 '12 at 21:13
I'm not saying the challenge is trivial. I'm saying it's too hard. You'll get an answer only IF someone finds a trick, that follows your rules to the letter, but makes it uninteresting. – ugoren Nov 19 '12 at 5:43

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.