Your task is to write a program that outputs the exact string Programming Puzzles (trailing newline optional), but when all spaces, tabs, and newlines are removed it outputs Code Golf (trailing newline optional.)

Your byte count is the count of the first program, with spaces still there.


  • The spaces in Code Golf and Programming Puzzles will be removed as part of the removal, so plan accordingly.

  • In encodings where 0x09, 0x0A and 0x20 aren't tabs, newlines or spaces respectively, those chars will be removed.

  • If your code is

    42  $@ rw$

    then that must output Programming Puzzles. Also, in the same language,


    must output Code Golf.

This is , so the shortest code in bytes wins! Good luck!

  • 3
    will the space in Code Golf also be removed, what about the one in Programming Puzzles. – colsw Apr 28 '17 at 13:20
  • 2
    This will be impossible in at least Whirl and Whitespace. – Engineer Toast Apr 28 '17 at 17:14
  • 13
    What are the close votes for? – OldBunny2800 Apr 28 '17 at 21:16
  • 12
    @OldBunny2800 good question. I keep asking that but the comment gets removed... – programmer5000 Apr 28 '17 at 21:19
  • 12
    The close votes are for the lack of inputs and outputs and restriction on the formatting of inputs and outputs. 100% if you had a section labeled "rules" with a bullet-pointed list of things you think were obvious about the challenge you'd have 0 close votes. It's all about presentation with CompSci folks, if we can think of a seemingly idiotic question to ask that may save us a byte or to, we will, try to counter that idiocy and you will be a great question writer. – Magic Octopus Urn Apr 28 '17 at 22:00

45 Answers 45

Python 2, 50 bytes

print["Code\40Golf","Programming Puzzles"][" ">""]

Try it online!

With all spaces removed:


Try that online!

Thanks to Stephen S for 3 bytes, and Erik the Outgolfer for 1

  • 2
    Darn, ninja'd! I was just about to click Post Answer! +1 – HyperNeutrino Apr 28 '17 at 13:22
  • 1
    I think you just broke my friend's brain. How does this even work? – Steven M. Vascellaro Apr 28 '17 at 15:09
  • 10
    @StevenVascellaro It's really simple. In the first case, " ">"" returns True, since, lexicographically, a space is greater than the empty string. In the second case, "">"" returns False, since nothing can be greater than itself. True and False are actually just 1 and 0 respectively, just in the bool datatype instead of int or long. In the first case, the spaces are preserved, so, the item at index 1, "Programming Puzzles", is returned verbatim. In the second case, the spaces are gone, hence the \x20 in the item at index 0 "Code\x20Golf" to preserve a space. – Erik the Outgolfer Apr 28 '17 at 15:26
  • 9
    @StephenS Nope, because unlike JavaScript, Python doesn't have an obsession with implicit casting. – Mego Apr 28 '17 at 15:57
  • 1
    If find Python's lack of obsession disturbing. – John Dvorak Apr 28 '17 at 19:56

Python 2, 48 47 bytes

-1 byte thanks to Erik the Outgolfer

print' 'and'Programming Puzzles'or'Code\40Golf'

Try it online!


Try it online!

  • 9
    Aww, I was just about to improve my answer to this... – Mego Apr 28 '17 at 13:29

C, 64 62 53 52 bytes

f(){puts(*" "?"Programming Puzzles":"Code\40Golf");}

Try it Online!

Uses the fact that C strings end with a null character

05AB1E, 15 bytes

”ƒËŠˆ”" "v”–±ÇÀ

Try it online!


”ƒËŠˆ”           # push "Code Golf"
      " "v       # for each character in the string " " do
          ”–±ÇÀ  # push "Programming Puzzles"
                 # implicitly output top of stack
  • ...I just don't get it. Does this use dictionary compression or something? – LegionMammal978 Apr 30 '17 at 2:15
  • @LegionMammal978 I'm pretty sure it does. – NoOneIsHere Apr 30 '17 at 3:15
  • @LegionMammal978: It does indeed use dictionary compression. – Emigna Apr 30 '17 at 8:59
  • 5
    @Emigna Okay, because last I checked, neither of those strings could be fit into 4 bytes :p – LegionMammal978 Apr 30 '17 at 10:27
  • To my knowledge some of those characters can be saved using one byte, assuming well known encodings. in UTF-8 I get 31 bytes... Am I wrong? – steffen May 4 '17 at 20:00

CJam, 38 bytes

" ""Programming Puzzles""Dpef!Hpmg":(?

Try it online! or with spaces removed


" "                    e# Push this string.
"Programming Puzzles"  e# Push "Programming Puzzles".
"Dpef!Hpmg":(          e# Push "Dpef!Hpmg" and decrement each char, giving "Code Golf".
?                      e# If the first string is true (non-empty) return the second string,
                       e#   else return the third.

Whether spaces are in the program or not determines if the first string is truthy or falsy.

  • 27
    Your code is sad :( – Roman Gräf Apr 28 '17 at 13:51
  • 14
    If you're willing to use unprintables, "Bncd\x19Fnke":) is happy code instead (replace \x19). – Erik the Outgolfer Apr 28 '17 at 15:58

Jelly, 18 bytes


Try it online!


In the program as written, the first line is a helper function that's never run. The second line (the last in the program) is the main program, and is the compressed representation of the string "Programming Puzzles" (which is then printed implicitly).

If you remove the newline, the whole thing becomes one large program. “½ċṭ6Ỵ» is the compressed representation of the string "Code Golf". evaluates but ignores its right hand argument, leaving the same value as before it ran; it can be used to evaluate functions for their side effects (something I've done before now), but it can also be used, as here, to effectively comment out code.

Interestingly, the actual logic here is shorter than the 05AB1E entry, but the code as a whole comes out longer because the string compressor is less good at compressing these particular strings.

  • This turns out to be valid. – Erik the Outgolfer Apr 28 '17 at 15:34
  • To my knowledge some of those characters can be saved using one byte, assuming well known encodings. in UTF-8 I get 36 bytes... Am I wrong? – steffen May 4 '17 at 19:59
  • @steffen: Jelly uses its own character encoding, in which all of the 256 different characters it uses can be stored in a single byte. (The only reason it does this rather than using a pre-existing encoding is for readability (!); you could trivially write the program encoded in, say, codepage 437, and it would run in the Jelly interpreter, but it would typically be much harder to read.) – user62131 May 4 '17 at 21:12

Javascript, 46 43 42 Bytes

x=>" "?"Programming Puzzles":"Code\40Golf"

console.log((x=>" "?"Programming Puzzles":"Code\40Golf")())

  • 5
    You can replace the \x20 in the first string with a space. – Shaggy Apr 28 '17 at 13:30
  • Beat me to it, nicely done. Does this need a trailing ;? – ricdesi Apr 28 '17 at 15:22
  • @ricdesi no, it dosen't. – user68614 Apr 28 '17 at 15:31
  • 3
    @ricdesi since this is codegolf, if the program runs, it works. ;s are sometimes not required in JavaScript. – Stephen Apr 28 '17 at 15:52
  • 2
    You can replace \x20 with \40 to save a byte :-) – ETHproductions Apr 28 '17 at 18:32

Jelly, 17 bytes

“Ñ1ɦ+£)G“½ċṭ6 Ỵ»Ṃ

Try it online!

How it works

As in the other Jelly answer, Ñ1ɦ+£)G and ½ċṭ6Ỵ encode the strings Programming Puzzles and Code Golf. begins a string literal and separates one string form another, while » selects the kind of literal (dictionary-based compression), so this yields

["Programming Puzzles", "Code Golf"]

then takes the minimum, yielding Code Golf.

However, by adding a space between ½ċṭ6 and , we get a completely different second string, and the literal evaluates to

["Programming Puzzles", "caird coinheringaahing"]

Since caird coinheringaahing is lexicographically larger than Programming Puzzles, selects the first string instead.

  • Just did the same with “½ċṭ6Ỵ“Ñ1ɦ +£)G»Ṁ – Jonathan Allan Apr 29 '17 at 8:00
  • To my knowledge neither of those characters can be saved using one byte, assuming well known encodings. in UTF-8 I get 34 bytes... Am I wrong? – steffen May 4 '17 at 19:55
  • @steffen Jelly uses a custom code page that encodes each of the 256 characters it understands as a single byte. – Dennis May 4 '17 at 21:48
  • @Dennis thank you for clarifying. – steffen May 5 '17 at 9:30

Wolfram language, 62 bytes

"Programming Puzzles"[ToExpression@"\"Code\\.20Golf\""][[0 1]]

The space in [[0 1]] is implicit multiplication, so this is equivalent to [[0]]. Without a space, 01 is just 1. The 0th and 1st parts of this expression are the strings we want.

Another solution of questionable validity (44 bytes, 2 saved by Kelly Lowder):

"Programming Puzzles"["Code\.20Golf"][[0 1]]

The \.20 gets replaced by a space immediately when typed into a Mathematica environment, so it's not clear if it gets removed along with the other spaces…

  • 1
    As soon as you paste (or type) this into Mathematica, (cloud based or not) the escape sequence, \:0020 turns into a space, and thus would be removed, so I'm not sure this qualifies. Also \.20 is two characters. "Programming Puzzles"["Code"<>FromCharacterCode@32<>"Golf"][[01]] will work. – Kelly Lowder Apr 28 '17 at 20:12
  • 1
    @KellyLowder, hmm, that's a good point. I've added another solution that should avoid that issue. (Thanks for the \.20 suggestion — how did you find that? I thought I'd scoured the whole documentation…) – Not a tree Apr 28 '17 at 22:56
  • 1
    I found the \.20 by making a typo. Seems to only work for two-digit character codes. I don't think it's in the documentation. – Kelly Lowder May 1 '17 at 13:48

Excel - 56 Bytes

=IF(""=" ","Code"&CHAR(32)&"Golf","Programming Puzzles")

Very similar to most of the other answers... nothing fancy here.

Ohm, 33 32 bytes

Uses CP437 encoding.


Try it online! or try without whitespace


With whitespace:

▀Bn¬i≈╣Ü╝Rb╡°╧S½uÇ▀    Main wire

▀Bn¬i≈╣Ü╝Rb╡°╧S½uÇ▀    Push "Programming Puzzles" (compressed string)
                       Implicitly output the top stack element

▀4>~H├MS░l╬δ           Helper wire (never called)

Without whitespace:

▀Bn¬i≈╣Ü╝Rb╡°╧S½uÇ▀▀4>~H├MS░l╬δ    Main wire

▀Bn¬i≈╣Ü╝Rb╡°╧S½uÇ▀                Push "Programming Puzzles" (compressed string)
                   ▀4>~H├MS░l╬δ    Push "Code Golf" (compressed string)
                                   Implicitly output top stack element
  • I'm so glad I finally finished string compression! – Nick Clifford May 2 '17 at 20:01
  • 1
    @NickClifford The curious thing I noticed was that Code Golf got longer when compressed. I guess that's because of the capitals? Either way it's still shorter than writing it normally because I can't use a literal space here. – Business Cat May 2 '17 at 20:05
  • Yeah, Smaz is kind of weird like that. – Nick Clifford May 2 '17 at 20:07
  • FYI, feel free to ping me in chat if you have any questions or feature requests for Ohm. – Nick Clifford May 2 '17 at 20:18

Haskell, 48 bytes

a _="Programming Puzzles";a4="Code\32Golf";f=a 4

Defines function f which returns the corresponding string.

For reference, the old version is:

Haskell, 49/47 bytes

f""="Code\32Golf";f(_)="Programming Puzzles";f" "

with spaces removed


Two simple pattern matches. (_) matches all patterns. You can improve the without-spaces version by one byte by defining the second pattern as f" "=/f""=, but this gives a "Pattern match is redundant" warning.

Alternative solution with the same byte count:

last$"Code\32Golf":["Programming Puzzles"|" ">""]

Japt, 29 bytes

With spaces:

`Co¸{S}Golf`r `PžgŸmÚÁ Puzz¤s

Try it online!

Without spaces:


Try it online!

This takes advantage of the fact that in Japt, a space closes a method call. With spaces, the code is roughly equivalent to this JavaScript code:

("Code"+(S)+"Golf").r(),"Programming Puzzles"

This is evaluated as JavaScript, and the result is sent to STDOUT. Since the last expression is "Programming Puzzles", that string is printed.

Without spaces, the code is roughly equivalent to:


(If you haven't figured it out by now, the S variable is a single space.) The .r() method on a string, if given one argument, removes all instances of that argument from the string. Since "Code Golf" does not contain "ProgrammingPuzzles", it returns "Code Golf" unchanged, which is then sent to STDOUT.

  • I didn't even think of using replace. Nice one! – Tom Apr 28 '17 at 14:39
  • To my knowledge some of those characters can be saved using one byte, assuming well known encodings. in UTF-8 I get 36 bytes... Am I wrong? – steffen May 4 '17 at 19:57
  • @steffen Japt uses the ISO-8859-1 encoding, in which each char represents one byte. But some of the chars would be unprintable in this program, so I used the Windows-1252 encoding here (actually, it was autogenerated by TIO) – ETHproductions May 4 '17 at 20:00

Brachylog, 44 bytes

" "Ṣ∧"Programming Puzzles"w|"Code"wṢw"Golf"w

Try it online!


" "Ṣ                                           If " " = Ṣ (which is itself " ")
    ∧"Programming Puzzles"w                    Write "Programming Puzzles"
                           |                   Else
                            "Code"w            Write "Code"
                                   Ṣw          Write " "
                                     "Golf"w   Write "Golf"
  • 1
    Crossed out 44 is still 44 :( Edit in &nbsp; on either side to fix :) – HyperNeutrino Apr 28 '17 at 13:41
  • @HyperNeutrino It's not crossed out, 44 is the length with spaces, and 42 without. – Fatalize Apr 28 '17 at 13:41
  • Oh. Whoops. Well, it's too similar so I couldn't tell without looking at the markdown by going into edit. Never mind :P – HyperNeutrino Apr 28 '17 at 13:42

Alice, 44 bytes

 /"selzzuP gnimmargorP"d&o@

Try it online!

Without whitespace:


Try it online!


In the first program, the two mirrors / redirect the instruction pointer onto the second line. "selzzuP gnimmargorP" pushes the required code points in revere order, d pushes the stack depth and &o prints that many bytes. @ terminates the program.

Without the whitespace, the program is all on a single line. In that case, the instruction pointer can't move in Ordinal mode, so the / effectively become no-ops (technically, the IP simply doesn't move for one step, the same / gets executed again, and the IP reflects back to Cardinal mode). So if we drop those from the program, it looks like this:


To include the space in Code Golf, we use an exclamation mark instead and decrement it with t. After we've got all the code points on the stack, # skips the next command, which is the entire second string. d&o then prints the stack again, and @ terminates the program.

PHP, 44 Bytes

ternary operator

<?=" "?"Programming Puzzles":"Code\x20Golf";

PHP, 51 Bytes


<?=/** /"Code\x20Golf"/*/"Programming Puzzles"/**/;

PHP, 57 Bytes

array switch

<?=["Code\x20Golf","Programming Puzzles"][(ord("

Pyth, 37 bytes

?" ""Programming Puzzles""Code\40Golf

Try it here.


Try it here.

C# 88 81 70 63 bytes

Func<string>@a=()=>" "==""?"Code\x20Golf":"Programming Puzzles";

With whitespace stripped:


Thanks to BrianJ for showing me how to have no space between a method return type and the method name, PeterTaylor for saving 7 18 bytes, and Patrick Huizinga for saving 7 bytes.

Same method as everyone else really, technically this could be considered invalid because the method doesn't specify a return type for the method, but there has to be whitespace between the return type and the method name.

  • 1
    you can prefix the function name with an @, so then you have void@a... and avoid the "no return type" compilation error (also adds bytes, though :( ) – Brian J Apr 28 '17 at 15:36
  • .Length<1 saves one byte; \u0020 saves six if I've counted correctly; and you can make a valid answer (and save a few bytes at the same time) by submitting a lambda instead of a top level function. Func<string>a=()=>... – Peter Taylor Apr 28 '17 at 15:37
  • @BrianJ Hmm, didn't know that, wonder why that works from a compiler view-point. Anyway, it may lose bytes but it also technically makes this answer not non-competing, so it's worth it. Thanks! – Skidsdev Apr 28 '17 at 15:38
  • @Mayube the @ is primarily used if you need to use a reserved word as a variable name (the equivalent is surrounding with [] in VB.NET (and MS SQL Server)). – Brian J Apr 28 '17 at 15:41
  • 1
    Yes, it requires returning the string; but if you use => instead of return you don't need any spaces. (And even if you use return, you can return(...)). – Peter Taylor Apr 28 '17 at 15:47

Common Lisp (SBCL), 52 bytes

(format`,t"~[Programming Puzzles~;Code~@TGolf~]"0 1)

Prints Programming Puzzles


Prints Code Golf


(format t "~[Programming Puzzles~;Code Golf~]" 0 1)


The trick basically comes from how #'format works in Common Lisp.

In CL, most whitespace can be omitted provided that there is no ambiguity about where tokens start or end. The first trick was separating the format and t symbols. I had to unambiguously end the format symbol without changing how t was interpreted. Luckily, ` in CL ends the preceding token before it gets processed, and , cancels the effect of ` (` is used to implement templating, where the next expression following it gets "quoted", but any sub-expression prefixed with a , is evaluated and the result included in the template, so `, is nearly a no-op).

The third argument to format is the template string. format is similar to printf in C, but has much more powerful formatting directives and use ~ to indicate them instead of %. ~[ and ~] allow you to select between multiple options for printing, with ~; separating them. An additional argument is supplied to format- the numeric index of which one you want printed. In order to ensure that the " " in Code Golf survives, I used the tabulation directive ~T, which is used to insert whitespace, generally to align text into columns. ~@T is a variation which just inserts a given number of spaces, defaulting to 1.

Finally, there are two arguments to format- 0 and 1. Before whitespace is removed, the 0 is used by ~[~;~] to select "Programming Puzzles" and the extra format argument (the 1) is dropped (I'm not sure how standard dropping extra format arguments is, but this works on Steel Bank Common Lisp). After whitespace is removed, there is only one argument (01) which selects "Code Golf" instead.

  • 1
    +1, just one thing: "but any sub-expression prefixed with a , is evaluated and spliced in" Isn't ,@ necessary for splicing? – PrzemysławP May 3 '17 at 15:46
  • "spliced" is a poor term for that, admittedly. Technically, , evals the next expression and includes the result in the template, while ,@ assumes the expression will eval to a list and includes that list's contents in the template directly. Traditionally in the lisp community, ,@ is called "splicing", but I'm not sure that's the most obvious choice. I'll try to reword it a bit. – djeis May 3 '17 at 17:04

Java 8, 74 50 48 bytes

()=>" "==""?"Code\040Golf":"Programming Puzzles"
  • @NonlinearFruit you're right, I've changed that one to be non-competent – Khaled.K May 1 '17 at 18:50
  • 1
    I don't think printing is a requirement, so you could just return the string. I haven't tested it but the == operator should also work, ()=>""==""?"Code\u00A0Golf":"Programming Puzzles" – NonlinearFruit May 1 '17 at 19:59
  • 1
    \u00A0 -> \040 for a 2 byte savings. – Poke May 3 '17 at 18:47

Japt, 32 bytes

" "?`PžgŸmÚÁ Puzz¤s`:`Co¸{S}Golf

Try it online!

PowerShell, 56 bytes

('Programming Puzzles',('Code'+[char]32+'Golf'))[!(' ')]

Try it online!

Pretty basic I would say, but it gets the job done

JavaScript (ES6), 45/43 44/42 bytes

Just another option, inspired by Mego's original answer

_=>" "&&"Programming Puzzles"||"Code\40Golf"

Try it

f=_=>" "&&"Programming Puzzles"||"Code\40Golf"


My original implementation, which I felt was too close to Mego's, came in at 48/46 47/45 bytes:

_=>["Programming Puzzles","Code\40Golf"][+!" "]

And this 46/45 44/43 byte implementation, which I'm fairly sure is "illegal", is just for poops & giggles! It needs to be run in your browser's console while viewing this page.

document.title.substr(49,31).split`\40&\40`[+!" "]

Or a more robust option, that accommodates the changing of the question title and/or tags or can be run on any page on PPCG, weighing in at 70/69 66/65 bytes:

(t=document.title).substr(t.lastIndexOf("\40-\40")+3,31).split`\40&\40`[+!" "]
  • 1
    Oh, I didn't notice the other answer. By the way, you can do \40 instead of \x20 to save a byte :-) – ETHproductions Apr 28 '17 at 18:32
  • That's what I get for following the herd! Thanks, @ETHproductions. – Shaggy Apr 28 '17 at 22:23

><>, 42 bytes

With whitespace

/>o<"Programming Puzzles"

Try it online!

Without whitespace


Try it online!

dc, 50

[pq]sm[Programming Puzzles]dZ19=m[Code]n32P[Golf]p

Try it online.

[ ] defines a string - Z measures its length. If the length is 19 then it contains a space and the macro stored in the m register is called, which prints Programming Puzzles and quits. Otherwise Code Golf is printed.

  • Could you link to the dc interpreter / docs / github? – programmer5000 Apr 29 '17 at 1:14
  • @programmer5000 Just choose dc on TIO, then click the language name. – Dennis Apr 29 '17 at 1:15
  • @Dennis thanks, I didn't even know that TIO does that! – programmer5000 Apr 29 '17 at 1:18

><>, 47 45 bytes

! v"floG!"1-"edoC"!
o<>"selzzuP gnimmargorP">

Try it online!

Thanks to randomra for -2 (clever two !s so that I can use only one >o<.)

The code shouts "Flog! Flog! Flog!" and resembes a fish.

T-SQL, 96 82 81 67 bytes

print+iif(len(' x')=2,'Programming Puzzles','Code'+char(32)+'Golf')

Try it online | Without spaces

Old version (96 bytes):

select(case'x'when(replace(' ',' ','x'))then'Programming Puzzles'else'Code'+nchar(32)+'Golf'end)
  • Nice work, you can get to 67 by losing the outer parens and changing the condition to iif(len(' x')=2 – BradC Jun 21 '17 at 21:31
  • @BradC Close, but the outer paren prevents needing a space after print. I used a + instead and it worked. – mbomb007 Jun 21 '17 at 21:57
  • Must've pasted and counted the wrong one. And I didn't know either, but the plus was the first character I tried and it worked. – mbomb007 Jun 22 '17 at 3:20

R, 50 bytes

I think this is the same as this Javascript answer, and basically the same idea as all the others.

`if`(' '=='','Code\x20Golf','Programming Puzzles')

GolfScript, 38 bytes

" ""Programming Puzzles""Code\sGolf"if

Try it online!

Befunge, 76 bytes

" "0`#v_"floG"84*"edoC",,,,,,,,,@
,,,,,@>"selzzuP gnimmargorP",,,,,,,,,,,,,,

Try it online!

Not the most compact solution, but then again writing Befunge code without whitespace is pretty difficult.

At the very beginning, it compares a space character with 0. If it's greater, it goes to the bottom row. If it isn't, which is what happens when you replace space with nothing, it stays on the first row.

  • What do the ,s do? – programmer5000 Apr 28 '17 at 21:14
  • @programmer5000 Each prints one character. – Martin Ender Apr 28 '17 at 21:51
  • A tip for printing a large number of characters up until you reach a 0 is to do >:#,_ which could save you a lot of bytes – MildlyMilquetoast May 23 '17 at 0:09

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.