# 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

# JavaScript (52 characters)

alert(['He\x6C\x6Co world!'][(!1,0)-0], +-1+"Hadtw")


Each character is used 2 times, and it doesn't use any comments!

Edit: I've just posted the same answer here.

# Active Server Pages (Classic ASP):

Hel<%REspOnsE.wRite Chr((0<0>-.6&"!")+&H6C+h-dinptO)
%>o world!



Each character is used twice!

To run it, you'll need a web server running IIS.

Save it in the site root with a ".asp" extension, make a HTTP request to the server, and you'll see that the response text is exactly "Hello world!" and a new line:

Hello world!



Edit: You could also use this smaller code:

Hel<%= Chr((0<0>we=6&"!")+&H6C+hd)
%>o world!



Or this:

Hel<%= CHr((0<1>wedC=8&"!&")++108)
%>o world!



# c-41

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

• Doesn't work in general: codepad.org/O09aQhCe - on what platform does character code 186 give you 'll' ? – Paul R Jan 18 '14 at 10:33
• In MS-DOS (code page 437 and similar) character with code 186 is double vertical line, used for drawing frames. – AMK Jan 18 '14 at 12:22
• It's 38 chars. You missed '!'. Besides, the two vertical bars are not two L's – mcleod_ideafix Jan 19 '14 at 2:06
• It produces this output: He||o world! I'm using code blocks – Mhmd Jan 19 '14 at 9:43
• Without ending '\n' this answer contains 35 chars. And output looks wery similar to Hello world!. But this answer may be wroted shorter as main(){puts("He║o world!");} – AMK Jan 19 '14 at 18:52

# JavaScript 35

With inspiration from @VisioN

alert(atob("SGVsbG8gV29y")+'ld!\n')


# Tcl, 21 bytes

puts Hello\ wor\x6cd!


Try it online!

# SmileBASIC

?@H[1]+@e[!0];CHR$(108);"lo world!  Another solution: CLS?"He__o world! LOCATE 2,0?@l[1]*2  In C. Choose one of these. My favourite (crazy but compact in memory): #include <stdint.h> printf("%s", (char*)(int32_t[]){1819043144,1870078063,6581362});  For those who like big numbers: printf("%s", (char*)(int64_t[]){8031924123371070792,43509902450});  Or here the more descriptive versions: printf("%s", (char*)(int32_t[]){0x6c6c6548,0x6f77206f,0x646c72}); printf("%s", (char*)(int64_t[]){0x6f77206f6c6c6548,0x0a21646c72});  char map: H e l l o w o r l d ! <LF> 48 65 6c 6c 6f 20 77 6f 72 6c 64 21 0a (remember to swap big/little endian bytes when composing)  Btw: why there is no 128 bit integer in C? printf("%s", (char*)(int128_t[]){0x0a21646c726f77206f6c6c6548}); printf("%s", (char*)(int128_t[]){802616035175250124568770929992}); // string uses only 100 of 128 bits  • These don't met the requirements as some characters are used more than twice. Eg ( ) 0 1 2 9 etc etc – Adam Speight Jan 17 '14 at 22:50 • When I look at the example in the question, I see print("He%so world!"%(2*'l')) which is 1p 2r 1i 1n 1t 2( 2" 1H 1e 2% etc. Even when I focus to the string I still see 2 o's, so why should my answer follow the rules when the question doesn't? ;-) – Daniel Alder Jan 17 '14 at 22:57 • printf("%s", (char*)(int32_t[]){1819043144,1870078063,6581362}); ( x 3, ) x 3, 1 x 5, 3 x 3, 4 x 4, 6 x 3, 8 x 4 – Adam Speight Jan 17 '14 at 23:08 • Ok, I see. I misunderstood the specs. But I'm not the only one, when I look at the bash + ruby solutions of SztupY and the solution of cnst – Daniel Alder Jan 18 '14 at 0:11 • Just because someone else didn't follow the rules doesn't justify you. – Dozer789 Jan 18 '14 at 19:11 AWK and echo EDIT: fix the extra o's following the note. (thanks ProgramFOX) echo He: | awk -F: '{print$1,Q,"\157 Wor",Q}' OFS=l ORS=d\!


and thanks awk which give me the option to say "-F" instead of "IFS=" (:-)

• There are too many spaces, too. after echo, after He:, after |, and so on. – Vereos Jan 21 '14 at 8:33

Java

Okay I found this on SO, it doesn't output a big H

Rare sequence of random stream of digits for 2 specific seeds.
Probably fixed out by brute forcing
One of the SO solutions also include a brute forcer to make your own sequences.

System.out.println(randomString(-229985452) + " " + randomString(-147909649) + "!");


And randomString() looks like this

public static String randomString(int i)
{
Random ran = new Random(i);
StringBuilder sb = new StringBuilder();
for (int n = 0; ; n++)
{
int k = ran.nextInt(27);
if (k == 0)
break;

sb.append((char)('' + k));
}

return sb.toString();
}

• And this meets the specs, how? I can easily count 3 S's, 3 spaces, 3 2's, etc. – Justin Jan 18 '14 at 8:05
Console.Write("He{0}{0}o world", "l");

• Can you please state the language? Also, a little explanation will help. – Justin Jan 18 '14 at 7:03
• obviously C# :) – SSpoke Jan 18 '14 at 9:27
• Too many ls, too many os, too many "s, too many es... I guess this needs a revision :P – Vereos Jan 18 '14 at 12:20

I think that the only character which is being repeated more than twice is 'l' how about assigning variables

For language C:(Note,i am bad at syntax)

main(){

char *x=*b='l';

printf("Hel%so wor%sd!",x,b);}


and using them instead of 'l' while printing ??

It's not elegant as the answers already here.But it is fair and simple ?right ??

• Why don't you post a code instead – Mhmd Jan 19 '14 at 9:45
• Welcome, @AnikitSrivastava. You should submit code to solve the programming challenge or else place your comments under the question itself. – Darren Stone Jan 19 '14 at 9:49
• @user689 done that .... – Ankit Srivastava Jan 19 '14 at 10:11
• @DarrenStone okay, i have added the code now. – Ankit Srivastava Jan 19 '14 at 10:12
• Cool. But it's not quite valid. You are using the character r three times. Also, please compile your submission to ensure the syntax is valid. Warnings are fine but you have a compile error with the undeclared b`. – Darren Stone Jan 19 '14 at 10:24