Hello world! with NO repetition

28

0

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.

Timtech

Posted 2014-01-19T22:27:35.643

Reputation: 12 038

if We are escaping character codes, can the "" character be used more than once? – WallyWest – 2014-01-19T22:40:29.357

4What about piet? – Victor Stafusa – 2014-01-19T22:48:37.477

@Victor "should only use ASCII characters" – Timtech – 2014-01-19T22:58:42.493

@Eliseod'Annunzio No, I'm sorry. – Timtech – 2014-01-19T23:00:13.720

Just checking, buddy! :) – WallyWest – 2014-01-19T23:15:06.203

Is the "followed by a newline" requirement really necessary? This is hard! D: – FireFly – 2014-01-19T23:44:35.013

@FireFly Yeah, it's necessary. – Timtech – 2014-01-20T00:21:16.890

Why ASCII only? – Vektorweg – 2014-01-20T03:47:26.103

Are Huby and CHIQRSX9+ allowed? – Victor Stafusa – 2014-01-20T08:13:26.810

Are ASCII control characters allowed? – tobyink – 2014-01-20T10:07:45.010

@tobyink I don't see why not. ASCII should include all bytes 0-127, and after all LF and CR are control characters too. – FireFly – 2014-01-20T10:10:27.480

@tobyink Yes, they are ASCII. – Timtech – 2014-01-20T11:04:56.067

3That was a great puzzle, and I enjoyed doing it :-). – Konrad Borowski – 2014-01-20T20:38:30.277

You should also disallow "Hello", "HQ9+B", and "CHIQRSX9+" – The Guy with The Hat – 2014-01-21T21:57:47.577

@RyanCarlson Okay, added them. – Timtech – 2014-01-21T22:47:16.617

About ASCII only: a few days ago i heard some bad things about developers of programming languages (C#, Java, ...), because they said that his language supports unicode, but at the same time don't do a correct abstraction of unicode. The length function returns the length in bytes instead of characters, for example. Now talking about ASCII only could be interpreted as discriminatory, because natural languages with more or other letters are handicapped. – Vektorweg – 2014-01-22T12:39:04.010

9“should only use ASCII characters” — what a draconian restriction. That removes an entire class of languages that don’t happen to use ASCII. – Timwi – 2014-01-23T18:49:25.153

So since Dom Hastings' answer seems to follow the specs, are command line arguments ignored?

– Jonathan Frech – 2018-02-21T00:46:36.810

I know this challenge is old, but would you mind adding Help, WarDoq! to the list of disallowed languages?

– MD XF – 2018-02-23T03:46:35.763

@MDXF Don't worry, that language was created after the challenge was posted. – Timtech – 2018-02-24T04:56:47.860

@Timtech No, the rule requiring languages created after challenges to be marked as non-competing has phased out, per this meta thread by me and Martin Ender.

– MD XF – 2018-02-25T00:30:46.970

@MDXF Alright, I added it for this challenge specifically then. – Timtech – 2018-02-25T05:02:19.747

The rule about "getting no input" - is it intended just to close a loophole (like fetching missing chars from elsewhere), or does it actually forbid to make any use of STDIN? Say, if I have a program that needs a single line of input to run correctly (the content doesn't matter, it could be any single hardcoded char unused in the code, it just must be non-empty), would this count as a violation? – Kirill L. – 2018-04-08T07:16:33.583

@KirillL. That could be okay in the same spirit as a command-line flag (so it still counts towards the bytecount), but I'm not understanding why you would need input if the contents of the input doesn't matter. – Timtech – 2018-04-08T15:27:22.060

@Timtech, I'm trying to solve this in Ruby, and the idea is using "-p" flag that runs the script once for each input line with implicit print. With empty input it just won't run at all. I've seen people using a trick that makes this flag work without input in Perl, but I couldn't find a functional Ruby equivalent. – Kirill L. – 2018-04-08T17:03:38.407

To be more specific, here is my current solution. Do you think it's OK?

– Kirill L. – 2018-04-08T17:05:40.877

What do you think this is... The radio program "Just a Minute?" – Lyxal – 2020-01-23T01:36:11.050

Answers

33

Perl 6 (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.

Konrad Borowski

Posted 2014-01-19T22:27:35.643

Reputation: 11 185

3Amazing! I need to get on learning. Some Perl 6 syntax! I agree with your comment too, was definitely a fun problem! – Dom Hastings – 2014-01-20T20:42:52.517

4Woah... my mind is blown :O +1 – Doorknob – 2014-01-21T22:12:52.907

12

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!

Dom Hastings

Posted 2014-01-19T22:27:35.643

Reputation: 16 415

Challenge has lower case w. – Ørjan Johansen – 2018-02-19T07:28:36.640

@ØrjanJohansen Thanks, I forgot! – Dom Hastings – 2018-02-19T08:35:57.197

11

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.

Ilmari Karonen

Posted 2014-01-19T22:27:35.643

Reputation: 19 513

Seriously impressed! I spent ages trying to get around the lls... – Dom Hastings – 2014-01-24T08:35:58.283

9

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

aaaaaaaaaaaa

Posted 2014-01-19T22:27:35.643

Reputation: 4 365

7

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.

BlackCap

Posted 2014-01-19T22:27:35.643

Reputation: 3 576

According to this, Keystrokes like <Esc> and combinations involving the Ctrl-key count as one byte – oktupol – 2018-02-20T08:16:37.090

6

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).

Jo King

Posted 2014-01-19T22:27:35.643

Reputation: 38 234

Very good but this challenge is without the comma. – Ørjan Johansen – 2018-02-19T04:46:06.177

Oh lol, that makes it easier... Thanks @ØrjanJohansen – Jo King – 2018-02-19T04:48:40.637

You have two of + and d. – Ørjan Johansen – 2018-02-19T05:14:02.250

@ØrjanJohansen oops. should be fixed now – Jo King – 2018-02-19T05:21:16.280

3

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!

Kirill L.

Posted 2014-01-19T22:27:35.643

Reputation: 6 693

1

Keg, 8 bytes

«H%c¡|,!

Just the standard hello world program!¡

Lyxal

Posted 2014-01-19T22:27:35.643

Reputation: 5 253

0

Stax (non-competing), 8 bytes

`dx/&\p4

Try it online!

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

Weijun Zhou

Posted 2014-01-19T22:27:35.643

Reputation: 3 396

0

W, 11 bytes

Just a compressed source literal.

►oδ'▲╪îΣ×φ←

user85052

Posted 2014-01-19T22:27:35.643

Reputation: