This question already has an answer here:
- Build a polyglot for Hello World 8 answers
Often I need a simple Hello World! program to show some basic concepts of a programming language on my travels. As I usually travel only with light luggage I can't to carry a Hello World! program for each language. So a program that generates Hello World! programs in as many languages as possible would be a great help.
Write a program or function that accepts a language as an input and outputs or returns the source code for program or function that accepts no input and outputs (not returns) Hello World!.
The input defines in which language the Hello World! program should be generated. The input can be a number, a string, or whatever is the easiest for you. The input must only be used to select the language. You are not allowed to use the input as part of the output.
Please specify the valid inputs in your answer.
The output can the return value, or be written to a file or STDOUT (or equivalent). It must full program of function in the language defined by the input. The resulting program/function must write Hello World! to STDOUT (or equivalent for the language). The output doesn't need to be exactly "Hello World!". Everything reasonably recognizable as Hello World! is acceptable. Eg. "HeLLo w0rlD1" would be an acceptable output. Also the resulting Hello World! string can be different for different languages. See bonus points section for more details.
The program should work for as many languages as possible, and be as short as possible. Therefore the score is calculated by number of bytes / (number of supported languages - 1). Eg. an answer with 15 bytes and 3 supported languages would have a score of 7.5.
As usual with code-golf challenges lower scores are better.
- You can subtract 10 percent from your score if the resulting Hello World! output for all supported languages is the same.
- You can subtract and additional 10 percent from your score if the output for all supported languages is exactly Hello World!