-6
\$\begingroup\$

Write a series of programs in the same language that print “Hello, world!” using n distinct source characters, where n is in [1..10] inclusive (“distinct” meaning that duplicate characters are ignored from character count). The winner is the solution with the most programs, each with distinct n. I suggest making one solution per language, which is treated like a wiki.

Further rules:

  • Case-sensitive ('H' and 'h' are distinct characters)
  • In case-insensitive languages, all non-string-literal characters are assumed to be uppercase.
  • EDIT: No characters ignored by the compiler (comments)
  • Output must be exactly “Hello, world!” (without quotes) - no variations in punctuation or case, and no newline.
  • “Output” can mean either value of the expression or output to stdout.
  • Esoteric programming languages are very much allowed.
  • EDIT: The language must already exist (as of this question being asked).
  • If anyone gets all of [1..10], they are the accepted winner.

Here's a polyglot example:

'Hello, world'

It scores 11 (and thus is not part of a solution) because it includes distinct characters:

'Helo, wrd!
\$\endgroup\$
  • \$\begingroup\$ "Esoteric programming languages are very much allowed." Yet you have implicitly disallowed brainfuck and the HQ9+ 'family' \$\endgroup\$ – Kendall Frey Mar 8 '14 at 23:06
6
\$\begingroup\$

DC: 2, 3, 4, 5, 6, 7, 8, 9 and 10 distinct characters

Seeing as the value of an expression is accepted as valid, this should qualify for 2 distinct characters (newlines added for legibility):

1111111111111111111111111111111+
1111111111111111111111111111111+
1111111111111111111111111111111+
1111111111111111111111111111111+
1111111111111111111111111111111+
11111111111111111111111111111+1+
11111111111111111111111111111+1+
1111111111111111111111111111+11+
1111111111111111111111111111+11+
11111111111111111111111111+1111+
11111111111111111111111111+1111+
1111111111111111111111111+11111+
11111111111111111111111+1111111+
11111111111111111111111+1111111+
1111111111111111111111+11111111+
1111111111111111111111+11111111+
1111111111111111111111+11111111+
111111111111111111111+111111111+
111111111111111111111+111111111+
111111111111111111111+111111111+
11111111111111111111+1111111111+
11111111111111111111+1111111111+
11111111111111111111+1111111111+
11111111111111111111+1111111111+
11111111111111111111+1111111111+
11111111111111111111+1111111111+
1111111111111111111+11111111111+
1111111111111111111+11111111111+
1111111111111111111+11111111111+
11111111111111111+1111111111111+
11111111111111111+1111111111111+
11111111111111111+1111111111111+
11111111111111111+1111111111111+
11111111111111111+1111111111111+
11111111111111111+1111111111111+
1111111111111111+11111111111111+
1111111111111111+11111111111111+
1111111111111111+11111111111111+
1111111111111111+11111111111111+
1111111111111111+11111111111111+
1111111111111111+1111111111111+
1111111111111111+1111111111111+
111111111111111111+11111111111+
1111111111111111111+1111111111+
1111111111111111111+1111111111+
1111111111111111111+1111111111+
11111111111111111111111+111111+
11111111111111111111111+111111+
11111111111111111111111+111111+
11111111111111111111111+111111+
11111111111111111111111+111111+
1111111111111111111111111+1111+
1111111111111111111111111+1111+
11111111111111111111111111+111+
111111111111111111111111111+11+
111111111111111111111111111+11+
111111111111111111111111111111+
11111111111111111111111111111+
11111111111111111111111111111+
11111111111111111111111111111+
11111111111111111111111111111+
1111111111111111111111111+
1111111111111111111111111+
11111111111111111111111+
1111111111111111111111+
1111111111111111111111+
1111111111111111111111+
111111111111111111111+
111111111111111111111+
111111111111111111111+
111111111111111111111+
111111111111111111+
111111111111111111+
111111111111111111+
1111111111111111+
1111111111111111+
111111111111111+
111111111111111+
111111111111111+
111111111111111+

The above is equal to Hello, world!, which can be seen by printing it with P. Note that it yields an error, as the first plus sign doesn't have two values on the stack to work with, but that doesn't change the value of the expression (as the error doesn't stop the execution). Replace the first plus sign with a space for the solution with 3 distinct characters.

4 distinct characters:

11dd1d+++ddd++dP+1dd+d+++dP1ddd++d+++ddPP111dddP11d+d+P1d+d+d+dd+d+P+PP1dd+++PPdd++ddd++1+PP

The rest:

2i1001000011001010110110001101100011011110010110000100000011101110110111101110010011011000110010000100001P
3i12000022021201222010112112220012020100011020212102102112221212020P
4i1020121112301230123302300200131312331302123012100201P
5i100103122130403124020421012422302411143103141P
6i2324032511514252112222553531220321252053P
7i2106632145606024426126104063251063041P
\$\endgroup\$
4
\$\begingroup\$

Brainfuck, n=2, 3, 4, 5, 6, 7, 8

Case n=2: (new lines added for readability)

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.
+++++++++++++++++++++++++++++.
+++++++..
+++.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++.
+++.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++.

Case n=2 will be our basis.

For case n=3: we add - to the end of the n=2 source.

For case n=4: we add -> to the end of the n=2 source.

For case n=5: we add ->< to the end of the n=2 source.

For case n=6: we add [><] to the beginning of the n=2 source.

For case n=7: we add [><-] to the beginning of the n=2 source.

For case n=8: we add [><,-] to the beginning of the n=2 source.

Note: if you allow comments to be counted, add a anywhere for n=9 and add ab anywhere for n=10.

\$\endgroup\$
4
\$\begingroup\$

Emacs Lisp: One expression that returns "Hello, World!"

Exactly 10 distinct characters: [s, t, r, i, n, g, ), (, *, +]

(string

(*(+(*)(    *))(+(*(
*(+(*)(*    ))(+(*)(
*))))(*(    +(*)(*)(
*)(*))(*(*(+(*)(*))(
+(*)(*))(+(*)(*)))))
))(+(*)(    *(+(+(*)
(*))(+(*    )(*))))(
*(+(*)(*    ))(+(*)(

*))(+(*)(*))(+(*)(*)
)(+(*)(*)))(*(*(+(*)
(*))(+(*
)(*))(+(*)(*)))(+(*)
(*))(+(*)(*))(+(*)(*
))))(+(*
(+(*)(*))(+(*)(*)))(
*(+(*)(*))(+(*)(*))(

+(+(*)(*
))))(*(+
(*)(*))(
+(*)(*))
(+(*)(*)
)(+(*)(*
))(+(*)(*)))(*(*(+(*
)(*))(+(*)(*))(+(*)(

*)))(+(*
)(*))(*(
+(*)(*))
(+(*)(*)
))))(+(*
(+(*)(*)
)(+(*)(*)))(*(+(*)(*
))(+(*)(*))(+(+(*)(*

))))(*(+(*)(*))(+(*)
(*))(+(*)(*))(+(*)(*
))(+(*)(    *)))(*(*
(+(*)(*)    )(+(*)(*
))(+(*)(    *)))(+(*
)(*))(*(    +(*)(*))
(+(*)(*)))))(+(+(*)(
*)(*))(*(+(*)(*))(+(

*)(*))  (+(*  )(*)))
(*(+(*  )(*)  )(+(*)
(*)))(  *(+(  *)(*))
(+(*)(  *))(  +(*)(*
))(+(*  )(*)  )(+(*)
(*)))(  *(*(  +(*)(*
))(+(*)(*))(+(*)(*))
)(+(*)(*))(*(+(*)(*)

)(+(*)(*)))))(+(*)(*
)(*(+(*)(*))(*(+(*)(
*))(+(*)    (*))))(*
(+(*)(*)    (*)(*))(
*(*(+(*)    (*))(+(*
)(*))(+(    *)(*))))
)(*)(*))(+(*(*(+(*)(
*))(+(*)(*)))(*(+(*)

(*))(+(*)(*))(+(*)(*
)))))(+(*(*(+(*)(*))
(+(*)(*)    )(+(*)(*
))))(+(*    )(*)(*))
(*(+(*)(*))(+(*)(*))
(+(*)(*)   ))(*(+(
*)(*))(+    (*)(*))
)(*(+(*)     (*))(+(

*)(*))(+
(*)(*))(
+(*)(*))
(+(*)(*)
))(*(*(+
(*)(*))(
+(*)(*))(+(*)(*)))(+
(*)(*))(*(+(*)(*))))

)(+(+(*)(*)(*))
(*(+(*)(*))(+(*)(*))
(+(*)(*)    ))(*(+(*
)(*))(+(    *)(*)))(
*(+(*)(*    ))(+(*)(
*))(+(*)    (*))(+(*
)(*))(+(*)(*)))(*(*(
+(*)(*))(+(*)(*

))(+(*)(
*)))(+(*
)(*))(*(
+(*)(*))
(+(*)(*)
))))(+(*

)(*)(*(+

(*)(*))(+(*)(*)))(*(+(*)(*))(+
(*)(*)))(*(+(*)(*))(+(*)(*))(+
(+(*)(*))))(*(+(*)(*))(+(*)(*)
)(+(*)(*))(+(*)(*))(+(*)(*)))(
*(*(+(*)(*))(+(*)(*))(+(*)(*))
)(+(*)(*))(*(+(*)(*))(+(*)(*))
)))(+(*(+(*)(*))(+(*)(*)))(*(+
(*)(*))(+(*)(*))(+(+(*)(*))))(
*(+(*)(*))(+(*)(*))(+(*)(*))(+
(*)(*))(+(*)(*)))(*(*(+(*)(*))
(+(*)(*))(+(*)(*)))(+(*)(*))(*
(+(*)(*))(+(*)(*)))))(+(+(*)(*
))(+(*)(*))(*(+(*)(*))(+(*)(*)
)(+(*)(*))(+(*)(*))(+(*)(*)))(
*(*(+(*)(*))(+(*)(*))(+(*)(*))
)(+(*)(*))(+(*)(*))(+(*)(*))))
(+(*)(*(*(+(*)(*))(+(*)(*)))(*
(+(*)(*))(+(*)(*))(+(*)(*))))))
\$\endgroup\$
3
\$\begingroup\$

H9+

H
H0
H01
H012
H0123
H01234
H012345
H0123456
H01234567
H012345678
\$\endgroup\$
  • \$\begingroup\$ This is awkward. Wait, is the output exactly “Hello, world!”? What implementation are you using? \$\endgroup\$ – James Wood Mar 8 '14 at 22:34
  • \$\begingroup\$ Yes, I'm pretty sure that's the exact output. I didn't run it, because I don't know of any online (read: convenient) interpreter. \$\endgroup\$ – Kendall Frey Mar 8 '14 at 22:43
  • \$\begingroup\$ This one doesn't give the correct answer. Please find one that does and run it yourself. \$\endgroup\$ – James Wood Mar 8 '14 at 22:57
  • \$\begingroup\$ @JamesWood, this is exactly what you would have expected if you'd looked at any of the other Hello World questions before posting your one. \$\endgroup\$ – Peter Taylor Mar 8 '14 at 22:57
  • \$\begingroup\$ @JamesWood I've called out a question on account of that intepreter. It is (and I was) wrong. :) Also note, it's for HQ9+, which apparently doesn't ignore non-instruction symbols. \$\endgroup\$ – Kendall Frey Mar 8 '14 at 23:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.