137
\$\begingroup\$

Create the shortest possible obfuscated program that displays the text "Hello World".

In order to be considered an obfuscated program, it must meet at least two of the following requirements:

  • Does not contain the characters: h, l, w and d in any case
  • Does not contain the characters: e, o, r, 0, and 1 in any case
  • Does not contain the characters: 2 or 7

Input:
none

Output:
Hello World

Leaderboard

Here is a Stack Snippet to generate both a regular leaderboard and an overview of winners by language.

/* Configuration */

var QUESTION_ID = 307; // Obtain this from the url
// It will be like https://XYZ.stackexchange.com/questions/QUESTION_ID/... on any question page
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";
var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
var OVERRIDE_USER = 48934; // This should be the user ID of the challenge author.

/* App */

var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page;

function answersUrl(index) {
  return "https://api.stackexchange.com/2.2/questions/" +  QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER;
}

function commentUrl(index, answers) {
  return "https://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER;
}

function getAnswers() {
  jQuery.ajax({
    url: answersUrl(answer_page++),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      answers.push.apply(answers, data.items);
      answers_hash = [];
      answer_ids = [];
      data.items.forEach(function(a) {
        a.comments = [];
        var id = +a.share_link.match(/\d+/);
        answer_ids.push(id);
        answers_hash[id] = a;
      });
      if (!data.has_more) more_answers = false;
      comment_page = 1;
      getComments();
    }
  });
}

function getComments() {
  jQuery.ajax({
    url: commentUrl(comment_page++, answer_ids),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      data.items.forEach(function(c) {
        if (c.owner.user_id === OVERRIDE_USER)
          answers_hash[c.post_id].comments.push(c);
      });
      if (data.has_more) getComments();
      else if (more_answers) getAnswers();
      else process();
    }
  });  
}

getAnswers();

var SCORE_REG = /<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/;

var OVERRIDE_REG = /^Override\s*header:\s*/i;

function getAuthorName(a) {
  return a.owner.display_name;
}

function process() {
  var valid = [];
  
  answers.forEach(function(a) {
    var body = a.body;
    a.comments.forEach(function(c) {
      if(OVERRIDE_REG.test(c.body))
        body = '<h1>' + c.body.replace(OVERRIDE_REG, '') + '</h1>';
    });
    
    var match = body.match(SCORE_REG);
    if (match)
      valid.push({
        user: getAuthorName(a),
        size: +match[2],
        language: match[1],
        link: a.share_link,
      });
    
  });
  
  valid.sort(function (a, b) {
    var aB = a.size,
        bB = b.size;
    return aB - bB
  });

  var languages = {};
  var place = 1;
  var lastSize = null;
  var lastPlace = 1;
  valid.forEach(function (a) {
    if (a.size != lastSize)
      lastPlace = place;
    lastSize = a.size;
    ++place;
    
    var answer = jQuery("#answer-template").html();
    answer = answer.replace("{{PLACE}}", lastPlace + ".")
                   .replace("{{NAME}}", a.user)
                   .replace("{{LANGUAGE}}", a.language)
                   .replace("{{SIZE}}", a.size)
                   .replace("{{LINK}}", a.link);
    answer = jQuery(answer);
    jQuery("#answers").append(answer);

    var lang = a.language;
    if (/<a/.test(lang)) lang = jQuery(lang).text();
    
    languages[lang] = languages[lang] || {lang: a.language, user: a.user, size: a.size, link: a.link};
  });

  var langs = [];
  for (var lang in languages)
    if (languages.hasOwnProperty(lang))
      langs.push(languages[lang]);

  langs.sort(function (a, b) {
    if (a.lang > b.lang) return 1;
    if (a.lang < b.lang) return -1;
    return 0;
  });

  for (var i = 0; i < langs.length; ++i)
  {
    var language = jQuery("#language-template").html();
    var lang = langs[i];
    language = language.replace("{{LANGUAGE}}", lang.lang)
                       .replace("{{NAME}}", lang.user)
                       .replace("{{SIZE}}", lang.size)
                       .replace("{{LINK}}", lang.link);
    language = jQuery(language);
    jQuery("#languages").append(language);
  }

}
body { text-align: left !important}

#answer-list {
  padding: 10px;
  width: 290px;
  float: left;
}

#language-list {
  padding: 10px;
  width: 290px;
  float: left;
}

table thead {
  font-weight: bold;
}

table td {
  padding: 5px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">
<div id="answer-list">
  <h2>Leaderboard</h2>
  <table class="answer-list">
    <thead>
      <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr>
    </thead>
    <tbody id="answers">

    </tbody>
  </table>
</div>
<div id="language-list">
  <h2>Winners by Language</h2>
  <table class="language-list">
    <thead>
      <tr><td>Language</td><td>User</td><td>Score</td></tr>
    </thead>
    <tbody id="languages">

    </tbody>
  </table>
</div>
<table style="display: none">
  <tbody id="answer-template">
    <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr>
  </tbody>
</table>
<table style="display: none">
  <tbody id="language-template">
    <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr>
  </tbody>
</table>

\$\endgroup\$
15
  • 9
    \$\begingroup\$ I guess import in python is not permitted. \$\endgroup\$
    – Alexandru
    Feb 1, 2011 at 0:07
  • 29
    \$\begingroup\$ Does these rules apply to language keywords as well? \$\endgroup\$
    – hallvabo
    Feb 1, 2011 at 13:04
  • 10
    \$\begingroup\$ are those case insensitive restrictions? \$\endgroup\$
    – Rommudoh
    Aug 4, 2011 at 14:22
  • 24
    \$\begingroup\$ Could someone explain why 2 and 7 are not allowed? I'm just curious as I don't see why those were chosen in particular. \$\endgroup\$ Aug 5, 2011 at 23:01
  • 6
    \$\begingroup\$ @trinithis, and others, ASCII character 72 is "H" which is why I chose those two \$\endgroup\$ Sep 18, 2011 at 23:18

145 Answers 145

5
\$\begingroup\$

Minecraft command, 776 bytes

Let's do something explosive. These commands (break rule #1) generate "Hello World" made by TNT in a Minecraft superflat world.

Screenshot: enter image description here

/tp 33 4 3
/fill ~4 4 5 ~4 4 9 TNT
/fill ~4 4 5 ~6 4 5 TNT
/fill ~4 4 9 ~6 4 9 TNT
/fill ~6 4 5 ~6 4 6 TNT
/fill ~5 4 ~4 ~6 4 ~4 TNT
/fill ~8 4 3 ~8 4 9 TNT
/fill ~34 4 3 ~34 4 9 TNT
/fill ~38 4 3 ~38 4 9 TNT
/tp 3 4 3
/fill ~44 4 6 ~44 4 9 TNT
/fill ~54 4 3 ~54 4 9 TNT
/fill ~58 4 6 ~58 4 9 TNT
/tp 56 4 3
/fill ~4 4 6 ~4 4 6 TNT
/fill ~4 4 9 ~4 4 9 TNT
/fill ~8 4 ~4 ~8 4 ~4 TNT
/tp 66 4 3
/fill ~4 4 6 ~4 4 6 TNT
/fill ~4 4 9 ~4 4 9 TNT
/fill 33 4 3 33 4 9 TNT
/fill 34 4 6 34 4 6 TNT
/fill 35 4 3 35 4 9 TNT
/fill 43 4 3 43 4 9 TNT
/fill 45 4 6 45 4 9 TNT
/fill 46 4 6 46 4 6 TNT
/fill 46 4 9 46 4 9 TNT
/fill 53 4 9 56 4 9 TNT
/fill 53 4 3 53 4 9 TNT
/fill 55 4 3 55 4 9 TNT
/fill 59 4 6 59 4 9 TNT
/fill 63 4 6 63 4 9 TNT
/fill 65 4 6 65 4 6 TNT
/fill 69 4 6 69 4 9 TNT

Bonus: After explosion enter image description here

\$\endgroup\$
6
  • \$\begingroup\$ Why are you teleporting? Can't you just increase the relative coordinates in the fill command? \$\endgroup\$
    – Luca H
    Nov 23, 2017 at 15:22
  • \$\begingroup\$ @LucaH I must avoid number 0, 1, 2 and 7. \$\endgroup\$
    – Colera Su
    Nov 23, 2017 at 15:23
  • \$\begingroup\$ Oh man, I feel stupid... It's not like I didn't read the challenge, I just forgot about it... Thanks for clarifying! \$\endgroup\$
    – Luca H
    Nov 23, 2017 at 15:30
  • \$\begingroup\$ Wouldn't 1 work instead of TNT? \$\endgroup\$
    – Maya
    Dec 9, 2018 at 18:24
  • \$\begingroup\$ @NieDzejkob he has to avoid 1 \$\endgroup\$ Dec 24, 2019 at 21:43
4
\$\begingroup\$

Fourier, 39 bytes

8*9a99^^a+6^aa~q+3a33va86^aq+3a+3aqa-8a

Fourier is always obfuscated. This follows all of the rules.

Breakdown:

8*9a    Set the accumulator to 8, multiply it by 9, and print the 
        corresponding ASCII code.

99^^a   Set the accumulator to 99, increment it twice, and print the
        corresponding ASCII code.

+6^aa   Add 6 to the accumulator, increment it, and print the
        corresponding ASCII code twice.

~q      Set the variable q to the current value of the accumulator.

+3a     Add 3 to the accumulator and... I think you get the idea.

33va    Set the accumulator to 33, decrement it, and print ASCII.

86^a    Yes, okay, I think it's obvious by this point.

q+3a    Set the accumulator to the value of q (earlier set to 108),
        add 3, and print ASCII.

+3a     ...

qa      Invoke q again and print ASCII.

-8a     Subtract 8 from the accumulator and print ASCII.

This could maybe be refined a little.

\$\endgroup\$
1
  • \$\begingroup\$ Woah, I've only just realised that someone else has used Fourier :D Nice one, +1 \$\endgroup\$
    – Beta Decay
    May 10, 2016 at 13:30
4
\$\begingroup\$

PI based program: 127 char

q=`BC_LINE_LENGTH= bc -l<<<scale=18'51;a(1)'`;for v
in 39 iO da hJ 18 cn sU 4U 1I dS s2 me bK;do printf %b \\${q:64#$v:3};done

Old version

#!/bin/bash  

pi=$(bc -l <<<'scale=4000;4*a(1)')
pi=${pi//[$'\n\\']}
for v in aF Fb e3d F78 67a 172 496 12A 867 52D E3d 667 eAc;do
    printf -vv %b \\${pi:16#$v:3}
    o+=$v
done
echo $o  

Do render:

Hello, World!

Nota: in order to prevent long time compute, you could use pre-computed 4k pi value:

#!/bin/bash  

pi=$(gunzip < <(base64 -d <<-eof
H4sIAHM1DVwCAyXXB3IDMQwDwB9lJFH1/x/L4pxJcWwVEgRAXv312dcbe9W677wadecee1bdGuetNu6d/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WEJ04KSlfOvJpHDLmqv3jjvRmi0F7JmE7G7BHiqb4QEcN93+zx9Lmv0b1vsM5sA7QoZGVICYJiTPB5tmD9TcYY44YMRQw7mutxYmUBAZtOLyHNyk1EofXm0QrtRKjZ5GGrUhz5Vp5A8irLfi1gwQlvvhkko9L6HiG8DS91x/zcxjk3fG+US5d8Vw/AdvXM6FYBO/aRGe5+
T4Ei3d+DhQk4pXzxBhsDfh5cTnqJBwMx4z9HjINDlUWG0XlaA4NGlJGbt8bt9C8dMsNDnhnT3wHJ/b8y4ldF2xk6MqiifM9zjgZhNmSMysfHm1KM9IawV4HjTNS8EtuIpMwoxh4RS14GYb80I3nROorUvmc/g3L44YQgt/NU6bsZk+Sq7rF6HVzkvKUyprOHPBPdzI4QN9R8
/gQdxZLdztSrPdf35JFHUg4Crbyl4QkDpnnMQAvMy0xpYZ4T8vgAkDyW7ozmOXdkkFPKnWP+AVkFcIuiDwAA
eof
))
for v in af fB e3D F78 67a 172 496 12A 867 {52,E3}d 667 EaC;do
    printf -vv %b \\${pi:16#$v:3}
    o+=$v
done 
echo $o

Will render (same, but quicker):

Hello, World!
\$\endgroup\$
4
\$\begingroup\$

Labyrinth, 76 72 Characters, 12 Distinct

####*:*#(*:.#+#/#)*):.##++:.:.#+::}.#/#))-:.#*#:*-.{:.#+:.#:(*-:.#):+-.@

Try It Online

This is my first post here, so I'm not 100% sure I am doing everything right. Please let me know if there are any changes I should make! I have been working on implementing an interpreter for Labyrinth in my spare time, and since I just got a partially-working prototype (still don't have any grid manipulation or the ? ! \ characters), I wanted to write a Hello World! program as my first test, since I hadn't programmed anything yet in the language. I decided to do it without any alphanumeric characters to add a little bit of an extra challenge, but I haven't really done anything to hide how the code works.

Explanation:

  • ####*:*: Creates the number 36 (finds the length of the stack 4 times, multiplies the last two, duplicates this value, and multiplies those)

  • #(*:.: Outputs "H" (finds stack length of 3, subtracts 1, multiplies it to the 36, duplicates it for future use, and returns the character with code 72)

  • #+#/#)*):.: Outputs "e" (finds stack length of 3, adds to the 72 we saved from the last step, finds stack length of 3, divides 75 by 3, finds stack length of 3, increments to 4, multiplies 25 by 4, adds 1, duplicates for the next step, and outputs character code 101)

  • ##++:.:.: Outputs both "l"s (finds stack length twice and sums to get a value of 7, adds to the 101, duplicates and outputs twice to return two character code 108s and saves a 108 for the next step)

  • #+::}.: Output an "o" and move one to the auxiliary stack. Our next character code after the "o" is 32, but our next lowercase letter after that is another "o." For this reason, we save an 111 so that we don't have to work our way back up. (Finds stack length of 3, adds to the 108, duplicates twice, saves one on auxiliary stack, outputs one, keeps the third for the next step)

  • #/#))-:.: Returns a space. Since our character code is 111 right now, we have to find how to reduce our top-of-stack value to 32. To do this, we divide 111 by 3, returning 37 (all division rounds down), then we get a 3, increment it twice, and subtract it from the 37 to get 32. From there, we do the normal duplicate and return.

  • #*#:*-.: Return a capital "W." 32 and 87 are far enough apart that we have to do something similar to what we did in the last step. We multiply 32 by 3 to get 96, then square 3 using the #:* and subtract it off to get 87. Here, we don't duplicate, since the next value we will use is the 111 we saved on the other stack, so we simply output.

  • {:.: Fetch the 111, duplicate, and output our "o" (pretty self-explanatory).

  • #+:.: Returns "r." (increment 111 by 3, duplicate, and output)

  • #:(*-:.: Returns "l." Strangely enough, subtracting 6, duping, and outputting takes the same number of characters as the whole step to return "W" did. I expect there may be a way to golf this down, but it currently grabs the stack length (3), duplicates it, subtracts 1, multiplies them together, subtracts it from 114, duplicates 108, and outputs. Perhaps saving an extra copy of the 111 could help?

  • #):+-.: Returns "d." (Finds stack length of 3, adds 1, duplicates, sums, subtracts from 108, and returns) This is practically the same process as the last step.

  • @: Exits.

NOW REMOVED:

  • #/.: Returns "!". This seems overly short, since it has to "jump" from the lowercase letter range (near 100) to the special character range (near 30), but, in this case, there's a nice coincidence. The character code for "!" is 33, so, using the auto-floor functionality, simply dividing 100 by the length of the stack gives us the correct value. Then, we output.

Old versions had an extra colon right before the period at the end of the clause that produces "d" and, before the @, the "!" step is inserted.

In total, there are 12 distinct characters used, with three of those characters (},{, and @) only being used once and the decrement operator ( and the division operator / only being used twice. It is impossible to remove @ from the program, but { and } are unnecessary and only used to save characters in the 87-to-111 step. The ( character can likely be removed in favor of a combination of #, -, and ), and it is likely possible to shave a few others, like the + character, but that would come at the cost of being significantly longer. Division removal would be very expensive in terms of character count, but possible.

Using numeric characters, the shortest Hello World! program I know of is 43 characters (with 9 distinct), which means that the length disadvantage is only 67%, which I believe is quite a bit less than other languages.

\$\endgroup\$
1
  • 2
    \$\begingroup\$ Welcome to Code Golf. This is a really nice first answer! \$\endgroup\$ Dec 3, 2021 at 15:38
3
\$\begingroup\$

Befunge-93 - 57 characters

554553943346**,"b"3+,366**::,,3+::,48*,699*+,,+,**,**,+,@

Should meet all three requirements.

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

Perl

my @txt = (
  -38,
  -9,
  -6/3,
  -6/3,
  3/3,
  -468/6,
  -69/3,
  3/3,
  4,
  -6/3,
  -30/3,
);

$\ = "\n";
print map{pack 'C', 330/3 + $_} @txt;

I would have been able to do it without any of the of the "forbidden" characters, except there is no easy way, that I can think of to enable the use of anything other than print or die, without using, at least one of the "forbidden" characters.

use feature 'say' # e
use 5.010; # 10
BEGIN{ $^H{'feature_say'} = !'' } # eh
use Modern::Perl # ero

say ...
use IO::Handle; # e
STDOUT->say( ... )

So the only way is to load a module, that internally loads IO::Handle. Which will indirectly enable the use of STDOUT->say.

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

C (333 characters)

I decided to emphasize on obfuscate, with golf secondary. This is written entirely in C, and it only breaks rule #2 laid out in the original post. It also breaks I don't know how many C programming rules...

int main(){
int a[]={0x0a004000,0x0fc00109,0x04e01500,0x09e08400,0x03506a61,0x00f00000,0x0f010ae3,0x05f0fb16,0x0beb0030,0x0130a300,0x0bc00500,0x00000000};
int b,c=13,e,x,an;
goto _XX;
_00:an=e,x^=x,b^=b;
_10:if(!an)goto _XX;
b|=!!(an&0xf)<<x++;
an>>=4;
goto _10;
_XX:if(c<=1)goto _40;
if(c<13)printf("%c",b);
e=a[13-c--];
goto _00;
_40:return 0;
}
\$\endgroup\$
3
\$\begingroup\$

C, ??? characters

Not very heavily golfed, but I was going more for obfuscation anyway. Your mileage may vary, you'll probably have to do some crap to get the hardcoded address of printf right. No forbidden characters. You could easily shorten up a lot of stuff by not using different numbers of underscores as variable names and instead using 1 letter things, but I think it looks uglier this way.

int main()
{
    int(*f)(int*,...)=467846797-333333333;
    int _=9-8,__=_<<_,___=__<<_,____=___<<_,_____=____<<_,______=_____<<_,$=_|((_____|____)<<__);
    
    f("%c", $+(_|__|___)^______);
    f("%c", $+(___));
    f("%c", $+(_|__|____));
    f("%c", $+(_|__|____));
    f("%c", $+(__|___|____));
    f("%c", ______);
    f("%c", $+(__|___|_____)^______);
    f("%c", $+(__|___|____));
    f("%c", $+(_|_____));
    f("%c", $+(_|__|____));
    f("%c", $+(_|__));
    f("%c", ______|_);
}
\$\endgroup\$
3
\$\begingroup\$

Befunge-93, 8x6 grid

I know I'm a little late to the party, but I saw the Befunge-93 solutions and decided to see how small I could make one while still following all the rules.

"[uixn"v
Qv:,-9<"
v_vQQQ^)
>9+,>:|f
^Q>>^Q@"
^"?ncu"<
\$\endgroup\$
3
\$\begingroup\$

><> (Fish), 80 bytes

Wait, I'm not the only one that uses ><>?

33-aa*:8+:6+:3-8a*843--+48*aa*:b+$8+::843---89*ab*43-+543-p33-43-.
 :?!;_33-43-.

Thanks to @Sp3000 for a method to print without "o".


Try it here.

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

C 61 Bytes

main(){printf("%ce%c%co %cor%c%c",9*8,108,108,86+1,108,100);}

Went as small as possible on this guy. Hopefully y'all can see that. This breaks rule 2.

\$\endgroup\$
1
  • \$\begingroup\$ The rules say you have to comply with two of the three rules. I follow rule 1 and 3 \$\endgroup\$
    – bioweasel
    Oct 20, 2016 at 19:47
3
\$\begingroup\$

SuperMarioLang, 235 bytes

Why does this language exist?

+>+>)+)+)+++)++++((((-[!)>->.
+"+"===================#+".")
+++!((+++++++++)++++++)<.---+
++=#===================")---.
++((.-(.)).+++..+++++++.<---
 !+======================---
=#>++++++++++++++.).+++.-!>!
  =======================#=#

Try it online!

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

MAWP, 97 89 bytes

98W;55W4W1M;93W4W;93W4W;94W1M3W;58W4M;84W;98M5W64AM;94W1M3W;99M1M6W;93W4W;55W4W;964AM3W;.

Meets two of the requirements

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

Vyxal, 2 bytes

kh

Try it Online!

Built-in that pushes the string Hello World. Since it meets two of the requirements, it is valid, but it's not really obfuscated, is it? How about one that meets all three requirements?


Less trivial, 6 bytes

`ƈṡ ƛ€

Try it Online!

Pushes Hello World as a dictionary-compressed string and implicitly outputs. It meets all of the requirements, but it's still a bit boring, no?

Non-trivial, 7 bytes

\k⁺∧C+Ė

Try it Online!

Builds the string kh and evaluates it as Vyxal code. Meets all three requirements, and definitely the most obfuscated of the three programs.

Explanation:

\k       # Push 'k'
  ⁺∧     # Push 104; '⁺' takes the index of the next command in the Vyxal codepage ('∧' is 0x03) and adds 101
    C    # Convert to character; 104 becomes 'h'
     +   # Concatenate; builds the string 'kh'
      Ė  # Evaluate as Vyxal code
         # Implicit output
\$\endgroup\$
1
3
\$\begingroup\$

Python (6019 chars)

eval(eval(''+eval('str(str)[+all([])]')+eval('str(str'+eval('str('+str(eval)[eval(str((+all([])))+str((+all([[]]))))]+'l'+str(eval)[eval(str((+all([])))+str((all([])+all([])+all([])+all([])+all([])+all([]))))]+'at((+all([]))))[(+all([]))]')+str(str)[+all([])]+str(eval)[eval(str((+all([])))+str((all([])+all([])+all([])+all([])+all([])+all([]))))]+str(eval)[(all([])+all([]))]+str(eval)[(all([])+all([])+all([])+all([])+all([])+all([])+all([])+all([]))]+'t)[(all([])+all([])+all([])+all([]))]')+'r('+str((+all([])))+str((+all([])))+str((all([])+all([])))+')')+'r'+eval(''+eval('str(str)[+all([])]')+eval('str(str'+eval('str('+str(eval)[eval(str((+all([])))+str((+all([[]]))))]+'l'+str(eval)[eval(str((+all([])))+str((all([])+all([])+all([])+all([])+all([])+all([]))))]+'at((+all([]))))[(+all([]))]')+str(str)[+all([])]+str(eval)[eval(str((+all([])))+str((all([])+all([])+all([])+all([])+all([])+all([]))))]+str(eval)[(all([])+all([]))]+str(eval)[(all([])+all([])+all([])+all([])+all([])+all([])+all([])+all([]))]+'t)[(all([])+all([])+all([])+all([]))]')+'r('+str((+all([])))+str((+all([[]])))+str((all([])+all([])+all([])+all([])+all([])))+')')+eval('str(eval)[(all([])+all([])+all([])+all([])+all([])+all([])+all([])+all([]))]')+'t('+eval(''+eval('str(str)[+all([])]')+eval('str(str'+eval('str('+str(eval)[eval(str((+all([])))+str((+all([[]]))))]+'l'+str(eval)[eval(str((+all([])))+str((all([])+all([])+all([])+all([])+all([])+all([]))))]+'at((+all([]))))[(+all([]))]')+str(str)[+all([])]+str(eval)[eval(str((+all([])))+str((all([])+all([])+all([])+all([])+all([])+all([]))))]+str(eval)[(all([])+all([]))]+str(eval)[(all([])+all([])+all([])+all([])+all([])+all([])+all([])+all([]))]+'t)[(all([])+all([])+all([])+all([]))]')+'r('+str((all([])+all([])+all([])))+str((all([])+all([])+all([])+all([])))+')')+eval(''+eval('str(str)[+all([])]')+eval('str(str'+eval('str('+str(eval)[eval(str((+all([])))+str((+all([[]]))))]+'l'+str(eval)[eval(str((+all([])))+str((all([])+all([])+all([])+all([])+all([])+all([]))))]+'at((+all([]))))[(+all([]))]')+str(str)[+all([])]+str(eval)[eval(str((+all([])))+str((all([])+all([])+all([])+all([])+all([])+all([]))))]+str(eval)[(all([])+all([]))]+str(eval)[(all([])+all([])+all([])+all([])+all([])+all([])+all([])+all([]))]+'t)[(all([])+all([])+all([])+all([]))]')+'r('+str((all([])+all([])+all([])+all([])+all([])+all([])+all([])))+str((all([])+all([])))+')')+'ell'+eval('str(eval)[eval(str((+all([])))+str((all([])+all([])+all([])+all([])+all([])+all([]))))]')+eval(''+eval('str(str)[+all([])]')+eval('str(str'+eval('str('+str(eval)[eval(str((+all([])))+str((+all([[]]))))]+'l'+str(eval)[eval(str((+all([])))+str((all([])+all([])+all([])+all([])+all([])+all([]))))]+'at((+all([]))))[(+all([]))]')+str(str)[+all([])]+str(eval)[eval(str((+all([])))+str((all([])+all([])+all([])+all([])+all([])+all([]))))]+str(eval)[(all([])+all([]))]+str(eval)[(all([])+all([])+all([])+all([])+all([])+all([])+all([])+all([]))]+'t)[(all([])+all([])+all([])+all([]))]')+'r('+str((all([])+all([])+all([])+all([])))+str((all([])+all([])+all([])+all([])))+')')+eval(''+eval('str(str)[+all([])]')+eval('str(str'+eval('str('+str(eval)[eval(str((+all([])))+str((+all([[]]))))]+'l'+str(eval)[eval(str((+all([])))+str((all([])+all([])+all([])+all([])+all([])+all([]))))]+'at((+all([]))))[(+all([]))]')+str(str)[+all([])]+str(eval)[eval(str((+all([])))+str((all([])+all([])+all([])+all([])+all([])+all([]))))]+str(eval)[(all([])+all([]))]+str(eval)[(all([])+all([])+all([])+all([])+all([])+all([])+all([])+all([]))]+'t)[(all([])+all([])+all([])+all([]))]')+'r('+str((all([])+all([])+all([])))+str((all([])+all([])))+')')+eval(''+eval('str(str)[+all([])]')+eval('str(str'+eval('str('+str(eval)[eval(str((+all([])))+str((+all([[]]))))]+'l'+str(eval)[eval(str((+all([])))+str((all([])+all([])+all([])+all([])+all([])+all([]))))]+'at((+all([]))))[(+all([]))]')+str(str)[+all([])]+str(eval)[eval(str((+all([])))+str((all([])+all([])+all([])+all([])+all([])+all([]))))]+str(eval)[(all([])+all([]))]+str(eval)[(all([])+all([])+all([])+all([])+all([])+all([])+all([])+all([]))]+'t)[(all([])+all([])+all([])+all([]))]')+'r('+str((+all([])))+str((+all([])))+str((all([])+all([])+all([])+all([])+all([])+all([])+all([])+all([])+all([])))+')')+eval('str(eval)[eval(str((+all([])))+str((all([])+all([])+all([])+all([])+all([])+all([]))))]')+'rl'+eval(''+eval('str(str)[+all([])]')+eval('str(str'+eval('str('+str(eval)[eval(str((+all([])))+str((+all([[]]))))]+'l'+str(eval)[eval(str((+all([])))+str((all([])+all([])+all([])+all([])+all([])+all([]))))]+'at((+all([]))))[(+all([]))]')+str(str)[+all([])]+str(eval)[eval(str((+all([])))+str((all([])+all([])+all([])+all([])+all([])+all([]))))]+str(eval)[(all([])+all([]))]+str(eval)[(all([])+all([])+all([])+all([])+all([])+all([])+all([])+all([]))]+'t)[(all([])+all([])+all([])+all([]))]')+'r('+str((+all([])))+str((+all([[]])))+str((+all([[]])))+')')+eval(''+eval('str(str)[+all([])]')+eval('str(str'+eval('str('+str(eval)[eval(str((+all([])))+str((+all([[]]))))]+'l'+str(eval)[eval(str((+all([])))+str((all([])+all([])+all([])+all([])+all([])+all([]))))]+'at((+all([]))))[(+all([]))]')+str(str)[+all([])]+str(eval)[eval(str((+all([])))+str((all([])+all([])+all([])+all([])+all([])+all([]))))]+str(eval)[(all([])+all([]))]+str(eval)[(all([])+all([])+all([])+all([])+all([])+all([])+all([])+all([]))]+'t)[(all([])+all([])+all([])+all([]))]')+'r('+str((all([])+all([])+all([])))+str((all([])+all([])+all([])))+')')+eval(''+eval('str(str)[+all([])]')+eval('str(str'+eval('str('+str(eval)[eval(str((+all([])))+str((+all([[]]))))]+'l'+str(eval)[eval(str((+all([])))+str((all([])+all([])+all([])+all([])+all([])+all([]))))]+'at((+all([]))))[(+all([]))]')+str(str)[+all([])]+str(eval)[eval(str((+all([])))+str((all([])+all([])+all([])+all([])+all([])+all([]))))]+str(eval)[(all([])+all([]))]+str(eval)[(all([])+all([])+all([])+all([])+all([])+all([])+all([])+all([]))]+'t)[(all([])+all([])+all([])+all([]))]')+'r('+str((all([])+all([])+all([])))+str((all([])+all([])+all([])+all([])))+')')+')')
\$\endgroup\$
1
  • \$\begingroup\$ Welcome to Code Golf, and nice answer! \$\endgroup\$ Apr 26, 2022 at 14:04
2
\$\begingroup\$

FSharp, 83

("(())(((()("|>String.mapi(fun i c->" =CCG/GJC<".[i]+c)).Insert(5," ")|>printf "%s"

Breaks the second rule to use some F# keywords.

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

J (23 characters)

a.{~<:a.i.'Ifmmp!Xpsme'

It doesn't beat Golfscript, but I figure J deserves an entry anyway. (This is just a minor tweak of the second example on the J vocabulary page for the word i..

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

APL (157 155)

No h, l, r, w, d, 2, 7, e, o, or r, but there is 0 and 1 (so it meets two out of three requirements).

I went for obfuscation rather than size. (If you can't figure out how it works, it is a variation of this guy's method).

⎕UCS{⌈+/96,⍵{⊃a×b○c×1.118×⍺,a b c←⍵}¨,⌿((11-33)13.3 ¯8.5 18(.3×4)16.5 4 8.5 .4 6,[0]10⍴(⍴'⍴⍴')1),[1]⌈.5×⍳10}¨(⍳11)-1

APL (28)

Boring straightforward one, but meets all requirements and is short-ish.

⎕UCS(⎕UCS'Jgnnq"Yqtnf')-.5×4
\$\endgroup\$
2
  • \$\begingroup\$ +1 That's a great link. But your code's greek to me. :) (Don't worry, I'll get there. Just got some Iverson from Amazon.) \$\endgroup\$ Apr 10, 2013 at 3:58
  • 1
    \$\begingroup\$ Save a byte on the bottom one with -⍴⍬⍬ \$\endgroup\$
    – Adám
    Jul 20, 2016 at 15:55
2
\$\begingroup\$

C Program (83 Characters)

#include<stdio.h>
void main(){printf("%ce%c%co %cor%c%c",104,108,108,119,108,100);}
\$\endgroup\$
1
  • 1
    \$\begingroup\$ This program satisfies rules 1 and 3. \$\endgroup\$ May 1, 2012 at 17:46
2
\$\begingroup\$

"C++"

329 bytes including newlines and extraneous backslashes on newlines (which are 7 bytes).

C++ is in scare quotes because of all the implementation dependent details (gcc, appropriate linux kernel, x86). Doing this challenge in C++ is difficult because right off the bat #include is forbidden.

int main(){int r[]={1819043144,1866980911+1000000,164353511+10000011};asm("sub \
$31,%%esp\nsub $1,%%esp\nmov $4,%%eax\nmov %%eax,0x1C(%%esp)\nmov %0,%%eax\nmov\
 %%eax,0x18(%%esp)\nmov %1,%%eax\nmov %%eax,0x14(%%esp)\nmov $1,%%eax\nmov %%ea\
x,16(%%esp)\npopa\nint $0x80"::"r"(r),"r"(9+3):"%eax","%ebx","%ecx","%esi",
"%ebx");}

I think there's technically a bit of undefined behavior here as well, since I don't tell gcc all the registers I clobber (Things like %edx cannot be referred to directly) which is unfortunate.

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

JavaScript 155 142 122

This satisfies ALL the rules provided.

_=(!!4+"")[5-4],3[C="c\x6fnst"+_+"uct\x6f"+_][C]("a\x6c\x65"+_+
"t('\x48\x65\x6c\x6c\x6f \\x5"+-~6+"\x6f'+_+'\x6c\x64')")()
\$\endgroup\$
7
  • 1
    \$\begingroup\$ You can do -~[] to get 1. Also, using my approach with constructor twice instead of going via []["sort"] saves you even more: 3[$="c\x6fnst"+(_=(!+[]+"")[-~[]])+"uct\x6f"+_][$] gets you Function and saves 14 chars. \$\endgroup\$
    – FireFly
    Jan 20, 2014 at 23:08
  • \$\begingroup\$ @FireFly, nice spotting... All rules now done in 142 characters... I had to account for the "W"... Damn hard character to get with the restrictions... \$\endgroup\$ Jan 21, 2014 at 0:54
  • 1
    \$\begingroup\$ I took the liberty to edit the post with some more changes, I hope you don't mind... get boolean true via !!4, the number 1 via 5-4, and by making use of double-escaping (once because of the string literal, and then a second time due to the string literal inside the alert in the function body) we could simply concatenate the -~6 into the string instead of having to unescape. \$\endgroup\$
    – FireFly
    Jan 21, 2014 at 12:31
  • \$\begingroup\$ @FireFly As Humphrey Bogart said in Casablanca "This looks like the start of a beautiful friendship." :) But I have to ask, what the hell is the use of the 3? I see ',3[C="' but don't understand the number's importance in the code? \$\endgroup\$ Jan 21, 2014 at 22:15
  • 1
    \$\begingroup\$ Haha. The 3 replaces [] in your code because both numbers and arrays (like all other types constructed via constructor functions) inherit a 'constructor' property from their prototype. It doesn't matter which of these that we use, so I switched to 3 since it saves a character. In the end, it's just a stepping stone to reach Function (as the constructor of the Number function, i.e. Number.constructor). If you want to discuss further we should probably use the chatroom instead... \$\endgroup\$
    – FireFly
    Jan 21, 2014 at 22:33
2
\$\begingroup\$

Sclipting, 8 characters

낆녬닆묠녶뭲닆밄

Of course, this doesn’t contain any of the restricted characters.

(This answer is technically cheating because Sclipting was invented after this challenge was posted.)

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

Haskell (genetic programming), 306 chars

This is not really genetic programming. It's just a pun. The only violation of the rules is the function name putStrLn, which is a builtin I/O function, and follows the spirit of the rules even if it doesn't quite match the letter.

a=(['~','}'..]!!)
t=(succ)
y= \x->x-x
c=(y)$3
g=((t.t$c)*)
q=(a.g.t.g.t.g.g.t.g.t$c):(a.t.g.g.g.t.g.t$c):(a.g.t.g.g.g.t$c):(a.g.t.g.g.g.t$c):(a.t.g.t.g.t.g.t$c):(a.g.t.g.t.g.t.g.t.g.g.t$c):(a.t.g.t.g.t.g.g.g.t$c):(a.t.g.t.g.t.g.t$c):(a.g.g.t.g.t$c):(a.g.t.g.g.g.t$c):(a.g.t.g.g.t.g.t$c):[]
main=putStrLn$q
\$\endgroup\$
2
  • \$\begingroup\$ +1. But what's the significance of the parens around y on line 4? \$\endgroup\$
    – yyny
    Jan 30, 2016 at 0:15
  • 1
    \$\begingroup\$ None whatsoever. I suppose you could shave off a couple extra chars, but this isnt a competitive answer in any case. \$\endgroup\$ Jan 30, 2016 at 4:58
2
\$\begingroup\$

Golfscript 18 bytes

New code (saved 4 bytes thanks to Martin Büttner):

'Jgnnq"Yqtnf'{((}%

Old code (22 bytes):

"Jgnnq\"Yqtnf"{1 1+-}%

It basically preforms a Caesar cipher two times. Because you can't have a 2 in your code, I just used 1+1. It doesn't break any of the rules.

\$\endgroup\$
1
  • \$\begingroup\$ (( (decrement twice) is shorter than 1 1+-. Also, does GolfScript support ' to delimit strings? In that case you wouldn't need to escape the " in the string. \$\endgroup\$ Mar 9, 2015 at 12:47
2
\$\begingroup\$

Clip, 17 chars

All rules followed.

m+'☻`"Fcjjm▲Umpjb

This just means, in a more readable form, map (add 2 to ascii value) "Fcjjm▲Umpjb".

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

Pyth - 24 bytes. All 3 rules

Noticed there wasn't a Pyth entry yet (probably because the question's been around longer), but wanted to add one for completion's sake!

V"Qnuux)`x{um"=+kC-CN9;k

Try it out.

Explanation

# basically just a -9 int value translation on each character

V"Qnuux)`x{um"        ;     # for each chr (N) in the string "Qnuux)`x{um"
              =+k           #   append to k (initially an empty string)
                 C          #   the character value of the integer
                  -  9      #   that results from subtracting 9 from
                   CN       #   the integer value of the current chr (N)
                       k    # print k
\$\endgroup\$
2
\$\begingroup\$

Befunge-93, 49 45 bytes

Thanks to James Holderness for saving me two four bytes! (I don't know how to count)

Why is this 7-year-old challenge in the front page? I don't know! What I do know is that I came up with an answer before I realized the thread is ancient, so here goes:

554**:8+:6+:3-:83*-48*"q"2-:3-::7-"F"2+>:#,_@

Works in complete disregard to the third rule, but that's fine because rules are made to be broken anyway it meets 1 and 2.

Try it online!

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

Java, 88

I'm surprised, nobody used java.

System.out.print\u006Cn("\u0048e\u006C\u006Co "+((c\u0068ar)(11*8-1))+"or\u006C\u0064");
\$\endgroup\$
2
  • \$\begingroup\$ 1) this is not a complete function; 2) byte count is wrong. See my answer. \$\endgroup\$
    – Andrey
    Jan 18, 2017 at 8:04
  • \$\begingroup\$ @Andrey 1) it won't compile, but you can run it in jshell under java 9, as for 2 i fixed it. \$\endgroup\$
    – user902383
    Jan 18, 2017 at 8:17
2
\$\begingroup\$

Java, 71 bytes

Violates restriction #2, but doesn't contain [HLWDhlwd27].

String m(){return String.format("\u0048e\154\154o %cor\154\144",86+1);}

OR to print to stdout (the same length)

voi\u0064 m(){System.out.printf("\u0048e\154\154o %cor\154\144",86+1);}
\$\endgroup\$
3
  • \$\begingroup\$ task is to "Create the shortest possible obfuscated program that displays the text "Hello World"." and you are not displaying it \$\endgroup\$
    – user902383
    Jan 18, 2017 at 8:19
  • \$\begingroup\$ @user902383 function can use its return value for output. Anyway, I've updated the answer. \$\endgroup\$
    – Andrey
    Jan 18, 2017 at 8:53
  • \$\begingroup\$ v->"\u0048e\154\154o "+(char)(86+1)+"or\154\144" for 48 bytes. \$\endgroup\$ Jun 15, 2020 at 14:33
2
\$\begingroup\$

pb, 72 bytes

b[69+3]>b[101]>b[108]>b[108]>b[111]>>b[86+1]>b[111]>b[114]>b[108]>b[100]

Violates rule II

\$\endgroup\$
3
  • \$\begingroup\$ oh hey, someone else wrote a pb answer! (i'm a little late) \$\endgroup\$ Sep 8, 2017 at 6:13
  • \$\begingroup\$ @undergroundmonorail hey you're back! (?) \$\endgroup\$ Sep 8, 2017 at 9:16
  • \$\begingroup\$ i check this site every day... has it really been that long since i posted anything? o_o \$\endgroup\$ Sep 9, 2017 at 5:55

Your Answer

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

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