# Hello, World! (Every other character)

Write a program that prints "Hello, World!". But also, if you take only the first, third, fifth, etc. characters of your program, the resulting program should still print "Hello, World!".

abc
def


It should output "Hello, World!", but so should

acdf


No solutions with fewer than 2 characters.

• Can there be whitespace around the output? – vroomfondel Jun 26 '17 at 20:20
• Amazing first post! – Adám Jun 26 '17 at 22:49
• Seeing all the answers with "HHeelllloo" reminded me of speaking Whale. – Brian Minton Jun 27 '17 at 4:19
• Pro tip for avoiding "Hello, World!" built-ins in challenges like this: use a slightly different string of similar complexity like "Greetings, Earthlings!" – Martin Ender Jun 27 '17 at 7:15
• "No solutions with fewer than 2 characters." Amazing. – Rob Grant Jun 28 '17 at 9:10

# Python 3, 61 bytes

rant="partisn't"
print(("HHeelllloo,,  WWoorrlldd!!"""[::2]))


Try it online!

Abusing the fact that print is a function in Python 3 :)

The least partisan solution you'll find here on PPCG.

Becomes

rn=print
rn("Hello, World!"[:])

• This is beautiful. – musicman523 Jun 26 '17 at 22:30
• @musicman523 But, Doesn't REPL surround the text with single-quotes in that case. – officialaimm Jun 27 '17 at 2:38
• @officialaimm Yes, I suppose it does – musicman523 Jun 27 '17 at 3:25
• @yamboy1 Try deleting every other letter – vroomfondel Jun 27 '17 at 3:49
• This is art. This made me cry. – Koishore Roy Jul 20 '17 at 12:47

## Cardinal, 29 bytes

%
"
H
e
l
l
o
,

W
o
r
l
d
!


Try it online!

Removing every other character removes all the linefeeds, which still results in Hello, World!:

%"Hello, World!


Try it online!

The reason this works is that % creates four instruction pointers, moving in each of the four cardinal directions. IPs that leave the source code are simply removed. So in the first case, only the south-going IP remains and in the second case, only the east-going IP remains, all the others are simply dropped. In either case, the executed program is then just "Hello, World!. The " toggles to string mode where each cell is simply printed to STDOUT. We don't need to terminate the string, because leaving the source code still terminates the program.

Note that the same idea works in Beeswax, using * instead of % and  instead of " (this is because Beeswax was largely inspired by Cardinal but uses a hexagonal grid).

Try it online! (vertical) | | Try it online! (horizontal)

# C, 125 bytes

xpxuxtxs( ) { }xuxs ( ) { } main( ) {puts ( "Hello, World!" ) ; } mxaxixn ( ) {xpxuxtxs ( " H e l l o ,   W o r l d ! " ) ; }


Try it online!

With even characters removed:

xxxx(){}us(){}mi(){us("el,Wrd");}main(){puts("Hello, World!");}


Try it online!

# Actually, 2 bytes

HH


Explanation:

H, as you might expect, pushes Hello, World! to the stack.

The main program (HH) will encounter the first H and push Hello, World! to the stack. On the second H, however, it will try to use two arguments (as the stack needs to be empty to push Hello, World!) and fail. However, this error will be ignored and then Hello, World! will be implicitly printed.

The second program (H) will push Hello, World! once, and that will be impliclty printed.

This is similar to Fatalize's 2-byte answer, but this doesn't really "cheat".

Try it online!

• Nice solution, but I think this shouldn't count since it's too much like a one-character solution. – pommicket Jun 26 '17 at 20:54
• @LeoTenenbaum Why not? It conforms to the rules perfectly fine. – Okx Jun 26 '17 at 21:06
• What you explain isn't the case, H would only push Hello, World! on an empty stack, and if the stack isn't empty, it would expect 2 arguments, so there will be an error, and errors are ignored. And no Actually doesn't implicitly print only the topmost element. – Erik the Outgolfer Jun 27 '17 at 7:30
• @EriktheOutgolfer Oops. Will fix. – Okx Jun 27 '17 at 9:37
• This is why Actually is my favorite golfing language. It's at the perfect level of stupid. – RShields Jul 3 '17 at 0:07

# Lua, 89 bytes

--- [ [
print("Hello, World!")
--[[ ] ]
pCrAiLnCtU(L"AHTeOlRlFoE,L IWNoEr:lDd !:"D)
---]]


Try it online! As the syntax highlighting shows, this is massive comment abuse.

Alternate:

--[[pit"el,Wrd"
-[]]print("Hello, World!")--]


Try it online!

And for convenience, a program to convert a program into every other character form: Try it online!

• I like this one! The commenting format of Lua seems similar to T-SQL, I'm going to try and work on one for that language. – BradC Jun 26 '17 at 21:11
• This sort of trick should work for any language with both block comments and line comments (C, JS, etc) – CalculatorFeline Jun 26 '17 at 21:25
• CALCULATORFELINE:D :D – Riking Jun 28 '17 at 1:50
• HHeelllloo WWoorrlldd!! is kinda boring :P – CalculatorFeline Jun 28 '17 at 15:34

# Retina, 39 bytes


HHeelllloo,,  WWoorrlldd!!

(.).x?
$1  Try it online! Taking every other character gives:  Hello, World! ()x 1  Try it online! The first program creates a string with the greeting duplicated. Then it replaces each pair of characters with the first character. There is also an empty stage that replaces all empty strings with empty strings in between, but that doesn't do anything. The second program fails to match the letter "x" so it doesn't replace anything after creating the greeting. Perhaps more amusingly, if the third stage is changed slightly the first set of characters doesn't have to be the same message. This could lead to many identical length solutions such as full and halved. # Charcoal, 25 bytes H→e→l→l→o→,→ →W→o→r→l→d→!  Try it online! If you remove the even characters, you just remove the arrow commands that indicate the direction of the next text, and that leaves the following code: Hello, World!  Try it online! That also prints the greeting. # Haskell, 85 bytes {--}main=putStr"Hello, World!"--} m a i n = p u t S t r " H e l l o , W o r l d ! "  Try it online! Every second character removed: {-mi=uSrHlo ol!-}main=putStr"Hello, World!"  Try it online! This exploits the two comment formats in Haskell: {- -} for in-line or multi-line comments and -- to comment the rest of the line. # Javascript, 67 bytes /**/alertHello, World// * / a l e r t  H e l l o , W o r l d   Every second letter removed: /*aetHlo ol/*/alertHello, World  Just like many other answers, this exploits comments. • Nice answer, +1! Saved 2 bytes by creating a port of your answer in my Java 8 answer, and an additional byte when I changed // * / to //**/ (which unfortunately isn't possible in your case due to /**/alertHello, World  being an odd amount of bytes, instead of even like in my case. – Kevin Cruijssen Jun 27 '17 at 9:54 # Brachylog, 4 bytes Ḥ~wḤ  Try it online! ### Explanation ~w writes its right variable to STDOUT, and ignores its left argument. Ḥ is "Hello, World!", so this prints Hello, World!. If we only take the first and third chars, we get Ḥw. In that case w writes its left variable and ignores its right variable, so it also prints Hello, World!. ### 2 bytes ḤḤ  Try it online! This is technically a valid answer, but this unifies the output variable of the program instead of printing to STDOUT, so I guess the 4 bytes program is more in the spirit of the challenge. • I do not think the 2 byte answer is 'technically' valid, as the challenge states print. – Okx Jun 26 '17 at 21:56 • @Okx print, as in onto a piece of paper? – theonlygusti Jun 27 '17 at 10:39 • @theonlygusti It means print to STDOUT. – Okx Jun 27 '17 at 10:40 • @theonlygusti Sigh... that's what's meant by print by default. – Okx Jun 27 '17 at 10:42 • @Okx you're trying to be pedantic to invalidate a solution, but actually there's nothing invalid about it. The challenge only says "output." – theonlygusti Jun 27 '17 at 10:43 # x86 machine code, 162 bytes PROG.COM Download and run it in MS-DOS emulator, DOSBox for example. 90 B3 B4 B4 02 90 90 B3 B2 B2 48 90 90 B3 CD CD 21 90 90 B3 B2 B2 65 90 90 B3 CD CD 21 90 90 B3 B2 B2 6C 90 90 B3 CD CD 21 90 90 B3 CD CD 21 90 90 B3 B2 B2 6F 90 90 B3 CD CD 21 90 90 B3 B2 B2 2C 90 90 B3 CD CD 21 90 90 B3 B2 B2 20 90 90 B3 CD CD 21 90 90 B3 B2 B2 77 90 90 B3 CD CD 21 90 90 B3 B2 B2 6F 90 90 B3 CD CD 21 90 90 B3 B2 B2 72 90 90 B3 CD CD 21 90 90 B3 B2 B2 6C 90 90 B3 CD CD 21 90 90 B3 B2 B2 64 90 90 B3 CD CD 21 90 90 B3 B2 B2 21 90 90 B3 CD CD 21 90 90 B3 CD CD 20 90  after removal MINI.COM Download 90 B4 02 90 B2 48 90 CD 21 90 B2 65 90 CD 21 90 B2 6C 90 CD 21 90 CD 21 90 B2 6F 90 CD 21 90 B2 2C 90 CD 21 90 B2 20 90 CD 21 90 B2 77 90 CD 21 90 B2 6F 90 CD 21 90 B2 72 90 CD 21 90 B2 6C 90 CD 21 90 B2 64 90 CD 21 90 B2 21 90 CD 21 90 CD 20  ## How to run? Install DOSBox, for Ubuntu/Debian sudo apt install dosbox  Run it dosbox  In DOSBOX mount c /home/user/path/to/your/directory c: PROG.COM MINI.COM  ## How does it works? Machine operation codes represents assembly language instructions. In MS-DOS to print char you will set registers and make interrupt. AH register will be 0x02, DL register contains your char. Interrupt vector is 0x21. mov ah,0x2 ;AH register to 0x2 (B4 02) mov dl,0x48 ;DL register to "H" (B2 48) int 0x21 ;0x21 interrupt (CD 21)  MS-DOS COM file tiny model is good choise, because it doesn't have any headers. It is limited by 64K, but in our case it doesn't matters. To stop program use 0x20 interrupt int 0x20 ;0x20 interrupt (CD 20)  ## Magic If you want to execute 0xAB opcode command with one parameter 0xCD, you write AB CD  In PROG.COM 90 B3 AB AB CD 90 nop ; No operation (90) mov bl,0xb4 ; BL register to AB (B3 AB) AB CD command (AB CD) nop ; No operation (90)  In MINI.COM 90 AB CD nop ; No operation (90) AB CD command (AB CD)  It is equal machine codes, if you don't use BL register. ## Generator Convert text file with hex to hex binary cat hex_file | xxd -r -p > exec.com  function byte2hex(byte){ var ret=byte.toString(16).toUpperCase(); return ret.length==1 ? "0"+ret : ret; } function str2hex(str){ var ret = []; for(var i=0;i<str.length;i++){ ret.push(byte2hex(str.charCodeAt(i))); } return ret; } function genCode(hexArr){ var ret = [["B4","02"]]; for(var i=0;i<hexArr.length;i++){ if(hexArr[i]!=hexArr[i-1]){ ret.push(["B2",hexArr[i]]); } ret.push(["CD","21"]); } ret.push(["CD","20"]); return ret; } function magicCode(str){ var ret=[""]; var code=genCode(str2hex(str)); for(var i=0;i<code.length;i++){ ret.push("90 B3 "+code[i][0]+" "+code[i][0]+" "+code[i][1]+" 90"); if(i%4==3){ret.push("\n");} } return ret.join(" "); } function magicCodeMinified(str){ var ret=[""]; var code=genCode(str2hex(str)); for(var i=0;i<code.length;i++){ ret.push("90 "+code[i][0]+" "+code[i][1]); if(i%8==7){ret.push("\n");} } return ret.join(" "); } var str=prompt("string","Hello, world!"); var out="PROG.COM\n" + magicCode(str)+"\n\nMINI.COM\n"+magicCodeMinified(str); document.write(out.replace("\n","<br>")); alert(out); • Remove all  90 90 for -52 bytes. – NieDzejkob Dec 22 '18 at 19:37 • Also the nop at the very end will never be reached. – NieDzejkob Dec 22 '18 at 20:00 # Haskell, 102 bytes The full program: main= putStr"Hello, World!";; putSt x ="p u t S t r \" H e l l o , W o r l d !\""; mmaaiin = main  and with every other character removed: mi=ptt"el,Wrd";ptt x=putStr "Hello, World!";main=mi  • You can take off 2 bytes by removing the spaces between p u t S t r and \". – Wheat Wizard Feb 16 '18 at 19:54 # Pyth, 31 bytes p% 2"HHeelllloo,, WWoorrlldd!!  Try it online! Becomes p "Hello, World!  Thanks to @CalculatorFeline for pointing out an error and removing one byte. • Characters kept start from the first, not the second. You can drop the leading space. – CalculatorFeline Jun 26 '17 at 20:54 • Ah, thanks @CalculatorFeline. I read "Take" as "Remove" in the spec. – vroomfondel Jun 26 '17 at 20:55 # V, 32 bytes i;H;e;l;l;o;,; ;w;o;r;l;d;!;<esc>;Ó;  Note that <esc> is a single character, e.g. 0x1b Try it online! Removing every other character gives: iHello, world!<esc>Ó  Try it online! # PHP, 53 bytes # echo date($e_c_h_o='\H\e\l\l\o\,\ \W\o\r\l\d\!
');


With every other character removed:

#eh ae
echo'Hello, World!';


# Mathematica, 62 bytes

P0r0i0n0t0@0"0H0e0l0l0o0,0 0W0o0r0l0d0!0"Print@"Hello, World!"


It returns "0H0e0l0l0o0,0 0W0o0r0l0d0!0" Null P0r0i0n0t0[0], and prints Hello, World! as a side effect. When run as a program (not in the REPL), the return value will not be printed.

After removing every other character:

Print@"Hello, World!"rn@Hlo ol!


It returns Null ol! rn[Hlo], and prints Hello, World!.

# Jelly, 26 25 bytes

““3ḅaė;œ»ḷ“ 3 ḅ a ė ; œ »


Try it online!

After removing every second character, we're left with the following code.

“3a;»“3ḅaė;œ»


Try it online!

### How it works

““3ḅaė;œ»ḷ“ 3 ḅ a ė ; œ »  Main link.

““3ḅaė;œ»                  Index into Jelly's dictionary to yield
["", "Hello, World!"].
“ 3 ḅ a ė ; œ »  Index into Jelly's dictionary to yield.
ḷ                 Take the left result.

“3a;»“3ḅaė;œ»  Main link.

“3a;»          Index into Jelly's dicrionary to yield " N-".
Set the argument and the return value to the result.
“3ḅaė;œ»  Index into Jelly's dicrionary to yield "Hello, World!".
Set the return value to the result.


# Cubicallyv2.1, 222 bytes

+0503 @@6 :22 //1 +050501 @@6 :55 +0502 @@6@6 :33 //1 +050502 @@6 :55 +03 //1 +04 @@6 :55 //1 +03 @@6 :55 +01 //1 +0504 @@6 :33 //1 +050502 @@6 :55 +01 //1 +050502 @@6 :55 +0502 @@6 :11 //1 +050501 @@6 :55 +01 //1 +03 @@6


Try it online!

Every other letter:

+53@6:2/1+551@6:5+52@66:3/1+552@6:5+3/1+4@6:5/1+3@6:5+1/1+54@6:3/1+552@6:5+1/1+552@6:5+52@6:1/1+551@6:5+1/1+3@6


Try it online!

# Befunge-93, 43 41 bytes

Coming back to this a few years later, I found a way to avoid running those unsupported instructions, meaning this can even be run on implementations that treat those differently.

"!!ddllrrooWW  ,,oolllleeHH"""> :\$# ,#__@


Try it online!

Second version

"!dlroW ,olleH">:#,_@


is the shortest possible "Hello World!". This therefore is the shortest possible answer to this question for Befunge-93.

Try It Online

• That's brilliant! Much better than my Befunge answer. Can't believe you haven't got any votes for this. – James Holderness Dec 20 '17 at 0:06

# 05AB1E, 29 bytes

”ïŸŸ™ ,ï‚‚ï ! ”# ¦2 ä ø¨øJð ý


Try it online!

Explanation

”ïŸŸ™ ,ï‚‚ï ! ”                # push the string "Weekly Hello , Changed World ! "
#               # split on spaces
# RESULT: ['Weekly','Hello',',','Changed','World','!','']
¦              # remove the first element (Weekly)
2ä            # split in 2 parts
# RESULT: [['Hello', ',', 'Changed'], ['World', '!', '']]
ø           # zip
# RESULT: [['Hello', 'World'], [',', '!'], ['Changed', '']]
¨          # remove the last element
ø         # zip
# RESULT: [['Hello', ','], ['World', '!']]
J        # join each inner list
ðý      # join on space


After removing every other character we are left with the code

”Ÿ™,‚ï!” 2äøøðý


Try it online!

Explanation

”Ÿ™,‚ï!”       # push the string "Hello, World!"
2ä     # split in 2 parts
# RESULT: ['Hello, ', 'World!']
ø    # zip, as the string has an odd length the space is lost
# RESULT: ['HW', 'eo', 'lr', 'll', 'od', ',!']
ø   # zip again
# RESULT: ['Hello,', 'World!']
ðý # join on space


# CJam, 32 bytes

"HHeelllloo,,  WWoorrlldd!! "2 %


Try it online!

Taking every other character gives:

"Hello, World!"


Try it online!

• Note the trailing space on the alternated version. – CalculatorFeline Jun 26 '17 at 20:59

# Help, WarDoq!, 2 bytes

Hi


Try it online!

H prints Hello, World!, i is a no-op.

Help, WarDoq! can add two numbers and test for primes, so it is considered as a valid programming language per this meta post.

• why was this downvoted? – Uriel Jul 1 '17 at 22:33
• NOP and massive spaces are against the spirit. – RShields Jul 3 '17 at 0:09
• +1 because of the novelty on how the resulting source code re-emphasizes the message that gets output. – TOOGAM Jul 4 '17 at 9:53

# ///, 25 bytes

H\e\l\l\o\,\ \W\o\r\l\d\!


Try it online!

With every other character removed:

Hello, World!


# Octave, 49 45 bytes

Saved 4 bytes since Octave doesn't require brackets to do indexing.

'HHeelllloo,,  WWoorrlldd!! ' (1:2 : 3 ^ 3)''


Try it online!

And the reduced one:

'Hello, World!'(:    )'


Try it online!

## Explanation:

The initial code has the letters in the string duplicated, so that we're left with Hello, World! when every second is removed. Some spaces are added to ensure the brackets and apostrophes are kept.

The indexing is really 1:2:end. There are 27 characters, and we can't use end or 27 since we must remove a character, so we go with 3 ^ 3 instead. When we remove every third character, the indexing becomes (:) (and some additional spaces).

(:) means "flatten and turn into a vertical vector". So, we need to transpose it, using '. We don't need to transpose the string in the original code, but double transposing works, so the first string is transposed twice using '', and the second is transposed just once.

# APL (Dyalog), 35 34 bytes

-1 thanks to Martin Ender.

'0H0e0l0l0o0,0 0W0o0r0l0d0!0'~ ⍕ 0


Try it online!

'0H0e0l0l0o0,0 0W0o0r0l0d0!0' the message with zeros as removable filler characters

~ except

⍕ formatted (stringified)

0 number zero

Leaving just the odd characters, this becomes 'Hello, World!' .

# T-SQL, 75 bytes

---
PRINT 'Hello, World!'
/*
-P-R-I-N-T-'-H-e-l-l-o-,- -W-o-r-l-d-!-'
---*/


Single- and multi-line comment abuse, inspired by CalculatorFeline's LUA version.

After removal of all even-numbered characters, some of which are line breaks:

--PIT'el,Wrd'/
PRINT'Hello, World!'--/


# Javascript, 73 bytes

a ='a0l0e0r0t00H0e0l0l0o0,0 0W0o0r0l0d0!00/0/';eval(a.replace(/0/g,''))


Constructs a string a with the content a0l0e0r0t00H0e0l0l0o0,0 0W0o0r0l0d0!00/0/, then removes all 0's to give alertHello, World!//, which is eval'd.

Taking every other character of the program gives

a=alertHello, World!//;vlarpae//,')


which alerts Hello, World using template string syntax the same way as what was eval'd in the full program, then stores the result of the call in a and includes the insightful comment //;vlarpae//,').

## ><>, 47 bytes

Original:

| v~" H e l l o ,   W o r l d ! "

~o<< ;!!!? l


With every second character removed:

|v"Hello, World!"
o<;!?l


Try them online: original, modified

The original program pushes the characters of "Hello, World!" to the stack (in reverse order) interspersed with spaces, then alternately prints a character and deletes one until the length of the stack is zero. The second program does the same, except the deletion instructions ~ are gone.

If you don't mind halting with an error, we can take a leaf out of Martin Ender's Cardinal book: the modified code is

\"!dlroW ,olleH"!#o#


and the original is the same but with newlines inserted between all the characters, for 39 bytes. Try them online: original, modified.

My naive solution

# C/C++, 111 105 byes 97 bytes

(6 bytes saved using "puts", inspired by Hawkings)

///
f(){puts("Hello, World!");}
#define x\
_f_(_)_{_p_u_t_s_(_"_H_e_l_l_o_,_ _W_o_r_l_d_!_"_)_;_}


After takeaway

//f)pt(Hlo ol!)}#eiex
f(){puts("Hello, World!");}


# ,,,, 34 bytes

 2"Hteoltlaol,l yWhourmladn!! "⟛


On removing the even numbered characters...

 "Hello, World!"


## Explanation

With all the characters:

 2"..."⟛

no-op
2             push 2 to the stack
"..."        push "Hteoltlaol,l yWhourmladn!! " to the stack
⟛      pop 2 and the string and push every 2nd character of the string
implicit output


Without the even numbered characters:

 "..."

no-op
"..."         push "Hello, World!" to the stack
implicit output

• This implies you don't need to say this is non-competing. – FryAmTheEggman Jun 26 '17 at 20:54
• But you're supposed to keep all of the even-indexed characters... (0-indexed)... – HyperNeutrino Jun 26 '17 at 21:06
• Whoops, fixed. Just add another character lol. – totallyhuman Jun 26 '17 at 21:15