-8
\$\begingroup\$

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

\$\endgroup\$
9
  • 3
    \$\begingroup\$ I feel like we've had basically this challenge before, but I can't seem to find it. \$\endgroup\$
    – xnor
    Dec 14, 2014 at 6:28
  • \$\begingroup\$ Why the downvotes? \$\endgroup\$
    – Sheharyar
    Dec 14, 2014 at 6:30
  • 15
    \$\begingroup\$ 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. \$\endgroup\$
    – xnor
    Dec 14, 2014 at 6:34
  • 2
    \$\begingroup\$ @xnor - Thanks for explaining, I'm new to this stack site. :P \$\endgroup\$
    – Sheharyar
    Dec 14, 2014 at 6:55
  • 2
    \$\begingroup\$ Related. Also related \$\endgroup\$ Dec 14, 2014 at 7:10

28 Answers 28

12
\$\begingroup\$

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

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

PHP, 8 bytes

CODEGOLF

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

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

\$\endgroup\$
1
  • \$\begingroup\$ Hahahaha, you know what I meant. Let me rephrase the question. \$\endgroup\$
    – Sheharyar
    Dec 14, 2014 at 6:27
9
\$\begingroup\$

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!

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

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.

\$\endgroup\$
6
  • 1
    \$\begingroup\$ Unfortunately, this uses the now-banned capital G. What bad luck with your choice of Pyth's letters! \$\endgroup\$
    – xnor
    Dec 14, 2014 at 9:02
  • 1
    \$\begingroup\$ @xnor Fixed. Only tripled the length. \$\endgroup\$
    – isaacg
    Dec 14, 2014 at 10:58
  • \$\begingroup\$ 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. \$\endgroup\$
    – xnor
    Dec 14, 2014 at 11:01
  • \$\begingroup\$ @xnor Would that help for any non trivial challenges? \$\endgroup\$
    – isaacg
    Dec 14, 2014 at 11:03
  • \$\begingroup\$ 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? \$\endgroup\$
    – xnor
    Dec 14, 2014 at 11:06
5
\$\begingroup\$

Javascript (2,786 Bytes)

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

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

Output:

codegolf
\$\endgroup\$
2
5
\$\begingroup\$

CJam, 15 bytes

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

I guess it should be shorter than Marbelous.

\$\endgroup\$
5
\$\begingroup\$

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.

\$\endgroup\$
5
\$\begingroup\$

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");
    }
    
}
\$\endgroup\$
3
  • \$\begingroup\$ I think my answer is much lamer than yours! \$\endgroup\$
    – user15259
    Dec 19, 2014 at 20:31
  • \$\begingroup\$ Why not use a lambda? ()->"\143\157\144\145\143\157\154\146" ? \$\endgroup\$ Sep 11, 2016 at 12:03
  • \$\begingroup\$ @NonlinearFruit Err... Java 8 was still pretty new, this answer is from late 2014. \$\endgroup\$ Sep 11, 2016 at 13:33
5
\$\begingroup\$

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'
\$\endgroup\$
4
\$\begingroup\$

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.

\$\endgroup\$
1
  • 7
    \$\begingroup\$ 'P, would save at least 66 exabytes of memory. :P \$\endgroup\$
    – Dennis
    Dec 14, 2014 at 15:38
4
\$\begingroup\$

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

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

Brainfuck (66 Bytes)

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

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

Output:

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

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âÅ")
\$\endgroup\$
3
\$\begingroup\$

dc, 20

4850170388041124934P

Prints the ASCII byte stream 0x434F4445474F4C46.

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

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.

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

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.

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

C, 49 48 bytes

-1 byte thanks to ceilingcat.

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

C11, 46 45 bytes

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

It's obviously possible in C.

Works in 32bit little-endian systems.

\$\endgroup\$
1
  • \$\begingroup\$ Rule 3 lets you omit the 3 in the square brackets. \$\endgroup\$
    – ceilingcat
    Sep 30, 2019 at 20:33
2
\$\begingroup\$

Brainfuck (145 Bytes)

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

Output:

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

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

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

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

\$\endgroup\$
1
\$\begingroup\$

Shell, 21

tr 2-@ A-P<<<4@568@=7
\$\endgroup\$
1
\$\begingroup\$

ROT13, 8 bytes

pbqrtbys

rot13 is part of bsdgames.

\$\endgroup\$
1
\$\begingroup\$

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.

\$\endgroup\$
1
\$\begingroup\$

Jelly, 7 bytes

“£ṙɲI⁵»

Try it online!

\$\endgroup\$
3
  • \$\begingroup\$ what is this witchcraft \$\endgroup\$ Sep 11, 2016 at 13:14
  • 2
    \$\begingroup\$ @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. \$\endgroup\$ Sep 11, 2016 at 13:21
  • \$\begingroup\$ Oh I know it's Jelly. Jelly witchcraft is scary though. \$\endgroup\$ Sep 11, 2016 at 13:30
1
\$\begingroup\$

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!

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

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")
\$\endgroup\$
0
\$\begingroup\$

Pyke, 5 bytes

~aHpr

Try it here!

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

05AB1E, 5 bytes

’ƒËŠˆ

Uses the CP-1252 encoding. Try it online!

\$\endgroup\$

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