quadratic time 1. Run it through every compiler/interpreter 2. Choose the one generating the minimum amount of errors
linear time 1. Collect all tokens--words and symbols. 2. For a list of each language's tokens, find the set intersection with those found in (1). 3. Return the language corresponding to the largest result in (2).
>>7 quadratic time solution is the correct one, with a slight modification: output each language wich compiles with no errors. this will detect polyglot programs and intentionally obfuscated (or VALID PERL) code that doesn't look like the language it's written in. it will also not be fooled by nonsense which uses tokens from a language but isn't valid code.
ⅰ Determines the programming language of an input code β (previous exercise). ⅱ After determining the programming language, α must translate itself to the programming language in which β is written.
⑶ (★★★★★ exercise) Only APL allowed for writing program α in the previous exercise.
Name:
Anonymous2016-09-05 12:52
[writing this post has been left as an exercise to the reader]