You need to produce the word codegolf


Rules:

  1. None of the characters of the word codegolf (i.e. 'c', 'o', 'd', 'e', 'g', 'o', 'l' and 'f') in either case can exist anywhere in the code.

  2. Case of the word must be one of three:

    • All Upcase (CODEGOLF)
    • All Downcase (codegolf)
    • Capitalized (Codegolf)
  3. You only need to produce it somehow so there can be other characters in the output as well. For example, 21§HCodegolf092 is an acceptable result.

  4. The shortest code (counting in bytes) to do so in any language wins.


I guess it will be less trickier in some languages than others (Brainfuck, Javascript, etc.)

closed as too broad by Addison Crump, betseg, Erik the Outgolfer, flawr, Paul Schmitz Sep 11 '16 at 16:23

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.

  • 3
    I feel like we've had basically this challenge before, but I can't seem to find it. – xnor Dec 14 '14 at 6:28
  • Why the downvotes? – Sheharyar Dec 14 '14 at 6:30
  • 15
    The downvotes are probably because "print X without X" is a type of challenge that's been done to death and people are tired of it. So, it's not your question but the site's history, which I can't blame you for not knowing. – xnor Dec 14 '14 at 6:34
  • 2
    @xnor - Thanks for explaining, I'm new to this stack site. :P – Sheharyar Dec 14 '14 at 6:55
  • 2
    Related. Also related – FryAmTheEggman Dec 14 '14 at 7:10

28 Answers 28

Bash(works if there are no other files matching /bin/?at), 14

/bin/?at /*/u*

This expands to cat <files>, where the files include /dev/urandom. Because of the infinite monkey theorem, this will eventually output "codegolf".

  • 2
    Well, I almost surely upvoted you. – wchargin Dec 14 '14 at 23:39
  • It got stuck on /dev/ptmx on my system. – jimmy23013 Dec 15 '14 at 2:39
  • @user23013 Sorry, didn't think of that. Will edit. – user4098326 Dec 15 '14 at 2:41
  • And /*/?at worked for me. – jimmy23013 Dec 15 '14 at 2:45

PHP, 8 bytes

CODEGOLF

Does not contain 'c', 'o', 'd', 'e', etc.

(You might want to ban their uppercase versions as well.)

  • Hahahaha, you know what I meant. Let me rephrase the question. – Sheharyar Dec 14 '14 at 6:27

C - lots of characters

Without include, define, char, printf, return and lots of other useful things, it's a real challenge to try to do this in C.

I thought of outputting upside down letters, i.e. ɟloƃǝpoɔ, but the l and o are the same.

So here's the best I can do, which many people might remember as being very much like their first C assignment.

int main()
{
    puts("                   @                       @     @@ ");
    puts("                   @                       @    @   ");
    puts("                   @                       @    @   ");
    puts("  @@@    @@@    @@@@   @@@    @@@@   @@@   @  @@@@@ ");
    puts(" @   @  @   @  @   @  @   @  @   @  @   @  @    @   ");
    puts(" @      @   @  @   @  @@@@@  @   @  @   @  @    @   ");
    puts(" @   @  @   @  @   @  @      @   @  @   @  @    @   ");
    puts("  @@@    @@@    @@@@   @@@    @@@@   @@@   @    @   ");
    puts("                                 @                  ");
    puts("                                 @                  ");
    puts("                              @@@                   ");
}

To compile: gcc -o codegolf codegolf.c, surprisingly gcc, at least my installation, doesn't complain about missing includes or returns.

Running:

 $ ./codegolf 
                   @                       @     @@ 
                   @                       @    @   
                   @                       @    @   
  @@@    @@@    @@@@   @@@    @@@@   @@@   @  @@@@@ 
 @   @  @   @  @   @  @   @  @   @  @   @  @    @   
 @      @   @  @   @  @@@@@  @   @  @   @  @    @   
 @   @  @   @  @   @  @      @   @  @   @  @    @   
  @@@    @@@    @@@@   @@@    @@@@   @@@   @    @   
                                 @                  
                                 @                  
                              @@@  

If you squint your eyes and/or zoom out, it kind of looks okay!

PHP, 13 bytes

<?=~œ›š˜“™;

StackExchange may swallow some of the control characters. Here's a hexdump of the program:

3c 3f 3d 7e 9c 90 9b 9a 98 90 93 99 3b

It bitwise inverts the string, and prints it using the PHP short tag syntax.

Pyth, 9 bytes with updated rules

^v"\107"8

v"\107" evals a string containing G, octal escaped, which is the pyth variable for the alphabet.

^G8, is the result, which prints all 8 letter strings in the lowercase alphabet, including codegolf. Runs out of memory on my machine, unfortunately.

  • 1
    Unfortunately, this uses the now-banned capital G. What bad luck with your choice of Pyth's letters! – xnor Dec 14 '14 at 9:02
  • 1
    @xnor Fixed. Only tripled the length. – isaacg Dec 14 '14 at 10:58
  • This answer inspires me to suggest a new Pyth constant: A fixed, extremely long string of random characters. Or a De Brujin graph if you want to be efficient. – xnor Dec 14 '14 at 11:01
  • @xnor Would that help for any non trivial challenges? – isaacg Dec 14 '14 at 11:03
  • Not really, I'm just amused at the idea of one-character solutions. Unless iterating over it saves chars when you want to do something a huge but finite number of times? – xnor Dec 14 '14 at 11:06

Javascript (2,786 Bytes)

I'm not competing with this answer, just pointing out that it can be done.

([]+{})[!+[]+!![]+!![]+!![]+!![]]+([]+{})[+!![]]+([][[]]+[])[!+[]+!![]]+([][[]]+[])[!+[]+!![]+!![]]+[][(![]+[])[!+[]+!![]+!![]]+([]+{})[+!![]]+(!![]+[])[+!![]]+(!![]+[])[+[]]][([]+{})[!+[]+!![]+!![]+!![]+!![]]+([]+{})[+!![]]+([][[]]+[])[+!![]]+(![]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+[]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(!![]+[])[+[]]+([]+{})[+!![]]+(!![]+[])[+!![]]]((!![]+[])[+!![]]+([][[]]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+!![]]+([]+{})[!+[]+!![]+!![]+!![]+!![]+!![]+!![]]+([][[]]+[])[+[]]+([][[]]+[])[+!![]]+([][[]]+[])[!+[]+!![]+!![]]+(![]+[])[!+[]+!![]+!![]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(+{}+[])[+!![]]+([]+[][(![]+[])[!+[]+!![]+!![]]+([]+{})[+!![]]+(!![]+[])[+!![]]+(!![]+[])[+[]]][([]+{})[!+[]+!![]+!![]+!![]+!![]]+([]+{})[+!![]]+([][[]]+[])[+!![]]+(![]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+[]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(!![]+[])[+[]]+([]+{})[+!![]]+(!![]+[])[+!![]]]((!![]+[])[+!![]]+([][[]]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+!![]]+([]+{})[!+[]+!![]+!![]+!![]+!![]+!![]+!![]]+(![]+[])[!+[]+!![]]+([]+{})[+!![]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(+{}+[])[+!![]]+(!![]+[])[+[]]+([][[]]+[])[!+[]+!![]+!![]+!![]+!![]]+([]+{})[+!![]]+([][[]]+[])[+!![]])())[!+[]+!![]+!![]]+([][[]]+[])[!+[]+!![]+!![]])()([][(![]+[])[!+[]+!![]+!![]]+([]+{})[+!![]]+(!![]+[])[+!![]]+(!![]+[])[+[]]][([]+{})[!+[]+!![]+!![]+!![]+!![]]+([]+{})[+!![]]+([][[]]+[])[+!![]]+(![]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+[]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(!![]+[])[+[]]+([]+{})[+!![]]+(!![]+[])[+!![]]]((!![]+[])[+!![]]+([][[]]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+!![]]+([]+{})[!+[]+!![]+!![]+!![]+!![]+!![]+!![]]+([][[]]+[])[!+[]+!![]+!![]]+(![]+[])[!+[]+!![]+!![]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(+{}+[])[+!![]]+([]+[][(![]+[])[!+[]+!![]+!![]]+([]+{})[+!![]]+(!![]+[])[+!![]]+(!![]+[])[+[]]][([]+{})[!+[]+!![]+!![]+!![]+!![]]+([]+{})[+!![]]+([][[]]+[])[+!![]]+(![]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+[]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(!![]+[])[+[]]+([]+{})[+!![]]+(!![]+[])[+!![]]]((!![]+[])[+!![]]+([][[]]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+!![]]+([]+{})[!+[]+!![]+!![]+!![]+!![]+!![]+!![]]+(![]+[])[!+[]+!![]]+([]+{})[+!![]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(+{}+[])[+!![]]+(!![]+[])[+[]]+([][[]]+[])[!+[]+!![]+!![]+!![]+!![]]+([]+{})[+!![]]+([][[]]+[])[+!![]])())[!+[]+!![]+!![]]+([][[]]+[])[!+[]+!![]+!![]])()(([]+{})[+[]])[+[]]+(!+[]+!![]+!![]+!![]+!![]+!![]+[])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+[]))+([]+{})[+!![]]+(![]+[])[!+[]+!![]]+([][[]]+[])[!+[]+!![]+!![]+!![]]

Output:

codegolf

CJam, 15 bytes

"r~utv~}w"{H^}%

I guess it should be shorter than Marbelous.

Java, 118 Bytes

This is probably the lamest answer. Java programs have many key words. In order to print anything you have to use System.out. Despite all of these restrictions I can remove all of the letters in codegolf from my program except two letters.

With c and o allowed, 118 bytes:

c\u006cass a{pub\u006cic static voi\u0064 main(String[]a){Syst\u0065m.out.print("\143\157\144\145\143\157\154\146");}}

With l and o allowed, 123 bytes:

\u0063lass a{publi\u0063 stati\u0063 voi\u0064 main(String[]a){Syst\u0065m.out.print("\143\157\144\145\143\157\154\146");}}

With c and f allowed, 128 bytes:

c\u006cass a{pub\u006cic static v\u006fi\u0064 main(String[]a){Syst\u0065m.\u006fut.print("\143\157\144\145\143\157\154\146");}}

With l and f allowed, 133 bytes:

\u0063lass a{publi\u0063 stati\u0063 v\u006fi\u0064 main(String[]a){Syst\u0065m.\u006fut.print("\143\157\144\145\143\157\154\146");}}

With no restrictions on boilerplate code, 98 bytes:

class a{public static void main(String[]a){System.out.print("\143\157\144\145\143\157\154\146");}}

Expanded:

class a{

    public static void main(String[]a){
        System.out.print("\143\157\144\145\143\157\154\146");
    }

}
  • I think my answer is much lamer than yours! – Yimin Rong Dec 19 '14 at 20:31
  • Why not use a lambda? ()->"\143\157\144\145\143\157\154\146" ? – NonlinearFruit Sep 11 '16 at 12:03
  • @NonlinearFruit Err... Java 8 was still pretty new, this answer is from late 2014. – LegionMammal978 Sep 11 '16 at 13:33

Perl - 12

say a.."z"x8

This also takes advantage of rule 3. It prints every word from a to zzzzzzzz.

Run with:

perl -E'say a.."z"x8'

CJam, 10 bytes

'P,{_m*}3*

It runs very slowly, and it should run out of memory on most computers. But if it exited successfully finally, it will print a lot of things including CODEGOLF.

  • 7
    'P, would save at least 66 exabytes of memory. :P – Dennis Dec 14 '14 at 15:38

C, 49 bytes

main(){int a[3]={1701080931,1718382439};puts(a);}

C11, 46 bytes

main(){puts((int[3]){1701080931,1718382439});}

It's obviously possible in C.

Works in 32bit little-endian systems.

Marbelous - 9 bytes

7A
/\/\??

This will with a probability approaching 1 print a string containing all three acceptable outputs, since it prints an endless string of random ascii characters (up to and including the lowercase 'z' with ascii value 7A). Nothing was specified about whether this program should terminate. And just to make it clear, the characters get printed as they get generated, not after the program terminates (which is never).

Brainfuck (66 Bytes)

Can you do it in Brainfuck? Yes? Than I do it in Brainfuck!

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

Output:

CODEGOLF

Javascript (29 bytes / 25 characters)

this['bt\x6fa']("àÄâÅ")

SE strips out the control characters, so here's a hex dump:

74 68 69 73 5B 27 62 74 5C 78 36 66 61 27 5D 28 22 08 C3 A0 C3 84 18 C3 A2 C3 85 22 29 

With escape characters (34 / 29)

this['bt\x6fa']("\bàÄ\x18âÅ")

dc, 20

4850170388041124934P

Prints the ASCII byte stream 0x434F4445474F4C46.

J, 6 (12?) char

A sentence returning CODEGOLF at the REPL, along with every other combination of 8 ASCII characters and a whole bunch of spaces, newlines, and box-drawing characters.

{8#<a.

If you want to toss this into STDOUT, prepend 1!:2&4 to double the charcount.

Brainfuck (145 Bytes)

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

Output:

CODEGOLF

CJam, 18 bytes

"1n¯]"245bHb{'B+}%

This answer prints the result instantaneously without consuming infinite system memory :)

It is just base conversion of the string CODEGOLF to both save bytes and to avoid using any of the restricted characters.

Just try it out here

ROT13, 8 bytes

pbqrtbys

rot13 is part of bsdgames.

Python 2.7, 52 48 bytes

print('%'+`map`[13])*8%(67,79,68,69,71,79,76,70)

Output:

CODEGOLF

This answer creates a format string using a 'c' found in the representation string of the built-in map function. The program then uses the format string to convert each integer into a character that creates the 'CODEGOLF' string.

Alright, here we go again.

The Hexadecimal Stacking Pseudo-Assembly Language (156):

(Technically not a valid entry, or so I'm told)

200066
400000
200063
400000
200009
400000
210000
200066
400000
200009
400000
210000
200067
400000
200065
400000
200064
400000
200066
400000
200009
400000
210000
200063
400000
140000

Output:

codegolf

Shell, 21

tr 2-@ A-P<<<4@568@=7

Unnamed Two-Dimensional Programming Language, 26 bytes

67&79&68&69&71&79&76&70&s;

Output:

CODEGOLF

You can try it out here (Replace the code in the code() function with this code).

If it is acceptable, the final semicolon can be removed and the program will loop infinitely (in theory, not in the interpreter, as the interpreter gives up after 2048 instructions to avoid a browser-crashing infinite loop) for a score of 25 bytes.

This works by pushing the values for the characters CODEGOLF to the stack, printing them, and terminating.

Jelly, 7 bytes

“£ṙɲI⁵»

Try it online!

  • what is this witchcraft – Addison Crump Sep 11 '16 at 13:14
  • 2
    @Syxer It's a valid Jelly program. This is a compressed string using Jelly's compression. You can see that because 1) starts a string 2) » ends a compressed string. The string is then automatically output, no trailing newline AFAIK. To learn more about this language invented by Dennis, click on the Jelly link on my post. – Erik the Outgolfer Sep 11 '16 at 13:21
  • Oh I know it's Jelly. Jelly witchcraft is scary though. – Addison Crump Sep 11 '16 at 13:30

Vitsy, 6 bytes

<ZR^72

This has a 1 in 36028797018963968 chance of printing the right order of characters per character output with ~10000 characters output a second. This means that, by 3.17 million years from now, you'll almost certainly have seen it.

:)

Using a method found here.

Try it online!

Lua, 33 bytes

CODEGOLF (33 bytes)

print("\67\79\68\69\71\79\76\70")

Codegolf (40 bytes)

print("\67\111\100\101\103\111\108\102")

codegolf (40 bytes)

print("\99\111\100\101\103\111\108\102")

05AB1E, 5 bytes (non-competing)

Non-competing, since the language postdates the challenge.

’ƒËŠˆ

Uses the CP-1252 encoding. Try it online!

Pyke, 5 bytes

~aHpr

Try it here!

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