# Hello world! with limited character repetition

In a language of your choice, write a program that exactly outputs the characters Hello world! followed by a newline. The code:

• should not use any character more than twice (alphanumeric, symbol, whitespace...anything)
• should not use any external resources
• should not use any user input
• should not output anything else

An example of a valid python program:

print("He%so world!"%(2*'l'))


An example of an invalid python program (the character 'r' is used three times):

print("Hel"+chr(108)+'o world!')


Winner is whoever has the most votes after 14 days.

EDIT: A winner has been chosen! Thanks all for your work on this question!

• What about the repeated letter o in the "valid" python example. There also these:- " ' ( ) – Adam Speight Jan 17 '14 at 16:35
• @AdamSpeight what do you mean? The letter is only used twice, as per the specs. – Josh Jan 17 '14 at 16:37
• @AdamSpeight ... which is literally the same. – VisioN Jan 17 '14 at 16:42
• I think you mean a character should not appear more than twice, that is, it should not be repeated more than once. – Michael Kay Jan 17 '14 at 18:15
• I guess brainfuck is out of the question... – jub0bs Jan 17 '14 at 18:26

## GolfScript, 21 characters

'He'[108]+"lo world!"


108 is the ASCII code for l.

First, I push He on the stack. Then, He gets popped and becomes Hel. Then I push lo world! on the stack. Now there are two elements on the stack. Because at the end of a GolfScript program, everything of the stack is outputted, this program outputs:

Hello world!

followed by a newline, because Golfscript always outputs a newline.

## AWK,34

BEGIN{printf"Hel%co world!\n",108}


# nginx.conf

set $i l; return 202 "Hel${i}o world!\n";


In action:

opti# curl -6v "http://localhost/"
* About to connect() to localhost port 80 (#0)
*   Trying ::1...
* connected
* Connected to localhost (::1) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.26.0
> Host: localhost
> Accept: */*
>
< HTTP/1.1 202 Accepted
< Server: nginx/1.4.1
< Date: Fri, 17 Jan 2014 18:02:08 GMT
< Content-Type: application/octet-stream
< Content-Length: 13
< Connection: keep-alive
<
Hello world!
* Connection #0 to host localhost left intact
* Closing connection #0

• Unfortunately your code has three e's and three l's! – Josh Jan 17 '14 at 18:13
• One of the duplicate l's can be removed easily. e is harder, unless nginx is case-insensitive – SztupY Jan 17 '14 at 18:20
• Don't forget the spaces! – Vereos Jan 17 '14 at 18:52
• And 3×'r', as well – Joel Purra Jan 19 '14 at 14:22

# HTML — 17 characters

He&#x6c;lo world!


In action:

%echo -n "He&#x6c;lo world!" | wc
0       2      17
%echo -n "He&#x6c;lo world!" | lynx -dump -stdin

Hello world!

%


# Clojure (35)

(printf "He%c%co world!\n",108,108)

The whitespace almost got me, but Clojure allows the use of commas to separate parameters.

• You could always have used different types of whitespace--space, newline, tab, vertical tab, form feed. I'm not completely sure of Clojure's grammar off the top of my head, but the first tree ones would likely work at least. – FireFly Jan 18 '14 at 10:37
• But it was interesting to try out this use of commas in Clojure. I thought I'd read somewhere that they could be used to substitute for whitespace but hadn't messed with it. – Bob Jarvis - Reinstate Monica Jan 18 '14 at 12:40
• As MrWonderful pointed out for my Scala version, you're only using a single 'l'. You could save a few characters by using your second, for (printf "Hel%co world!\n",108) – KChaloux Jan 18 '14 at 16:41

# Perl, 28 chars

printf"He%so world!\n",'l'x2


Rules tested with:

perl -e '$"="\n";@a=split//,<>;print"@a";' | sort | uniq -c | sort  # C (32 characters) main(){puts("He\x6clo world!");}  # Plain TeX - 18 chars He^^,lo world!\bye  Remark: TeX terminates the paragraph before shipping it, so the "newline" is actually included. # Taking it directly from the instructions on this page: curl -sL bit.do/gBfx|perl -E'@Q=map{m%OUtPUTS The chARAC.ERS\N*?>([^<]+)%i?$1:()}<>;say$Q[1]'  or, if you wanna be strict with the white-spaces: # PERL curl -sL v.gd/92XIMS=~m%ThE\WChAracTERS.*?>\K[^<]+%i;say$&


or

curl -sL v.gd/qmwAMh=~m%outpUtS\WTHE\WChAracTERS.*?>([^<]+)%i;say$1  Advantage: will work for every sentence, but please don't change wording of the question :) Rules: we can consider this question being an "internal" resource. Without this question, no one would solve it. Should it be me or the program reading it? :) Backstage story: I almost teared out all my hair trying to debug this! :) First solution • using wget -O- leads to 3x - • sed needed too many / • so I need curl and perl, but all perl loops like until, while contain 3rd l! • I needed to replace the loop, this is quite complicated but • it seems $1 only works after positive (=~) not negative (!~) match
• I couldn't use !(..) - too many parentheses :x
• neither I could use || (I need a pipe!) or or (perl, curl ...)

Second solution

• I reread the rules. White-spaces shouldn't be repeated either - oh my!
• At least could recycle the do{}while idea. Better said, it was forced, the map solution could not be used for using () 2 times, 3rd needed to call open since no more whitespaces are left.
• Find proper url shortener was a story, using goo.gl, bit.ly, is.gd or ow.ly was obviously impossible for the first solution, as was bit.do and dft.ba for the second. Then, url-shorten the URL until you get something you can use, especially with bit.ly and v.gd. Why on earth they use so much lowercase characters?

The regex could be shortened, but I like the instructions to be as long as possible :-)

These rules are damn crazy :)

PERL v5.10 say feature has to be enabled, e.g. by running PERL -E option

• For the first one, you have a backslash left, right? You could do two tabs and one escaped newline for the spaces in the shell part. – FireFly Jan 20 '14 at 9:55
• @FireFly what a neat idea :) I don't now why I limited myself to spaces. I guess because I like one-liners that can just be copy-pasted :) – Innate Imunity is The Way Jan 20 '14 at 9:59

## Keg, 13 bytes

The winner was chosen, but I still want to do it. :) (Astonishingly it is shorter than HTML!)

Hel:o world\!


This is a popularity contest, but the program is very easy to understand despite of the conciseness.

## Explanation

Hel          #Push "Hel" onto the stack
:         #Duplicate the top of the stack (l)
o world  #Push "o world" onto the stack
\!#Escape ! and push it onto the stack(since it is an instruction)


# LINQPad, C# Expression - 22 chars

"Hello w\x6fr\x006cd!"


## PHP, 30 characters

<?=Hello.' wor'.chr(108),"d!";


HTML - (16 Chars):

Hello Wor&#108d!


Proper HTML would be to put a ; after &#108 but it still compiles fine. :)

• HTML... compiles fine? – Mr Lister Feb 20 '14 at 11:57
• @MrLister Yes, it compiles fine. It is a good practice to put a ; at the end of it, but it still compiles. – Dozer789 Feb 20 '14 at 23:40
• Oh wait, now I get it. You're creating .chm files! Sorry I didn't get that the first time. – Mr Lister Feb 21 '14 at 5:53
• @MrLister, Uh... No. I'm making .htm files. – Dozer789 Feb 21 '14 at 19:02
• Let's just agree to disagree; that would be easier. – Mr Lister Feb 22 '14 at 9:39

## C

q=7103816;
main(){printf("%slo world!%c",&q,2+8);}


Works on little-endian platforms, where 7103816 is encoded the same as Hel\0.

• Missing \n at the end. – mcleod_ideafix Jan 19 '14 at 2:10
• Thanks @mcleod_ideafix. I was going to simply add \n, but I'm out of ns. Fortunately, I had % and , to spare. – ugoren Jan 19 '14 at 7:47

# Lua - 22 characters

print"Hel\108o World!"


Simple enough, example output

lua -e 'print"Hel\108o World!"'
Hello World!


# Яussian

Хелло мир!

A mix of transliteration and proper language :) Google translate will turn it into proper "Hello world!"

• I guess this wouldn't even be accepted in a code-trolling question, lol. Nice interpretation of the In a language of your choice sentence, but here's Programming Puzzles and Code Golf site! – Vereos Jan 20 '14 at 11:44
• @Vereos thanks :) – Indoor Jan 24 '14 at 0:53

# C, 41

main(){printf("He%clo world!%c",108,10);}

• You're using the character n three times. (main, printf, \n) – Darren Stone Jan 21 '14 at 8:00
• Good work replacing the \n but your score was wrong. I updated the 33 to 41. – Darren Stone Jan 21 '14 at 9:16

# Javascript, 19ch

> 'Hello Wor\154d!\n'

Character count:

> "'Hello Wor\154d!\n'".length -> 15 //cough, cheating

> "'Hello Wor\\154d!\\n'".length -> 19

With your choice of return, alert(), or nothing? Man, javascript has too many contexts.

Slightly more interesting: ["He",,'o World\n'].join('l')

• Your correct variant has 4 times \ I think ;) – yo' Jan 30 '14 at 21:57

## R

Not gonna win anything, but I didn't see R yet...

'He\154\154o, World!'
'Hello, Wor\154d!'


# TI-BASIC, 33 bytes on-calculator

"l→Str1:Disp "He..o World!
Str1:Output(2,3,Ans+Ans


Since TI-BASIC uses tokens instead of characters, I limited myself by token. Make sure the screen is cleared before running the program. Note that l and o are two-byte tokens, but w is a sequence variable and d, e, and r are statistics variables, which are all one-byte tokens. This program first Displays the string without the first two l's, and then uses a different command to paste in the other two. Also note that TI-BASIC has no equivalent to a newline, but when the program ends the cursor does move down to allow further input to the calculator.

• Oh wait, I used 4 commas. I will have to redo this – Hello Goodbye Dec 31 '18 at 0:30
• Wait, this doesn't work at all because Disp overwrites Ans. – Hello Goodbye Dec 31 '18 at 0:39
• Fixed. I now made use of both Str1 and Ans. – Hello Goodbye Dec 31 '18 at 0:44

## Hexish

0B

• According to the documentation that prints hello world. We need a capital H, a !, and a newline. Close, but no cigar! – Josh Jan 17 '14 at 22:21
• @Josh Closer than you think... it actually prints Hello World! – Timtech Jan 17 '14 at 22:23
• Ehm, the Esolang page says that this language falls under the category "Unimplemented". Is that allowed? I mean, are unimplemented languages allowed? – Mr Lister Jan 18 '14 at 7:12
• In that case, I will now invent a new language SECODEGOLF where every program consists of a single decimal number, and the output is the solution to the corresponding CodeGolf question. For instance, the program 18721 would print "Hello World!" and a newline. – Mr Lister Jan 18 '14 at 7:26
• @MrLister Arguably SECODEGOLF is mostly implemented by this website. (Part of the implementation is crowd-sourced.) And most languages' specifications are only mostly implemented. :) – Eliah Kagan Jan 18 '14 at 9:17

main=print"Hello Wor\108d!"

Twice-check:

import Data.List
main=getContents>>=print.all((<3).length).group.sort


# q/kdb [16 chars]

"hel\154o world"

• itym -1"Hel\154o world!"; – Aaron Davies Jan 20 '14 at 9:35

# Node.js - 54 Unicode characters

eval([]+Buffer('consolť.ŬůgĨĢHťŬɬů wɯrɬd!Ģĩ',"ascii"))


console.log outputs a given string and a line shift, unfortunately that initially leaves me with way too many ls and os, so it took some work.

The code creates a buffer from a string and is told to use ascii encoding, this effectively takes all character values mod 256 and stores them in the buffer, the buffer is then added to an empty array, which cause both buffer and array to be converted to string before the addition, an empty array converts to an empty string, and the buffer is implicitly converted using UTF-8 encoding. The result is evaled to produce the desired result.

# PHP 5.1.2+

<?="\x48".hasH_file(@cRC32b,__FILE__,'« Tý'|5)." wor\X6Cd!";


The code hashes itself to get the remaining characters. Repeats the characters ".\,'_

A tab messes up the formatting. Base64:

PD89Ilx4NDgiLmhhc0hfZmlsZShAY1JDMzJiLF9fRklMRV9fLCfCqwlUw70nfDUpLiIgd29yXFg2Q2QhIjs=

• Nice hack, but I count 4 underscores. – aaaaaaaaaaaa Jan 19 '14 at 18:36
• @eBusiness Five _ actually, and four times " :) – yo' Jan 30 '14 at 22:20

## newLISP

Such a cruel challenge for a Lisp-like language, where so much is possible if only you don't count parentheses... :) But a solution can be found:

 (eval-string(encrypt {4?3%;=6^9z*9&^m=>*],c;W}{HDMZKOQX~B2OUJ1MJQX1HBF~KU2FZD}))


(81 characters)

which uses the simple encrypt function to pass a command through to the evaluator. The actual command is (println {Hello world!}). (Having "z" and "Z" and "Z" is allowed, according to the comments...:)).

# POSIX shell (Bash et al) - 26 chars

printf 'Hel\x6Co world!\n'


# k/q (25 chars)

-1@.h.uh"Hello wor%6cd!";

works in either k or q

(btw, the validity can be checked elegantly with |/#:'="-1@.h.uh\"Hello wor%6cd!\";")

http://esolangs.org/wiki/Hello%2B%2B

H
`

1 letter is all it takes to print that

BASH

printf "a\107Vs\x62G8gd29ybGQhCg=="|base64 -d