87
\$\begingroup\$

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.

Notes

  • 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$
    @42
    

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

    42$@rw$@42
    

    must output Code Golf.

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

\$\endgroup\$
12
  • 3
    \$\begingroup\$ will the space in Code Golf also be removed, what about the one in Programming Puzzles. \$\endgroup\$
    – colsw
    Commented Apr 28, 2017 at 13:20
  • 8
    \$\begingroup\$ This will be impossible in at least Whirl and Whitespace. \$\endgroup\$ Commented Apr 28, 2017 at 17:14
  • 16
    \$\begingroup\$ What are the close votes for? \$\endgroup\$
    – AAM111
    Commented Apr 28, 2017 at 21:16
  • 13
    \$\begingroup\$ @OldBunny2800 good question. I keep asking that but the comment gets removed... \$\endgroup\$
    – user58826
    Commented Apr 28, 2017 at 21:19
  • 14
    \$\begingroup\$ 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. \$\endgroup\$ Commented Apr 28, 2017 at 22:00

64 Answers 64

71
\$\begingroup\$

Python 2, 50 bytes

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

Try it online!

With all spaces removed:

print["Code\40Golf","ProgrammingPuzzles"]["">""]

Try that online!

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

\$\endgroup\$
9
  • 2
    \$\begingroup\$ Darn, ninja'd! I was just about to click Post Answer! +1 \$\endgroup\$
    – hyperneutrino
    Commented Apr 28, 2017 at 13:22
  • 2
    \$\begingroup\$ I think you just broke my friend's brain. How does this even work? \$\endgroup\$
    – Stevoisiak
    Commented Apr 28, 2017 at 15:09
  • 15
    \$\begingroup\$ @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. \$\endgroup\$ Commented Apr 28, 2017 at 15:26
  • 11
    \$\begingroup\$ @StephenS Nope, because unlike JavaScript, Python doesn't have an obsession with implicit casting. \$\endgroup\$
    – user45941
    Commented Apr 28, 2017 at 15:57
  • 4
    \$\begingroup\$ If find Python's lack of obsession disturbing. \$\endgroup\$ Commented Apr 28, 2017 at 19:56
59
\$\begingroup\$

Python 2, 48 47 bytes

-1 byte thanks to Erik the Outgolfer

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

Try it online!

print''and'ProgrammingPuzzles'or'Code\40Golf'

Try it online!

\$\endgroup\$
1
  • 10
    \$\begingroup\$ Aww, I was just about to improve my answer to this... \$\endgroup\$
    – user45941
    Commented Apr 28, 2017 at 13:29
29
\$\begingroup\$

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.

\$\endgroup\$
5
  • \$\begingroup\$ Just did the same with “½ċṭ6Ỵ“Ñ1ɦ +£)G»Ṁ \$\endgroup\$ Commented Apr 29, 2017 at 8:00
  • \$\begingroup\$ 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? \$\endgroup\$
    – steffen
    Commented May 4, 2017 at 19:55
  • \$\begingroup\$ @steffen Jelly uses a custom code page that encodes each of the 256 characters it understands as a single byte. \$\endgroup\$
    – Dennis
    Commented May 4, 2017 at 21:48
  • \$\begingroup\$ @Dennis thank you for clarifying. \$\endgroup\$
    – steffen
    Commented May 5, 2017 at 9:30
  • 22
    \$\begingroup\$ Where it all started. \$\endgroup\$
    – Razetime
    Commented Oct 10, 2020 at 4:34
26
\$\begingroup\$

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

\$\endgroup\$
0
22
\$\begingroup\$

05AB1E, 15 bytes

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

Try it online!

Explanation

”ƒËŠˆ”           # push "Code Golf"
      " "v       # for each character in the string " " do
          ”–±ÇÀ  # push "Programming Puzzles"
                 # implicitly output top of stack
\$\endgroup\$
8
  • \$\begingroup\$ ...I just don't get it. Does this use dictionary compression or something? \$\endgroup\$ Commented Apr 30, 2017 at 2:15
  • \$\begingroup\$ @LegionMammal978 I'm pretty sure it does. \$\endgroup\$ Commented Apr 30, 2017 at 3:15
  • \$\begingroup\$ @LegionMammal978: It does indeed use dictionary compression. \$\endgroup\$
    – Emigna
    Commented Apr 30, 2017 at 8:59
  • 6
    \$\begingroup\$ @Emigna Okay, because last I checked, neither of those strings could be fit into 4 bytes :p \$\endgroup\$ Commented Apr 30, 2017 at 10:27
  • 1
    \$\begingroup\$ @Draco18s: Kevin has written a nice tutorial over at the tips page you can use to get a better idea of how to use it. \$\endgroup\$
    – Emigna
    Commented Jan 9, 2019 at 17:54
16
\$\begingroup\$

Jelly, 18 bytes

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

Try it online!

Explanation

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.

\$\endgroup\$
3
  • \$\begingroup\$ This turns out to be valid. \$\endgroup\$ Commented Apr 28, 2017 at 15:34
  • \$\begingroup\$ 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? \$\endgroup\$
    – steffen
    Commented May 4, 2017 at 19:59
  • \$\begingroup\$ @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.) \$\endgroup\$
    – user62131
    Commented May 4, 2017 at 21:12
15
\$\begingroup\$

CJam, 38 bytes

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

Try it online! or with spaces removed

Explanation

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

\$\endgroup\$
2
  • 32
    \$\begingroup\$ Your code is sad :( \$\endgroup\$ Commented Apr 28, 2017 at 13:51
  • 16
    \$\begingroup\$ If you're willing to use unprintables, "Bncd\x19Fnke":) is happy code instead (replace \x19). \$\endgroup\$ Commented Apr 28, 2017 at 15:58
14
\$\begingroup\$

Javascript, 46 43 42 Bytes

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

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

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

Haskell, 48 bytes

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

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

f""="Code\32Golf";f(_)="ProgrammingPuzzles";f""

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"|" ">""]
last$"Code\32Golf":["ProgrammingPuzzles"|"">""]
\$\endgroup\$
10
\$\begingroup\$

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…

\$\endgroup\$
3
  • 1
    \$\begingroup\$ 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 shorter.by two characters. "Programming Puzzles"["Code"<>FromCharacterCode@32<>"Golf"][[01]] will work. \$\endgroup\$ Commented Apr 28, 2017 at 20:12
  • 1
    \$\begingroup\$ @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…) \$\endgroup\$
    – Not a tree
    Commented Apr 28, 2017 at 22:56
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ Commented May 1, 2017 at 13:48
7
\$\begingroup\$

Excel - 56 Bytes

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

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

\$\endgroup\$
6
\$\begingroup\$

Ohm, 33 32 bytes

Uses CP437 encoding.

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

Try it online! or try without whitespace

Explanation

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
\$\endgroup\$
4
  • \$\begingroup\$ I'm so glad I finally finished string compression! \$\endgroup\$ Commented May 2, 2017 at 20:01
  • 1
    \$\begingroup\$ @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. \$\endgroup\$ Commented May 2, 2017 at 20:05
  • \$\begingroup\$ Yeah, Smaz is kind of weird like that. \$\endgroup\$ Commented May 2, 2017 at 20:07
  • \$\begingroup\$ FYI, feel free to ping me in chat if you have any questions or feature requests for Ohm. \$\endgroup\$ Commented May 2, 2017 at 20:18
6
\$\begingroup\$

Japt, 29 bytes

With spaces:

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

Try it online!

Without spaces:

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

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:

("Code"+(S)+"Golf").r("ProgrammingPuzzles")

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

\$\endgroup\$
3
  • \$\begingroup\$ I didn't even think of using replace. Nice one! \$\endgroup\$
    – Tom
    Commented Apr 28, 2017 at 14:39
  • \$\begingroup\$ 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? \$\endgroup\$
    – steffen
    Commented May 4, 2017 at 19:57
  • \$\begingroup\$ @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) \$\endgroup\$ Commented May 4, 2017 at 20:00
5
\$\begingroup\$

Brachylog, 44 bytes

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

Try it online!

Explanation

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

Alice, 44 bytes

/"floG!"t"edoC"#
 /"selzzuP gnimmargorP"d&o@

Try it online!

Without whitespace:

/"floG!"t"edoC"#/"selzzuPgnimmargorP"d&o@

Try it online!

Explanation

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:

"floG!"t"edoC"#"selzzuPgnimmargorP"d&o@

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.

\$\endgroup\$
1
  • \$\begingroup\$ You must golf this (crossed out 44 is 44) \$\endgroup\$
    – MilkyWay90
    Commented Jan 11, 2019 at 1:55
4
\$\begingroup\$

PHP, 44 Bytes

ternary operator

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

PHP, 51 Bytes

comment

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

PHP, 57 Bytes

array switch

<?=["Code\x20Golf","Programming Puzzles"][(ord("
")/10)];
\$\endgroup\$
4
\$\begingroup\$

Common Lisp (SBCL), 52 bytes

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

Prints Programming Puzzles

(format`,t"~[ProgrammingPuzzles~;Code~@TGolf~]"01)

Prints Code Golf

Ungolfed:

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

Explaination:

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.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ +1, just one thing: "but any sub-expression prefixed with a , is evaluated and spliced in" Isn't ,@ necessary for splicing? \$\endgroup\$
    – user65167
    Commented May 3, 2017 at 15:46
  • \$\begingroup\$ "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. \$\endgroup\$
    – djeis
    Commented May 3, 2017 at 17:04
4
\$\begingroup\$

Perl 5, 43 41 bytes

say" "?"Programming Puzzles":Code.$".Golf

Try it online!

Uses the fact that ' ' is true in perl and '' is false. The $" variable is set to a space by default.

Thanks to @NahuelFouilleul for removing two bytes.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ maybe late but "Code$\"Golf" is shorter and Code.$".Golf too \$\endgroup\$ Commented Jan 9, 2019 at 13:09
  • \$\begingroup\$ @NahuelFouilleul Yeah, I was pretty new when I wrote this answer. Thanks though! \$\endgroup\$
    – Chris
    Commented Jan 9, 2019 at 17:19
3
\$\begingroup\$

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')
\$\endgroup\$
1
3
\$\begingroup\$

Pyth, 37 bytes

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

Try it here.

?"""ProgrammingPuzzles""Code\40Golf

Try it here.

\$\endgroup\$
3
\$\begingroup\$

><>, 42 bytes

With whitespace

\"floG"48*"edoC"
/>o<"Programming Puzzles"

Try it online!

Without whitespace

\"floG"48*"edoC"/>o<"ProgrammingPuzzles"

Try it online!

\$\endgroup\$
3
\$\begingroup\$

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.

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

C# 88 81 70 63 bytes

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

With whitespace stripped:

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

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.

\$\endgroup\$
12
  • 1
    \$\begingroup\$ 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 :( ) \$\endgroup\$
    – Brian J
    Commented Apr 28, 2017 at 15:36
  • \$\begingroup\$ .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=()=>... \$\endgroup\$ Commented Apr 28, 2017 at 15:37
  • \$\begingroup\$ @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! \$\endgroup\$
    – Mayube
    Commented Apr 28, 2017 at 15:38
  • \$\begingroup\$ @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)). \$\endgroup\$
    – Brian J
    Commented Apr 28, 2017 at 15:41
  • 1
    \$\begingroup\$ 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(...)). \$\endgroup\$ Commented Apr 28, 2017 at 15:47
3
\$\begingroup\$

Java 8, 74 50 48 bytes

()=>" "==""?"Code\040Golf":"Programming Puzzles"
\$\endgroup\$
3
  • \$\begingroup\$ @NonlinearFruit you're right, I've changed that one to be non-competent \$\endgroup\$
    – Khaled.K
    Commented May 1, 2017 at 18:50
  • 1
    \$\begingroup\$ 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" \$\endgroup\$ Commented May 1, 2017 at 19:59
  • 2
    \$\begingroup\$ \u00A0 -> \040 for a 2 byte savings. \$\endgroup\$
    – Poke
    Commented May 3, 2017 at 18:47
3
\$\begingroup\$

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

\$\endgroup\$
0
3
\$\begingroup\$

Befunge, 47 bytes

# <"floG"84*"edoC">:#,_@#" Programming Puzzles"

Try it Online

Without spaces it skip the first < and prints Code Golf instead

\$\endgroup\$
3
\$\begingroup\$

APL (Dyalog Unicode), ₄₅ ₄₁ 39 bytesSBCS

Anonymous lambda. Takes dummy argument.

{'Programming Puzzles'
⊢4⌽9↑'GolfCode'}

Try it online!

This function is a so called "dfn" which terminates with and returns the first non-assignment, i.e. Programming Puzzles.

Removing all whitespace gives:

{'ProgrammingPuzzles'⊢4⌽9↑'GolfCode'}

Try it online!

This takes the last nine characters of GolfCode thus padding with a trailing space, then cyclically rotates that 4 steps to the left. ignores the text on its left and returns the text on its right.

\$\endgroup\$
3
\$\begingroup\$

Python 3, 72 68 bytes

Had output backwards at first, thanks Draco18s, then saved 4 bytes, thanks Jo King

a=0;ab="Programming";a
b="Code";ad="Puzzles";a
d="Golf";print(ab,ad)

Try it online!

\$\endgroup\$
3
  • 1
    \$\begingroup\$ I think you have the outputs backwards. \$\endgroup\$ Commented Nov 11, 2019 at 20:56
  • \$\begingroup\$ Whoops lol, thanks. Fixed it \$\endgroup\$ Commented Nov 13, 2019 at 16:45
  • \$\begingroup\$ You can reuse the a to get 68 bytes \$\endgroup\$
    – Jo King
    Commented Nov 16, 2019 at 2:56
2
\$\begingroup\$

Japt, 32 bytes

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

Try it online!

\$\endgroup\$
2
2
\$\begingroup\$

PowerShell, 56 bytes

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

Try it online!

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

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.