# “Hello world!”, repeating each character n times [closed]

In your language of choice, write a program that outputs exactly Hello world!. Each character in your program must be repeated n times - you choose n.

For example, you might choose 2 for n. This means that every character used in your source code must be repeated that many times, or 0.

If I were to choose 3 for n, this program would be valid:

ab(b(b(aa)));;;


Rules:

• You cannot use any external resources
• No user input can be provided
• You must output exactly Hello world!, no more, no less. Newlines are the exception, they are optional.
• n must be >= 2, to keep things interesting

Popularity contest, ending in 14 days. Highest score answer at the end wins!

## closed as too broad by Dennis♦Sep 30 '16 at 17:03

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• Let's steal every answers from this topic: codegolf.stackexchange.com/questions/18925/… with n=1 – Fabinout Jan 21 '14 at 17:33
• Oops, let's say that n>=2, @Fabinout – Undo Jan 21 '14 at 17:33
• here's a JSFiddle I threw together for testing if anyone needs it – Doorknob Jan 21 '14 at 22:22
• I'd love to see a HQ9+ solution for this. – Nzall Jan 22 '14 at 8:38
• @Nate HQ9+ outputs a comma (as noted in a deleted answer). ;-) – Doorknob Jan 22 '14 at 13:31

# Brainfuck

n=57. 45 newlines removed thanks to ratchet freak

++++++++++[>+++++++>++++++++++>+++<<<-]>++.>+.+++++++..+++.>++.<++++++++.--------.+++.------.--------.>+.---------------------------------[.............................................][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]<-<<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><


+++++ +++++ [
> +++++ ++
> +++++ +++++
> +++
<<< -
]
> ++ .
> + .
+++++ ++.
.
+++ .
> ++ .
< +++++ +++ .
----- --- .
+++ .
----- - .
----- --- .
> + .
---------------------------------[.............................................][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]<-<<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><


The last line (on the readable version) is for filling up the character count. They are not comments. The [] are while(0)s, and the ><s are in essence no-ops

• couldn't you put the . inside one of the [] and not output the newlines – ratchet freak Jan 21 '14 at 20:21
• @ratchet freak Good point. Thanks. – ace Jan 21 '14 at 21:14
• I think ratchet was suggesting moving the [ in the first [] to before the dots, so that it wouldn't output even NULLs. – Ilmari Karonen Jan 22 '14 at 11:34
• @Ilmari Karonen Oh right, I see. Thanks. – ace Jan 22 '14 at 13:24

## JavaScript

alert(("aaaeerrttt((,,,HHHoo   wwwddd!!!))","Hello world!"))


This seemed a little too easy.

# Python 3, n = 3, no comments

dwwppHottedHen =print((("H[e]l1l1o\\ !w!orrilidn!\""[::2][:12])))== 2


Not too hard for a Pythonist to understand. ;) (Hint: try "abcdefghijk"[::2] and see what it results in)

By the way, a HottedHen is a warmed up chicken, if you were wondering. (The dwwpp before it stands for drinking water with purple pancakes, because that's what the hens were doing when I was writing it. Everyone knows that purple pancakes go well with water. Obviously.)

## C, 54

main(Hadmeinwurst015p){{!puts("Hello\40wor\154d!");;}}

• You have a v that doesn't match – Eduard Florinescu Jan 21 '14 at 22:15
• @Eduard hm, you're right, it must've slipped in there accidentally because it doesn't seem to have been included in the character count... fixed. – FireFly Jan 21 '14 at 22:28

## Golfscript - 32

New version with 2 of each used character - 32 - Test online

;"Hello wor\x6cd!" '\Hewrx6cd!';


Old version - 39 - Test online

;;'Hello world!'  "'HHeewworrdd!!\\\"";


EDIT: Updated since rules was updated saying it was discouraged with the use of comments

• Much better without comments! – Undo Jan 21 '14 at 17:46

# Java - 1221 chars

Each character is repeated (int)'!' number of times.

public class ncharacterHelloworld {
public static void main(String[] args){
{;
{;
{;
{;
{;
{;
{;
{;
{;
{;
{;
{;
{;
{;
{;
{;
{;
{;
{;
{;{;{;{;{;{;{;{;{;{;{;{
String pppppppppppppppuuuuuuuuuuuuuubbbbbbbbbbbbbbbllllllllllliiiiiiiiiiicccccccccccccaaaaaaaaaaaassssssssssssssnnnnnnnnnnnnnhhhhhhhhhhhhhhhhrrrrrrrrrrrrttttttttttteeeeeeeeeeeeeeHHHHHHHHHHHHHHHooooooooooooowwwwwwwwwwwwwwwdddddddddddddddvvvvvvvvvvvvvvvvmmmmmmmmmmmmmmmSSSSSSSSSSSSSSSgggggggggggggggyyyyyyyyyyyyyyyy="Hello world!",
a=pppppppppppppppuuuuuuuuuuuuuubbbbbbbbbbbbbbbllllllllllliiiiiiiiiiicccccccccccccaaaaaaaaaaaassssssssssssssnnnnnnnnnnnnnhhhhhhhhhhhhhhhhrrrrrrrrrrrrttttttttttteeeeeeeeeeeeeeHHHHHHHHHHHHHHHooooooooooooowwwwwwwwwwwwwwwdddddddddddddddvvvvvvvvvvvvvvvvmmmmmmmmmmmmmmmSSSSSSSSSSSSSSSgggggggggggggggyyyyyyyyyyyyyyyy,
u="\"=============================,,,,,,,,,,,,,,,,,,,,,,...............................",b="\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\\\\\\a",i,l,c,t,H,o,w,m;int[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]ffffffffffffffffffffffffffffffff;
if(!(!(!(!(!(!(!(!(!(!(!(!(!(!(!(!(!(!(!(!(!(!(!(!(!(!(!(!(!(!(!!true)))))))))))))))))))))))))))))))
System.out.println(a);
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
}

}

I got tired of putting all the = and , and the like in the code, so I ended dumping them all in a String; not a comment, a string. Every valid character is used for a variable name.

## Windows Command Script - 33 bytes

3 of everything:

ecHo Hello world!% eHccwwrrdd!!%%


# Windows Command Line - 42 Bytes

n=3

ecHo.Hello world! 2>^>2cceHwwrrdd!.. 2>^^!


## Batch - 45 Bytes

@ecHo.Hello world! 2>^>2cceHwwrrdd@@..! 2>^^!


2> redirects stderr to a file called >22cceHwwrrdd - > is an invalid character for a file name - redirect the output of that error to a file called ^!.

Realized that I completely ignored ! and >. Dang.

• I spy 4 spaces :( – eithed Jan 22 '14 at 0:18

# Ruby - 40 Chars (n=2)

print "Hel\x6co World!"||'pintHe\x6cWd!'

• How many spaces do you have? Is it correct to say that the first two around p are tabs (or something similar)? – Justin Jan 22 '14 at 4:41
• @Quincunx First space was a typo.Now edited – shiva Jan 22 '14 at 4:45

## PHP - 30 bytes, n = 2

Hell<?='=s?<;^2s'^RSHSI2VReIV;


Shortest solution thus far. I may be able to reduce this by 2-4 more bytes.

## PHP

<?print"H\145llo wor\154d!"; $Hwpintd<>!'$';?>


Shorter version (42 char):

<?print"H\145llo wor\154d!"; 'Hwd<pint?!';


Online page with that source

# C, 7556 54

2 of everything

main(HWacdeimnprstux6) {{!puts("Hel\x6co\ World!");;}}


main( ){puts("Hello Wor\x6cd!\0!;HWacdeimnprstux06{}");}


3 of everything.

main(){puts("Hello World!\000!!;;HHWWaaddeeiimmnnpprrssttuu{}{}\"\()o");}


Puts stops reading after the first null byte (\000), and only outputs everything before it.

• In the first i is kind of lonely! :) – Eduard Florinescu Jan 21 '14 at 22:20
• Your first two have only one i (easy to fix: change the main argument name). Your last only has one space – Doorknob Jan 21 '14 at 22:20
• @EduardFlorinescu Lol, I posted that exactly at the same time as you :P – Doorknob Jan 21 '14 at 22:21
• Oops, the first was missing. The second had it, just out of place. – Kevin Jan 21 '14 at 22:26

# Python:

With 3 characters each.

print 'Hello world!'#He's aware#paints#Hipos!nddwt!


nddwt is a rhino!

# JavaScript 40 (n=2)

I took a slightly different approach to @eithedog, using the left over letters to act as a logic trigger, so that it was absolutely essential to use it to activate the alert function.

('Hawtd !')&&alert("He\x6c\x6co world!")

Python 2, 38

deinptw=H=5; print"Hel\154o world\41";


Javascript, 40

alert("Hel\x6Co wor\x6Cd!", !('adtHw,'))


If I'm not mistaken every character appears twice (though I started seeing double, so I'm not sure)

edit: And, if abusing the rules - 36:

alert("Hel\x6Co wor\x6Cd!")( !wdatH)


(abuse = while output is given as a prompt, the console displays the error - don't know how to treat this).

• r appears 3 times while w only appears once. (in both versions) Just replace the final r with w to fix it – Doorknob Jan 21 '14 at 22:19
• Oh, dyslexia, you cruel mistress... Thanks! – eithed Jan 22 '14 at 0:07

# Bash, 39

echo -e "H\r--w\"!wccdd!\rHello world!"


This displays exactly Hello world!, and is 39 chars if you omit the trailing newline (bash doesn't seem to need it).

If you need a case-sensitive version, it becomes 42 chars:

echo -e "HhhH\r--w\"!wccdd!\rHello world!"


# 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!

Note: I posted this answer here first.

# Golfscript x4 -- No extra symbols -- Using all possible commands

'HHHeeelWWWrrrd'!!! do do 'Hello world!'


I tried to do one that didn't have any extra symbols beyond what was absolutely necessary (though I could have chosen " instead of ' or ")

As a secondary goal I also wanted to put as few characters as possible into a string as possible, so I used the ! operator as such, and I also squeezed in to do operators.

## R, 346 characters, n = 12

cat((((((((((intToUtf8(c(40,69,76,76,79,0,55,79,82,76,68,1)+31+1+0+0+0+0+0+0+0+0++0*11111111[1]*22222222222[1]*33333333333[1]*44444444444[1]*5555555555[1]*6666666[1]*7777777[1]*888888888[1]*999999*9[1]*9[1]*9[1])))))))))),"\"\"\"\"\"\"\"\"\"\"\\aaaaaaaaaaaccccccccccfffffffffffiiiiiiiiiiinnnnnnnnnnnoooooooooootttttttttTTTTTTTTTTTUUUUUUUUUUU"[0])


Characters used in this code:

,"()[]*\+0123456789acfinotTU


# Classic ASP (VBScript; 62 characters)

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


Uses each character exactly 2 times!

Edit: This code is a bit shorter:

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


And so is this:

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


# Befunge 98 - 26 bytes

Since I had to duplicate the r anyway, I figured I may as well make the source text read left-to-right rather than typical gnirts Befunge style. There's nothing particularly notable about this; I'm not sure if having code that simply isn't executed counts as a comment, but the six characters Hel w! are just ignored.

rHel w!@,dk"Hello, world!"


# Turtlèd, n=3, (noncompeting)

N=3, because of "Hello world!" having three ls.

'!' ' HHeeowwrrdd"Hello world!""!


Try it online

## Explanation:

'!                                write exclamation mark
' '                             write space twice on the same cell as exclamation mark
HHeeowwrrdd                 balances chars in Hello world!, moves the pointer
"Hello world!"   Write Hello world! to grid
"! Write the exclamation mark again, on top of the last one