30
\$\begingroup\$

In any programming language that existed before this question was asked, write a program (not a function) that outputs the characters Hello world! followed by a newline. Your program:

  • should not use any character more than once (including whitespace)
  • should only use ASCII characters
  • should not use any built-in libraries
  • should not get input (user, file, filename, system variable, internet, anything)
  • should not output anything else

Winner is whoever has the most votes after 14 days and abides to the six rules.

The sixth rule is that you cannot use H9+, HQ9+, HQ9+B, HQ9++, HQ9+2D, Hello, Hello+, Hello++, Hexish, CHIQRSX9+, or Fugue. Also, all answers which require implementations that are newer than this challenge must be marked as non-competing.


Disclaimer: This question was posted with the assumption that Hello world! with limited repetition did not cause any damage to your computer or your brain in the process of coming up with the answers.

\$\endgroup\$
28
  • 4
    \$\begingroup\$ What about piet? \$\endgroup\$ Jan 19, 2014 at 22:48
  • 4
    \$\begingroup\$ That was a great puzzle, and I enjoyed doing it :-). \$\endgroup\$ Jan 20, 2014 at 20:38
  • 1
    \$\begingroup\$ You should also disallow "Hello", "HQ9+B", and "CHIQRSX9+" \$\endgroup\$ Jan 21, 2014 at 21:57
  • 16
    \$\begingroup\$ “should only use ASCII characters” — what a draconian restriction. That removes an entire class of languages that don’t happen to use ASCII. \$\endgroup\$
    – Timwi
    Jan 23, 2014 at 18:49
  • 3
    \$\begingroup\$ "should not use any built-in libraries" makes it impossible for I/O in languages like C and C++ where the I/O is in a built-in library. \$\endgroup\$
    – S.S. Anne
    Mar 7, 2020 at 3:44

11 Answers 11

38
\$\begingroup\$

Raku (29 28 characters)

This was somewhat annoying, but I finally managed to make a program for this task. Thanks go to the great #perl6 community, for helping me with this task. It took me two hours, hope you enjoy. The output is completely up to specification, including a newline.

say
Q[@A`DO world!]~|<HeLhg>

There are four tokens of interest.

  • say

    This outputs the argument with new line at end. The new line after the command itself is needed as a space replacement.

  • Q[@A`DO world!]

    This is the first string. Q[] is for raw strings (like r"" in Python). It can take any delimiter (or pair of them), in this case []. In this case, I use this for quotes, I don't need raw string behavior.

  • ~|

    This is stringwise (~) bitwise or (|) operator.

  • <HeLhg>

    <> is list literal, which takes space separated list of elements. In this case, it has one element, and used as a scalar, it gives a string.

\$\endgroup\$
2
  • 3
    \$\begingroup\$ Amazing! I need to get on learning. Some Perl 6 syntax! I agree with your comment too, was definitely a fun problem! \$\endgroup\$ Jan 20, 2014 at 20:42
  • 4
    \$\begingroup\$ Woah... my mind is blown :O +1 \$\endgroup\$
    – Doorknob
    Jan 21, 2014 at 22:12
14
\$\begingroup\$

Perl 5.10+: 24 chars

say+He,YZX^q(567 world!)

OK, I think this is as short as it gets in Perl.

Run with perl -M5.010 (or just perl -E) to enable the Perl 5.10+ say feature.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Seriously impressed! I spent ages trying to get around the lls... \$\endgroup\$ Jan 24, 2014 at 8:35
14
\$\begingroup\$

Perl 5 with -M5.010, 29 bytes

say+He.v108
x2,q(O world!)^$"

Try it online!

I've gained a lot of knowledge since I first attempted this. Still not as short as the other answers, but the best I can come up with!

\$\endgroup\$
2
  • \$\begingroup\$ Challenge has lower case w. \$\endgroup\$ Feb 19, 2018 at 7:28
  • \$\begingroup\$ @ØrjanJohansen Thanks, I forgot! \$\endgroup\$ Feb 19, 2018 at 8:35
12
\$\begingroup\$

Vim 7.3, 18 keystrokes

:h-cu
9j3wy$<C-^>P<End>r!o

Copies the string Hello world from this helpfile, which unfortunately has been removed in never versions of Vim.

\$\endgroup\$
3
  • \$\begingroup\$ According to this, Keystrokes like <Esc> and combinations involving the Ctrl-key count as one byte \$\endgroup\$
    – oktupol
    Feb 20, 2018 at 8:16
  • \$\begingroup\$ So it wasn't a permanent solution \$\endgroup\$
    – gildux
    Feb 3 at 0:58
  • \$\begingroup\$ Maybe something like iHelwxrd<Esc>3|yl3pr $P2hro0E. or similar \$\endgroup\$
    – gildux
    Feb 3 at 1:31
10
\$\begingroup\$

Golfscript 42 33

I might as well golf this, considering that I had to fit some of the code and all of the data in the same block with no way of delimiting the two I think this is a pretty short result. Unlike my first submission the block code is now a fully integrated part of the data, thus {1 do not only begin the block and put a 1 on the stack, it is also the data that defines the H, and so forth. The array creation now includes the empty input string, which means that I don't have to crop the beginning as there is only one character between the empty string and the H, that character is cut away when I take every second character, and the empty string eventually is output as nothing.

{1wZ$Qei^Ak 3h-)ulmsogr7}.`*]2%n+

Online demo: http://golfscript.apphb.com/?c=ezF3WiRRZWleQWsgM2gtKXVsbXNvZ3I3fS5gKl0yJW4r

[{1$^(r iFNGDJUHv98oIMgtplbh4m}.`\*]6>2%n+

Defines a code block. Makes a copy of the code block and converts it to string. Uses the code block to iterate over the string. For each iteration the code will make a copy of the previous char value, xor it with the current char value, and subtract 1. The resulting string then has the first 6 characters removed, and every second character removed. Finally a line feed is appended.

"r iFNGDJUHv98oIMgtplbh4m" is just two undeclared variables, they do nothing, but they are carefully constructed to produce the desired result.

Online demo: http://golfscript.apphb.com/?c=W3sxJF4ociBpRk5HREpVSHY5OG9JTWd0cGxiaDRtfS5gXCpdNj4yJW4r

\$\endgroup\$
0
7
\$\begingroup\$

Befunge-98, 34 31 bytes

f"v!dlrow
+c<>a,kb@#*98e':g05-3

Try it online!

Uses quite a few different methods to avoid duplicated characters.

First, we use wrapping string literal to avoid using two "s. This adds " world!" to the stack.

Going left on the second line, we add 9 to the extra f to make the o of the "Hello". We get the character from cell 5,0 (l) and then duplicate it. The ' is used to fetch the letter e. Multiply 9 by 8 to get 72, the ASCII value of H. We then print it everything using ck,, and flip the direction with the > to reuse the , to print the newline (a).

\$\endgroup\$
4
  • \$\begingroup\$ Very good but this challenge is without the comma. \$\endgroup\$ Feb 19, 2018 at 4:46
  • \$\begingroup\$ Oh lol, that makes it easier... Thanks @ØrjanJohansen \$\endgroup\$
    – Jo King
    Feb 19, 2018 at 4:48
  • \$\begingroup\$ You have two of + and d. \$\endgroup\$ Feb 19, 2018 at 5:14
  • \$\begingroup\$ @ØrjanJohansen oops. should be fixed now \$\endgroup\$
    – Jo King
    Feb 19, 2018 at 5:21
6
\$\begingroup\$

Elixir, 37 bytes

IO.puts~c(He#{[?n-2,108]}\x6f world!)

Try it online!

I can't guarantee that this would have worked back in 2014 when this challenge was posted, and Elixir was still pre-1.0 (and thus, whether it is formally "competing", but looking at their release notes, I think it should be OK). Anyway, I'm happy that I finally found a valid solution to this task using a conventional general purpose language other than Perl!

Walkthrough

IO.puts     #Print with trailing newline
~c(...)     #Sigil: charlist with interpolation
He          #Start of literal string...
#{...}      #Interpolated block
[?n-2,108]  #A list of codepoints for 2 'l's
\x6f        #Hex code for 'o'
world!      #...and done!
\$\endgroup\$
4
\$\begingroup\$

Keg, 17 bytes

Hel:o Wn1+rp4-d\!

Try it online!

\$\endgroup\$
0
1
+100
\$\begingroup\$

Vyxal, 6 bytes

kh\!+,

Try it Online!

Basically the normal way of printing "Hello World!" in Vyxal.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ should only use ASCII characters \$\endgroup\$
    – l4m2
    Feb 3 at 1:06
1
\$\begingroup\$

Vim, 21 keystrokes

2iHelo WORLD!Escgu8h10X

Try it online!

Vim adds a newline at the end of the file so there's no need to add it explicitly.

To run it locally:

  1. Save the code to a file (here hello_world.vim) replacing Esc with `` (\x1b).
  2. run vim -u NONE -s hello_world.vim hello_world.txt.
  3. exit Vim.
\$\endgroup\$
0
\$\begingroup\$

Stax, 8 bytes

`dx/&\p4

Try it online!

Just a compressed string literal. Luckily Stax lets me go without the closing backtick.

\$\endgroup\$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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