"Hello world!", repeating each character n times

15

4

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
  • It's highly discouraged to use comments to accomplish your goal.

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

Undo

Posted 2014-01-21T17:24:07.360

Reputation: 413

Question was closed 2016-09-30T17:03:17.567

Let's steal every answers from this topic: http://codegolf.stackexchange.com/questions/18925/hello-world-with-no-repetition with n=1

– Fabinout – 2014-01-21T17:33:15.940

Oops, let's say that n>=2, @Fabinout – Undo – 2014-01-21T17:33:51.160

Space counts as a character? – 3ventic – 2014-01-21T17:49:24.577

@3ventic Yes, it does. – Undo – 2014-01-21T17:53:44.210

1here's a JSFiddle I threw together for testing if anyone needs it – Doorknob – 2014-01-21T22:22:53.413

2I'd love to see a HQ9+ solution for this. – Nzall – 2014-01-22T08:38:34.543

1@Nate HQ9+ outputs a comma (as noted in a deleted answer). ;-) – Doorknob – 2014-01-22T13:31:13.680

Answers

25

Brainfuck

n=57. 45 newlines removed thanks to ratchet freak

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

A more readable version:

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

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

user12205

Posted 2014-01-21T17:24:07.360

Reputation: 8 752

couldn't you put the . inside one of the [] and not output the newlines – ratchet freak – 2014-01-21T20:21:13.527

@ratchet freak Good point. Thanks. – user12205 – 2014-01-21T21:14:20.267

I think ratchet was suggesting moving the [ in the first [] to before the dots, so that it wouldn't output even NULLs. – Ilmari Karonen – 2014-01-22T11:34:56.307

@Ilmari Karonen Oh right, I see. Thanks. – user12205 – 2014-01-22T13:24:40.767

12

JavaScript

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

This seemed a little too easy.

Kendall Frey

Posted 2014-01-21T17:24:07.360

Reputation: 2 384

12

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

Doorknob

Posted 2014-01-21T17:24:07.360

Reputation: 68 138

11

C, 54

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

FireFly

Posted 2014-01-21T17:24:07.360

Reputation: 7 107

1You have a v that doesn't match – Eduard Florinescu – 2014-01-21T22:15:28.243

@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 – 2014-01-21T22:28:46.870

5

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

Plarsen

Posted 2014-01-21T17:24:07.360

Reputation: 1 740

Much better without comments! – Undo – 2014-01-21T17:46:34.807

4

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.

Justin

Posted 2014-01-21T17:24:07.360

Reputation: 19 757

3

Windows Command Script - 33 bytes

3 of everything:

ecHo Hello world!% eHccwwrrdd!!%%

Robert Sørlie

Posted 2014-01-21T17:24:07.360

Reputation: 1 036

3

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.

unclemeat

Posted 2014-01-21T17:24:07.360

Reputation: 2 302

I spy 4 spaces :( – eithed – 2014-01-22T00:18:52.943

3

Ruby - 40 Chars (n=2)

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

Siva

Posted 2014-01-21T17:24:07.360

Reputation: 241

How many spaces do you have? Is it correct to say that the first two around p are tabs (or something similar)? – Justin – 2014-01-22T04:41:26.470

@Quincunx First space was a typo.Now edited – Siva – 2014-01-22T04:45:20.527

3

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.

primo

Posted 2014-01-21T17:24:07.360

Reputation: 30 891

2

PHP

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

Shorter version (42 char):

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

Online page with that source

3ventic

Posted 2014-01-21T17:24:07.360

Reputation: 121

I think you can:

  • not end with ?> (which will eliminate the use of >)
  • treat Hepwintd<! as string - 'Hepwintd<!' which will take care of $
  • < – eithed – 2014-01-21T19:16:02.523

2

Jelly, 16 bytes (non-competing)

“⁸ƒẹI4»
“⁸ƒẹI4»

(+trailing newline)

Try it online! (n = 2)

NO COMMENTS AT ALL. I assure you. Just Link 1 and the Main Link.

Erik the Outgolfer

Posted 2014-01-21T17:24:07.360

Reputation: 38 134

And yes I know this is not [tag:code-golf]. – Erik the Outgolfer – 2016-09-29T18:23:52.230

Hmm... so this answer paved the road to close for this challenge. Nice. – Erik the Outgolfer – 2016-10-01T12:41:45.607

1

Golfscript, 42

."Hello world!"'\\\'"  HHeeowwrrdd!!'..;;;

Test online

ProgramFOX

Posted 2014-01-21T17:24:07.360

Reputation: 8 017

1

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

eithed

Posted 2014-01-21T17:24:07.360

Reputation: 1 229

2r appears 3 times while w only appears once. (in both versions) Just replace the final r with w to fix it – Doorknob – 2014-01-21T22:19:19.690

Oh, dyslexia, you cruel mistress... Thanks! – eithed – 2014-01-22T00:07:53.520

1

Python:

With 3 characters each.

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

nddwt is a rhino!

Eduard Florinescu

Posted 2014-01-21T17:24:07.360

Reputation: 1 863

1

Perl (51 bytes)

print'Hello world!'; ppriinnttHHeeowwdd; "'\"\\!!";

Konrad Borowski

Posted 2014-01-21T17:24:07.360

Reputation: 11 185

Old post and probably doesn't matter too much, but you can save a few bytes using $' or $" inside a q!! block instead of the \\s. – Dom Hastings – 2016-09-30T11:53:05.173

1

C, 75 56 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.

Kevin

Posted 2014-01-21T17:24:07.360

Reputation: 501

In the first i is kind of lonely! :) – Eduard Florinescu – 2014-01-21T22:20:30.187

Your first two have only one i (easy to fix: change the main argument name). Your last only has one space – Doorknob – 2014-01-21T22:20:43.340

1@EduardFlorinescu Lol, I posted that exactly at the same time as you :P – Doorknob – 2014-01-21T22:21:11.170

Oops, the first was missing. The second had it, just out of place. – Kevin – 2014-01-21T22:26:45.213

1

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!")

WallyWest

Posted 2014-01-21T17:24:07.360

Reputation: 6 949

1

Python 2, 38

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

Armin Rigo

Posted 2014-01-21T17:24:07.360

Reputation: 181

1

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

user15247

Posted 2014-01-21T17:24:07.360

Reputation:

1

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.

Toothbrush

Posted 2014-01-21T17:24:07.360

Reputation: 3 197

1

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.

McKay

Posted 2014-01-21T17:24:07.360

Reputation: 382

1

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

Sven Hohenstein

Posted 2014-01-21T17:24:07.360

Reputation: 2 464

1

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!

Toothbrush

Posted 2014-01-21T17:24:07.360

Reputation: 3 197

1

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

Hactar

Posted 2014-01-21T17:24:07.360

Reputation: 646

0

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

Destructible Lemon

Posted 2014-01-21T17:24:07.360

Reputation: 5 908