515
\$\begingroup\$

So... uh... this is a bit embarrassing. But we don't have a plain "Hello, World!" challenge yet (despite having 35 variants tagged with , and counting). While this is not the most interesting code golf in the common languages, finding the shortest solution in certain esolangs can be a serious challenge. For instance, to my knowledge it is not known whether the shortest possible Brainfuck solution has been found yet.

Furthermore, while all of Wikipedia (the Wikipedia entry has been deleted but there is a copy at archive.org ), esolangs and Rosetta Code have lists of "Hello, World!" programs, none of these are interested in having the shortest for each language (there is also this GitHub repository). If we want to be a significant site in the code golf community, I think we should try and create the ultimate catalogue of shortest "Hello, World!" programs (similar to how our basic quine challenge contains some of the shortest known quines in various languages). So let's do this!

The Rules

  • Each submission must be a full program.
  • The program must take no input, and print Hello, World! to STDOUT (this exact byte stream, including capitalization and punctuation) plus an optional trailing newline, and nothing else.
  • The program must not write anything to STDERR.
  • If anyone wants to abuse this by creating a language where the empty program prints Hello, World!, then congrats, they just paved the way for a very boring answer.

    Note that there must be an interpreter so the submission can be tested. It is allowed (and even encouraged) to write this interpreter yourself for a previously unimplemented language.

  • Submissions are scored in bytes, in an appropriate (pre-existing) encoding, usually (but not necessarily) UTF-8. Some languages, like Folders, are a bit tricky to score - if in doubt, please ask on Meta.
  • This is not about finding the language with the shortest "Hello, World!" program. This is about finding the shortest "Hello, World!" program in every language. Therefore, I will not mark any answer as "accepted".
  • If your language of choice is a trivial variant of another (potentially more popular) language which already has an answer (think BASIC or SQL dialects, Unix shells or trivial Brainfuck-derivatives like Alphuck), consider adding a note to the existing answer that the same or a very similar solution is also the shortest in the other language.

As a side note, please don't downvote boring (but valid) answers in languages where there is not much to golf - these are still useful to this question as it tries to compile a catalogue as complete as possible. However, do primarily upvote answers in languages where the authors actually had to put effort into golfing the code.

For inspiration, check the Hello World Collection.

The Catalogue

The Stack Snippet at the bottom of this post generates the catalogue from the answers a) as a list of shortest solution per language and b) as an overall leaderboard.

To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:

## Language Name, N bytes

where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:

## Ruby, <s>104</s> <s>101</s> 96 bytes

If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the last number in the header:

## Perl, 43 + 2 (-p flag) = 45 bytes

You can also make the language name a link which will then show up in the snippet:

## [><>](https://esolangs.org/wiki/Fish), 121 bytes

/* Configuration */

var QUESTION_ID = 55422; // 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 = 8478; // 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,<]*(?:<(?:[^\n>]*>[^\n<]*<\/[^\n>]*>)[^\n,<]*)*),.*?(\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,
      });
    else console.log(body);
  });
  
  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;
    lang = jQuery('<a>'+lang+'</a>').text();
    
    languages[lang] = languages[lang] || {lang: a.language, lang_raw: lang, 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_raw.toLowerCase() > b.lang_raw.toLowerCase()) return 1;
    if (a.lang_raw.toLowerCase() < b.lang_raw.toLowerCase()) 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;
  display: block !important;
}

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

#language-list {
  padding: 10px;
  width: 500px;
  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="https://cdn.sstatic.net/Sites/codegolf/all.css?v=ffb5d0584c5f">
<div id="language-list">
  <h2>Shortest Solution 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>
<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>
<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\$
21
  • 3
    \$\begingroup\$ @isaacg No it doesn't. I think there would be some interesting languages where it's not obvious whether primality testing is possible. \$\endgroup\$ Aug 28, 2015 at 13:56
  • 6
    \$\begingroup\$ If the same program, such as "Hello, World!", is the shortest in many different and unrelated languages, should it be posted separately? \$\endgroup\$ Aug 28, 2015 at 15:33
  • 2
    \$\begingroup\$ @mbomb007 Well it's hidden by default because the three code blocks take up a lot of space. I could minify them so that they are a single line each, but I'd rather keep the code maintainable in case bugs come up. \$\endgroup\$ Aug 28, 2015 at 19:34
  • 8
    \$\begingroup\$ @ETHproductions "Unlike our usual rules, feel free to use a language (or language version) even if it's newer than this challenge." Publishing the language and an implementation before posting it would definitely be helpful though. \$\endgroup\$ Aug 29, 2015 at 23:01
  • 2
    \$\begingroup\$ @MartinEnder ... Almost. If two BF solutions have the same size, the one with smaller lexicographical order will take smaller number of bytes in Unary. Of course the smallest Unary solution translated to BF is guaranteed to be smallest. \$\endgroup\$
    – DELETE_ME
    May 20, 2018 at 10:20

969 Answers 969

1
2
3 4 5
33
34
\$\begingroup\$

Java 8, 76 bytes

Thought I would try to beat Geobit's answer :)

interface A{static void main(String[]a){System.out.print("Hello, World!");}}

Try here!

\$\endgroup\$
3
  • \$\begingroup\$ Why not use class? \$\endgroup\$
    – Joao-3
    Dec 29, 2022 at 17:31
  • \$\begingroup\$ @Joao-3 interface methods are public by default. \$\endgroup\$ Dec 29, 2022 at 21:56
  • \$\begingroup\$ Oh, thanks for giving me a nice Java fact! \$\endgroup\$
    – Joao-3
    Jan 3 at 13:52
34
+100
\$\begingroup\$

Shakespeare Programming Language, 755 749 715 612 605 592 bytes

-34 bytes thanks to jimmy23013

-And a whole 107 bytes more! Wow!

,.Ajax,.Puck,.Act I:.Scene I:.[Enter Ajax and Puck]Ajax:You big big big cat!Puck:You is the sum ofI the square ofI!Speak thy!You is the square ofthe sum ofI a big cat!Ajax:Remember the sum oftwice twice you a cat!Remember I!You is the sum ofI you!Puck:You is the sum ofyou a cat!Speak thy!You is the sum ofa big cat a cat!Ajax:Speak thy!Speak thy!Remember you!You is the sum ofyou I!Speak thy!Remember the sum ofyou I!Remember you!You big big big big big cat!Puck:You is the sum ofI twice twice you!Speak thy!Ajax:Remember the sum oftwice I a pig!Scene V:.Ajax:Speak thy!Recall!Let usScene V!

Try it online!

Non-erroring version, 626 bytes

,.Ajax,.Puck,.Act I:.Scene I:.[Enter Ajax and Puck]Ajax:Remember I!You big big big cat!Puck:You is the sum ofI the square ofI!Speak thy!You is the square ofthe sum ofI a big cat!Ajax:Remember the sum oftwice twice you a cat!Remember I!You is the sum ofI you!Puck:You is the sum ofyou a cat!Speak thy!You is the sum ofa big cat a cat!Ajax:Speak thy!Speak thy!Remember you!You is the sum ofyou I!Speak thy!Remember the sum ofyou I!Remember you!You big big big big big cat!Puck:You is the sum ofI twice twice you!Speak thy!Ajax:Remember the sum oftwice I a pig!Scene V:.Ajax:Speak thy!Recall!Be you nicer zero?If solet usscene V!

Try it online!

An improvement over the previous community wiki answer.

Explanation:

,.Ajax,.Puck,.Act I:.Scene I:.[Enter Ajax and Puck]   #Initialise Ajax and Puck

Ajax:You big big big cat!                    #Set Puck to 8
Puck:You is the sum of I the square of I!    #Set Ajax to 8+8*8=72 ('H')
Speak thy!                                   #Print 'H'
You is the square of the sum of I a big cat! #Set Ajax to (8+2)^2=100 ('d')
Ajax:Remember the sum of twice twice you a cat! #Push 2*2*8+1=33 ('!') to Puck's stack
Remember I!                                  #Push 'd' to Puck's stack
You is the sum of I you!                     #Set Puck to 100+8 ('l')
Puck:You is the sum of you a cat!            #Set Ajax to 100+1=101 ('e')
Speak thy!                                   #Print 'e'
You is the sum of a big cat a cat!           #Set Ajax to 3
Ajax:Speak thy!Speak thy!                    #Print 'll'
Remember you!                                #Push 'l' to Puck's stack
You is the sum of you I!Speak thy!           #Set Puck to 108+3=111('o') and print it
Remember the sum of you I!                   #Push 111+3=114 ('r') to Puck's stack
Remember you!                                #Push 111 ('o') to Puck's stack

You big big big big big cat!                 #Set Puck to 32 (' ')
Puck:You is the sum of I twice twice you!    #Set Ajax to 32+12=44 (',')
Speak thy!                                   #Print ','
Ajax:Remember the sum of twice I a pig!      #Push 2*44-1=87 ('W') to Puck's stack
Scene V:.Ajax:Speak thy!Recall!Let us Scene V!  #Print and pop repeatedly until Puck's stack is empty (', World!')
\$\endgroup\$
8
  • \$\begingroup\$ Impressive. Take another +1. This should win one of ASCII-only's bounties for improving the RosetTIO solutions. \$\endgroup\$ Apr 9, 2018 at 12:39
  • \$\begingroup\$ Ah, just noticed the no stderr rule, so the 622 byte version is probably invalid. \$\endgroup\$
    – jimmy23013
    Apr 11, 2018 at 8:43
  • \$\begingroup\$ @jimmy23013 Eh, we already had 43 warnings in stderr, I think we're good. Very nice work! \$\endgroup\$
    – Jo King
    Apr 11, 2018 at 10:17
  • \$\begingroup\$ @JoKing They were all compiler messages and it was not the program itself writing to stderr. But this time a runtime error. \$\endgroup\$
    – jimmy23013
    Apr 11, 2018 at 10:35
  • \$\begingroup\$ Let us Scene V works. \$\endgroup\$
    – jimmy23013
    Apr 11, 2018 at 10:42
33
\$\begingroup\$

Pada, 83 68 bytes

~.O~Ow~q~Owo~O~Oww~Q~qwo~q~O~wQ~q~w~q~q~Q~Ow~Q~Q~wo~q~w.~q~w.~.wO~qw

I believe this is optimal for a linear program (i.e. one which doesn't use the control flow operators ? and *). It might be optimal overall, but I don't know how to go about making use of those additional operators in such a small amount of code (or how to explore the possibilities programmatically).

The language has recently undergone some changes after I started discussing it with the author by email. However, I have written a reference implementation for the current state of the language spec last week, so the above code is actually runnable.

Metagolf

Originally, I had used the output of my reference implementation to this challenge and created a hand-crafted solution based on that. However, that was just a heuristic approach.

So instead I wrote a solver in Mathematica which actually knows about the Pada data structures and operators to find an optimal solution. On average, it grows linearly with the length of the string (although some character combinations are a bit slower than others) and took about 1.5 hours for Hello, World!.

So how did I go about writing the solver. First, we notice that we only need to consider 6 operators: ~.oOqQ (plus the necessary w for each of the printed characters). Using the stacks or the bit locks isn't useful in linear code, and I don't believe that ? and * can be used effectively in less than 68 bytes.

Pada's state (ignoring the stacks and locks) consists of 7 switches and 8 bits, arranged like this:

       /
   /       \
 /   \   /   /
0 1 0 0 1 0 0 0

So that's 215 = 32768 possible states. My first preprocessing step was to set up a directed graph of states where each edge corresponds to a single operation. That is, the graph has 32768 vertices, each with out-degree 6 (one outgoing edge for each of the 6 operations under consideration). We can use this graph to find the shortest path between any two states (this graph alone can be quite useful for golfing Pada).

Now for each character, we want to reach a state where w prints that character. How many such states are there? w reads the byte from the bit it is dropped on (cyclically). So there are 8 possible rotations of the bits of the character which can all print that character. For each of those rotations, three switches are fixed (in order to make w drop in the correct position). This leaves 4 arbitrary switches. So we've got 8 * 24 = 128 possible states for each w in our code.

With those we can solve another graph problem: construct a graph which has a source vertex, then one "layer" for each character, and a sink vertex. The layers consist of the 128 states for each vertex, the source node corresponds to the initial state of the program (all switches to the left and all bits are zero). The sink node corresponds to no state in particular. We've got directed edges from every vertex in one layer to every vertex in the next layer, where the edge weight is the distance between the two states in our earlier graph. The weights of the edges from the last layer to the sink are all 0. That is, we can precompute all those edge weights. This is the most expensive step of the computation and took 1.5 hours for Hello, World!.

With this graph set up, we can find the shortest path from the source to the sink quite quickly (it took 0.05s on my machine). For Hello, World! the desired states are:

0, 16960, 22052, 13828, 13828, 30389, 12487, 8307, 27299, 23450, 18922, 22778, 18682, 18459

where the least significant 7 bits correspond to the switches and the most significant 8 bits to Pada's bits.

Now we go back to the first graph and find the actual edges (i.e. operations) corresponding to the shortest path between each pair of subsequent states, and end each of them with a w. Voilà, an optimal solution (based on the above assumptions).

Here is the full Mathematica if anyone ever wants to metagolf a different string in Pada:

string = "Hello, World!";
width = StringLength@string;
getState[letter_, state_] := (
  {shift, switchState} = IntegerDigits[state - 1, 16, 2];
  bits = RotateRight[
    IntegerDigits[ToCharacterCode[letter][[1]], 2, 8], shift];
  switchState = IntegerDigits[switchState, 2, 4];
  switches = {-1, -1, -1, -1, -1, -1, -1};
  {top, middle, bottom} = IntegerDigits[shift, 2, 3];
  switches[[1]] = top;
  If[top < 1,
   switches[[2]] = middle;
   If[middle < 1,
    switches[[4]] = bottom,
    switches[[5]] = bottom
    ],
   switches[[3]] = middle;
   If[middle < 1,
    switches[[6]] = bottom,
    switches[[7]] = bottom
    ]
   ];
  For[i = 1, i <= 7, ++i,
   If[switches[[i]] < 0,
    switches[[i]] = First@switchState;
    switchState = Rest@switchState
    ]
   ];
  {bits, switches}
  )
encode[state_] := FromDigits[Join @@ state, 2]
decode[id_] := Partition[IntegerDigits[id, 2, 15], 8, 8, 1, {}]
getBitFromSwitches[switches_] := (
  If[switches[[1]] < 1,
   If[switches[[2]] < 1,
    1 + switches[[4]],
    3 + switches[[5]]
    ],
   If[switches[[3]] < 1,
    5 + switches[[6]],
    7 + switches[[7]]
    ]
   ]
  )
toggle[list_, index_] := ReplacePart[list, index -> 1 - list[[index]]]
stateEdges = Flatten@Table[
    {bits, switches} = decode@id;
    bit = getBitFromSwitches@switches;
    {
     Labeled[id \[DirectedEdge] encode@{bits~toggle~bit, switches}, 
      "~"],
     Labeled[id \[DirectedEdge] encode@{bits, switches~toggle~1}, "."],
     If[switches[[1]] < 1,
      {
       Labeled[id \[DirectedEdge] encode@{bits, switches~toggle~2}, 
        "o"],
       Labeled[
        id \[DirectedEdge] encode@{bits, switches~toggle~1~toggle~3}, 
        "q"],
       If[switches[[2]] < 1,
        Labeled[id \[DirectedEdge] encode@{bits, switches~toggle~4}, 
         "O"],
        Labeled[id \[DirectedEdge] encode@{bits, switches~toggle~5}, 
         "O"]
        ],
       If[switches[[3]] < 1,
        Labeled[
         id \[DirectedEdge] 
          encode@{bits, switches~toggle~1~toggle~3~toggle~7}, "Q"],
        Labeled[
         id \[DirectedEdge] 
          encode@{bits, switches~toggle~1~toggle~3~toggle~6}, "Q"]
        ]
       },
      {
       Labeled[id \[DirectedEdge] encode@{bits, switches~toggle~3}, 
        "o"],
       Labeled[
        id \[DirectedEdge] encode@{bits, switches~toggle~1~toggle~2}, 
        "q"],
       If[switches[[3]] < 1,
        Labeled[id \[DirectedEdge] encode@{bits, switches~toggle~6}, 
         "O"],
        Labeled[id \[DirectedEdge] encode@{bits, switches~toggle~7}, 
         "O"]
        ],
       If[switches[[2]] < 1,
        Labeled[
         id \[DirectedEdge] 
          encode@{bits, switches~toggle~1~toggle~2~toggle~5}, "Q"],
        Labeled[
         id \[DirectedEdge] 
          encode@{bits, switches~toggle~1~toggle~2~toggle~4}, "Q"]
        ]
       }
      ]
     }
    ,
    {id, 0, 2^15 - 1}];
stateGraph = 
  Graph[# & @@@ stateEdges, EdgeLabels -> Rule @@@ stateEdges];
uid = 0;
layers = Join[{{{uid++, 0}}}, 
   Table[{uid++, encode@getState[#, i]}, {i, 128}] & /@ 
    Characters@string, {{{uid++, -1}}}];
edges = Flatten[Table[
      from \[DirectedEdge] to
      ,
      {from, #},
      {to, #2}
      ] & @@@ Partition[layers, 2, 1], 2];
Timing[weights = (
     {from, to} = Last /@ List @@ #;
     If[to < 0,
      0,
      GraphDistance[stateGraph, from, to]
      ]
     ) & /@ edges;]
characterGraph = Graph[edges, EdgeWeight -> weights];
Timing[path = 
  Last /@ Most@
    FindShortestPath[characterGraph, {0, 0}, layers[[-1]][[1]]]]
(PropertyValue[{stateGraph, #}, EdgeLabels] & /@ 
      DirectedEdge @@@ 
       Partition[FindShortestPath[stateGraph, ##], 2, 1] <> "w" & @@@ 
   Partition[path, 2, 1]) <> ""
\$\endgroup\$
5
  • \$\begingroup\$ An interesting language to do metagolf on =). This makes me wonder, what's your day job? o.O \$\endgroup\$
    – justhalf
    Aug 29, 2015 at 15:08
  • 4
    \$\begingroup\$ @justhalf I'm currently in limbo between a master's degree and PhD studies (so I've definitely got too much time on my hands if that was your implication ;)). (This is generally more of a discussion for chat though :)) \$\endgroup\$ Aug 29, 2015 at 16:00
  • \$\begingroup\$ Pada means when in bahasa Indonesia/Malay. Is that relevant? \$\endgroup\$
    – XiKuuKy
    Oct 28, 2016 at 15:28
  • \$\begingroup\$ @XiKuuKy afaik, the language is called Pada, because it means "falling" in Croatian. \$\endgroup\$ Oct 28, 2016 at 19:41
  • \$\begingroup\$ And this answer to (see here ). You probably can combine 2 answers in one to describe this wonderful Hello World problem in general. \$\endgroup\$ Sep 20, 2017 at 15:30
30
\$\begingroup\$

Pyth, 14 bytes

"Hello, World!

Doubt it'll get smaller than this in Pyth.

\$\endgroup\$
2
  • 18
    \$\begingroup\$ This also works in TI Basic \$\endgroup\$ Sep 8, 2015 at 19:40
  • \$\begingroup\$ I checked all nine zlib.compress levels with [len(zlib.compress("Hello, World!",i))+2 for i in range(10)] .Z"compressed text isn't more efficient for any level. \$\endgroup\$
    – Tornado547
    Nov 28, 2017 at 16:51
30
\$\begingroup\$

Befunge 98, 19 18 Bytes

New answer (from undergroundmonorail)

"ck,@!dlroW ,olleH

Explanation

  • " starts string mode
  • Everything that follows is pushed to the stack. The stack is now Hello, World!@,kc
  • After hitting the end, interpreter go back to the start
  • It encounters " again, ending string mode
  • 12 is pushed to the stack (c)
  • k takes the top value of stack and executes the next command the instruction pointer can see that many times
  • , pops a value from stack and outputs it as a char. It has been executed 12 times by last k instruction, and one time more when the interpreter actually reads the , instruction
  • @ ends the program

The difference with the old answer is that we cleverly reuse the " character by using Befunge's looping behavior when it hits the end of the line. Since it might be less intuitive, I'm letting the old one as well. Also, you may have noticed that the stack will still contains some characters (ck,@) because of this nice trick, leaving some mess if we ever wanted to do something after that.

Old Answer

"!dlroW ,olleH"ck,@

This works for funge and befunge 98

Explanation

  • Everything between "" is pushed to the stack. ('H' is now on top.)
  • c (12) is pushed to the stack
  • k takes the top value of stack and executes the next command the instruction pointer can see that many times.
  • , pops a value from stack and outputs it as a char. It has been executed 12 times by last k instruction, and one time more when the interpreter actually reads the , instruction
  • @ ends the program
\$\endgroup\$
15
  • 2
    \$\begingroup\$ I don't think 93 has k \$\endgroup\$
    – Sp3000
    Aug 28, 2015 at 14:30
  • 1
    \$\begingroup\$ Well, now that it's 98 only you can use c for 93+. \$\endgroup\$ Aug 28, 2015 at 19:52
  • 3
    \$\begingroup\$ In 18: "ck,@!dlroW ,olleH \$\endgroup\$ Sep 25, 2015 at 19:07
  • 1
    \$\begingroup\$ It hits the " to start the string, adds the entire rest of the line to that string, wraps around and hits the same " to end the string. Now the whole program except that " has been pushed to the stack, with !dlroW ,olleH on top. Then it prints the top 12 characters the same way yours does and stops at @. \$\endgroup\$ Sep 28, 2015 at 17:40
  • 1
    \$\begingroup\$ For the 18 byte solution, my interpreter produces ` Hello, World` (leading space, no exclamation). The Anarchy Golf interpreter (use form, select Befunge-98, paste code, submit) does the same. \$\endgroup\$
    – primo
    Sep 29, 2015 at 12:14
30
\$\begingroup\$

Python 2, 20 bytes

print"Hello, World!"

Python 2 is better for printing than 3 :D

\$\endgroup\$
4
  • 29
    \$\begingroup\$ Just in case anybody is wondering: import __hello__ prints "Hello world!", which is incorrect punctuation for this challenge. \$\endgroup\$
    – Sp3000
    Aug 28, 2015 at 15:11
  • 7
    \$\begingroup\$ @Sp3000 Yeah, I looked into it. It actually prints Hello world... (tested on repl.it. You're thinking of Python 3, which has a different result. \$\endgroup\$
    – mbomb007
    Aug 28, 2015 at 15:13
  • \$\begingroup\$ @mbomb007 Ah, I didn't realise Python 2 and Python 3 had different __hello__ messages, indeed I tested on the wrong one. \$\endgroup\$
    – Sp3000
    Aug 28, 2015 at 15:18
  • \$\begingroup\$ Python 2.7 prints Hello world... \o/ What is this!!! \$\endgroup\$
    – Zizouz212
    Sep 16, 2016 at 1:37
28
+1000
\$\begingroup\$

Hexagony, 23 bytes

H;_\/201;lQP/oe;/W_|@dr

Try it online!

----

This was found with a brute force program. Time taken:

In 0 days 0 hours 52 minutes 56.4935 seconds

I suspect this is optimal.

\$\endgroup\$
11
  • 1
    \$\begingroup\$ I was hoping it wouldn't be brute-forced, but you still get the bounty \$\endgroup\$
    – Jo King
    May 19, 2018 at 13:56
  • 3
    \$\begingroup\$ @JoKing I was hoping it would be :D ... I've been meaning to write a brute forcer for linear programs for ages and never got around to it, so I'm glad someone finally did. \$\endgroup\$ May 19, 2018 at 13:57
  • 3
    \$\begingroup\$ Any plans on posting the brute-forcer as well? \$\endgroup\$
    – Jo King
    May 20, 2018 at 0:29
  • 1
    \$\begingroup\$ @JoKing Before posting the brute force program, I need to optimize it and make sure that it doesn't produce a shorter solution in a reasonable amount of time. \$\endgroup\$
    – DELETE_ME
    May 20, 2018 at 13:17
  • 1
    \$\begingroup\$ I'm quite impressed by this backwards code the brute force has worked out, where it uses each ; at least twice in passing, and twice again when the paths cross over \$\endgroup\$
    – Jo King
    May 20, 2018 at 13:51
27
\$\begingroup\$

Brainfuck, 92 (hirose)

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

This is a slight modification of hirose's 92-byte solution for the lowercase-w version of the problem on Anarchy Golf.

Changing ++ to -- conveniently subtracts 32 from the cell that holds w, turning it into W.

Brainfuck, 95

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

For this solution, I used code that I wrote for this problem on SPOJ and touched up the output a bit by hand.

Note: Both solutions are compatible with Alex Pankratov's bff (brainfuck interpreter used on SPOJ and ideone) and Thomas Cort's BFI (used on Anarchy Golf).

\$\endgroup\$
4
  • \$\begingroup\$ Here's the variant for a brainfuck derivative, oOo code: pastebin.com/BqNcDnm7 I'm not sure if it deserves its own answer. (It's based on the 92-char one you posted) \$\endgroup\$
    – JNV
    Aug 30, 2015 at 8:41
  • \$\begingroup\$ What is the advantage of the 95-byte solution? Why mention it at all? \$\endgroup\$
    – anatolyg
    Aug 31, 2015 at 14:29
  • 2
    \$\begingroup\$ @anatolyg The 92 is my modification of hirose's solution. The 95 is another solution that I developed from scratch. If you can't see the value of mentioning alternative approaches, or of distinguishing your own work from (trivial or non-trivial) modifications of someone else's code, I don't know what to say. This type of thing is standard practice on Anarchy Golf, and I'd be happy to see it catch on here as well. Incidentally, I've been informed that the 95 translates to 97 in ???, while the 92 translates to 98. \$\endgroup\$ Aug 31, 2015 at 16:04
  • \$\begingroup\$ (I was misinformed; it's 95 -> 96 and 92 -> 97 for ???.) \$\endgroup\$ Aug 31, 2015 at 20:29
26
\$\begingroup\$

Jelly, 8 bytes

“3ḅaė;œ»

Try it online!

\$\endgroup\$
4
  • 1
    \$\begingroup\$ Wat. How on earth did you compress it so much... \$\endgroup\$ Jan 11, 2016 at 15:42
  • 6
    \$\begingroup\$ Jelly now has an experimental decompressor that indexes an English dictionary. \$\endgroup\$
    – Dennis
    Jan 11, 2016 at 16:00
  • 17
    \$\begingroup\$ Jelly is ḅaė. \$\endgroup\$
    – mbomb007
    Feb 24, 2016 at 19:54
  • 2
    \$\begingroup\$ you mean: ḅaė is jelly \$\endgroup\$
    – Daniele D
    Aug 12, 2016 at 9:06
26
\$\begingroup\$

Stack Cats, 134 + 3 = 137 148 907 bytes

I'm happy to give a 500-rep bounty to the first person who can bring this down below 100 (+3) bytes.

-*(:^-_-_:-_:-_:-_:-_-_:[:^]]:^!-*!->[!_>[!_>[{]>[^-_-_:]]<<<}>[!-:^[[\\>]:^[[>:[>:^[<<]]\\>[*>+:^:-_]:^[[-_*[>>>[-_[/<]>+^[>[<<]]*>[)

Needs to be run with the -l switch of the Ruby interpreter, hence +3 bytes.

Try it online!

There's definitely still room for improvement here, but I haven't quite figured out myself yet how to program in this language effectively. The current solution was just a general idea for how to approach the challenge and I just wrote the code in a rather ad-hoc way. Even without changing the overall approach I'm confident that one can end up much closer to 100 bytes or even below.

Explanation

Proudly introducing my latest creation, this time in collaboration with Sp3000. :) The idea for this language was originally born for feersum's language design CnR, but at the time we weren't able to figure out whether this idea was usable, and then kept putting it off. A couple of weeks ago we decided to revisit the idea, cleaned up the design a lot and managed to make progress towards proving its Turing-completeness, so here it is.

Stack Cats is a stack-based, reversible programming language. In fact, in order to undo any piece of code, you simply mirror it (which means reversing it and swapping all brackets and slashes). Furthermore, every program has to have mirror symmetry itself. This implies that every non-trivial program has odd length and the form f g f-1, where g is a single very simple command which is also an involution. That makes programming and especially golfing in Stack Cats fairly tricky.

Note that the source code above isn't actually symmetric. This is because the -l switch lets you omit the first half (before the g), since it's redundant in any valid program anyway. So the full program is actually:

(]<*[[>>]<]^+<[>\]_-]<<<]*_-]]^:[_-:^:+<*]<//[[>>]^:<]:<]]^:[<//]]^:-!]<{>>>[[:_-_-^]<[}]<_!]<_!]<-!*-!^:[[^:]:_-_-:_-:_-:_-:_-_-^:)*-*(:^-_-_:-_:-_:-_:-_-_:[:^]]:^!-*!->[!_>[!_>[{]>[^-_-_:]]<<<}>[!-:^[[\\>]:^[[>:[>:^[<<]]\\>[*>+:^:-_]:^[[-_*[>>>[-_[/<]>+^[>[<<]]*>[)

When I say "stack-based", I mean that the memory model is actually a tape of stacks. As in my other stack-based languages, each stack is initially implicitly filled an infinite amount of zero (this time, that was actually necessary to ensure full reversibility of all commands on all possible states). In addition to this the initial stack starts with a -1 on top when there is no input (which is the case here).

Output in Stack Cats works simply by printing the contents of the final stack, top to bottom. So the goal is to generate a stack with the following values (top is right):

33 100 108 114 111 87 32 44 111 108 108 101 72

(There are a few other options but this is what the above program does.)

I'm going to represent the tape as follows, with the v indicating the tape head's position:

     v
... -1 ...
     0

Now on to the code. Note that the program begins with a (...) which continues until just before the central *-*. This is a loop, which can be used as a conditional. The loop is entered and exited only when the top of the stack is positive. Since the initial stack holds a -1, the entire first half of the program is skipped. This makes programming a lot easier, but of course it's also somewhat wasteful in terms of golfing. I haven't yet been able to figure out how to make easy use of both halves of the code except for simple toy problems.

Next comes the *-*. Here, * takes the top of the stack XOR 1, i.e. turns -1 into -2, the - negates it to give 2 and then we have another *, giving 3. Now that the top of the stack is positive, we do enter the (...) in the second half. The code in there will be executed only once and now turns this single 3 into the stack we need for the output.

It turns out that the quickest way to obtain large numbers without loops is a Fibonacci-like progression where we repeatedly add the last value to the one before. I say Fibonacci-like because we have some flexibility here since we can occasionally increment or decrement values in the process, or add the last value to the previous one several times before swapping their roles.

For now, we're trying to compute 33 and 87, because they both appear in the same Fibonacci-like sequence. (And they are the character codes of ! and W.) If the top of the stack is a and the value below is b, I'll be writing this as (a, b), so the current state is (3, 0). Let's go:

:    Swap the top two values.              (  0,  3)
^    XOR the second into the first.        (  3,  3)
-    Negate top.                           ( -3,  3)
_    Subtract top from second.             (  6,  3)
     As you can see, -_ can be used to
     add the second-to-top to the top.
-_   Add second into top.                  (  9,  3)
:    Swap.                                 (  3,  9)
-_   Add second into top.                  ( 12,  9) 
     The last two together form a normal
     "Fibonacci step".
:-_  Fibonacci step.                       ( 21, 12)
:-_  Fibonacci step.                       ( 33, 21)
:-_  Fibonacci step.                       ( 54, 33)
-_   Add second into top.                  ( 87, 33)
:    Swap.                                 ( 33, 87)

Now [ pushes the 33 one stack to the left (moving the tape head along), :^ duplicates it and ] moves one copy back. Together, this just puts a 33 on the stack to the left. And then ]:^ moves the 33 to the right and duplicates it again there. So now we've got:

           v
          33    
... 33 87 33 ...
     0  0  0

Next, it turns out that most of the lower case letters are multiples of 3 and their other factors are 36, 37, 38 which aren't too far away. 99 is also useful, since we'll need both 100 and 101, so we now create a stack with those factors so we can multiply all of them by 3 later.

Stack Cats doesn't have a decrement or increment command. The standard way to increment a value is to combine bitwise NOT (!) and unary negation (-). However, if we know that our value is even we can also increment by toggling the least significant bit with *. Hence, the following !-*!- brings the 33 on top of the stack up to 36. Next, we pull over two 0s from the empty stack to the right, turn use them to get incremented copies of the 36 with >[!_>[!_. The tape now looks like this:

           v
          38    
          37    
          36    
... 33 87 33 ...
     0  0  0

Time for the loop:

>[{]>[^-_-_:]]<<<}

Besides the (...) we've already seen, Stack Cats has another loop, {...}, but its semantics are also a bit unusual. The loop body is always executed at least once. When the loop starts, Stack Cats remembers the value on top of the stack, and then the loop doesn't terminate until that value is seen again at the end of an iteration. That means the easiest way to work through a stack is to put a zero on top and then shift the stack away one value at a time until we hit the zero at the bottom. Here is what the loop does:

>[       Fetch a zero from the empty stack to the right.
{        Loop until zero...
  ]        Push the current factor X to the right.
  >[       Fetch a zero from the stack next to that.
  ^        XOR X into that zero, duplicating X.
  -_-_     Add X into the new value twice, computing 3*X.
  :        Swap 3*X and X.
  ]]<<     Push X two stack to the right and return.
  <        Move back to the stack we're looping over.
}
>        Move onto the stack which now holds the multiples.

This is the new tape:

              v
             99   33    
            108   36    
            111   37    
... 33 87   114   38 ...
     0  0 0   0 0  0

The next bit is [!-:^ which you've seen before: it increments the 99 to 100 and duplicates it on the empty stack next to it. The [[ moves one of those 100s over onto the 33 — we're now starting to build the final stack there. Here's what we've got:

      v
                     33    
               108   36    
    100        111   37    
...  33 87 100 114   38 ...
      0  0   0   0 0  0

It's going to be annoying to fetch all the values from so many stacks away, so here's a new command. \ swaps the current stack with the one of the right, moving the tape head along. So the \\ now brings the output stack closer to the useful values:

             v
                     33    
               108   36    
           100 111   37    
... 87 100  33 114   38 ...
     0   0   0   0 0  0

Next, there's >]:^ which moves the 108 onto the empty stack to duplicate it. [[>:[ moves one of them and the 114 onto the output stack. >:^[ duplicates the 111 and moves one copy onto the output stack. Then we fetch the 87 with <<]], and move the stack two positions further with another \\. We've now got World!:

                  v
                 87       
                111       
                114 33    
                108 36    
                100 37    
... 100 111 108  33 38 ...
      0   0   0   0  0

Time for the space: we've still got that 33 around, so we fetch and decrement it with >[*. We don't need those 36, 37, 38 any more, but we do need a 44. We also still need the 72 for the H later on, and we can actually compute that on the way. All of this is accomplished with the following code:

>+:^:-_]:^[[-_*[>>>[-_[

The new command here is + which swaps the top of the stack with the third value from the top. We use it together with : to put the 36 below the 37 and 38. The ^ replaces the 37 with 37 XOR 38 which is 3. We then add this to 38 with :-_ which gives 41. ]:^ duplicates that on the stack to the right. Then we add a 32 into it with [[-_ and decrement it with * by toggling the least-significant bit. Voilà, there's our 72. We move it to the side with [, go back to the other copy of 41 with >>> and add another 3 into it with [-_ before putting it on the output stack with [. Next, we move the current stack to the left with /. Here's the current tape:

              v
             44           
             32           
             87           
            111           
            114           
            108           
            100  72  3    
... 100 111  33 108 36 ...
      0   0   0   0  0

Now all that's left is collecting a few more values with

<]>+^[>[<<]]*>[

The <] fetches the 111. Then >+^ swaps the 72 with the zero below in order to duplicate the 108. [>[ moves both of those onto the output stack. <<]] fetches the 100 and * turns it into a 101. Finally >[ gets the 72 and we're done.

If you've actually followed all of this you'll noticed that there's tons of stuff we could have done differently which may or may not have saved bytes. There are many more ways to compute the different numbers, maybe XOR would have been useful more often. We could also generate some larger or negative numbers, since the final values are taken modulo 256 before being printed. We could also have made more use of loops, or used the stacks differently. There are also further stack manipulation commands like | to reverse it, X to swap the stacks left and right and = to swap only their top values.

As difficult as it is to program in Stack Cats, it still provides quite a large set of useful commands, which allow for many different approaches to any given problem.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Crazy language, very nice answer. \$\endgroup\$
    – Razetime
    Apr 28, 2018 at 9:27
  • \$\begingroup\$ 94+3 bytes \$\endgroup\$ Jul 8, 2022 at 15:00
26
\$\begingroup\$

Python 3, 22 bytes

print("Hello, World!")

In Python 3, printing is a function and so it requires parenthesis.

A 16 byte solution would be import __hello__, but annoyingly this prints the message without the comma!

\$\endgroup\$
1
  • 4
    \$\begingroup\$ Don't forget wrong caps :P \$\endgroup\$ Jun 20, 2017 at 21:24
26
+500
\$\begingroup\$

Lost, 57 54 45 43 38 37 36 bytes

It's been a long journey here, but we've reached 36 bytes. A 35 seems unlikely.

roW"\\ dl
<@+1(\
lo, /"Hel
%<<<\?<<<

Try it online!

Lost is a 2 dimensional language in which the start location and direction are entirely random. As you might imagine it is rather difficult to write deterministic programs in lost. However the language has a couple of design features that allow for deterministic programs to be written.

This draws on JoKing's 38 byte solution but is significantly more bizarre.

Explanation

This is a bit to messy to explain in a satisfactory way.

As is common with lost there's quite a few different execution paths and the art is tweaking it so every path works out just right.

Going over the program in general would skip a lot of things, but covering every execution path would be long and still seem unsatisfactory.

The best way to understand what is going on is to just try and make your own first. But I will explain how this works in general.

Basic design philosophy

Unlike most 2d programming languages where a flat program is ideal because it avoids extra newlines. In lost squarish programs are ideal. This is because most lost programs employ a collection stream to catch all the wandering ips before they start actually executing.

The flatter it is the longer the stream has to be so that it can occupy every column. This means that a square program minimizes the stream size.

However squares are kind of hard to program with in lost. And there are some losses when trying to split linear logic onto several lines. Earlier versions of this were flatter for this reason. But this has managed to get pretty square.

The stream

The bottom row is a collection stream. Pretty common for lost programs. Regardless of where it initially starts the ip will eventually wander into the stream and start normal execution.

This is mostly just <. These act as hard redirects and are what trap the ip. There are three special things here %, \ and ?. The \ is the exit. It will deflect the pointer up and start our regular execution. But since our normal execution expects a clean stack, we first need to clean up.

? pops a value off the top of the stack and jumps if it's not zero. Since we can't push a zero this will jump until the stack is empty. Since it's placed in front of the exit this means we are stuck in the stream until the stack is cleaned.

One issue is that ? is not a hard redirect so if the ip starts in its column it needs to end up in the stream some other way. This was actually a significant hurdle in making the program work, but there are redirects in \ and / which just barely work out so it always ends up in the stream.

Then we also have %. This turns the safety off so we can exit the program. Since we need to do that eventually it's placed here. Once again, it's not a redirect so it needs to be in a column with another redirect. There is a < two rows above and that will eventually push the ip into the stream so that is covered.

Hello, /

Once we exit the stream we enter the first row. The first row wants to push the string Hello, . But we also want to save on quotation marks. In lost we can potentially start and end a string with the same quotation mark, it just needs to start the string and then wrap around again to get back to it. This will push everything on the line apart from the quote as a string. This includes of course our entrance and exit, here a single /. So we are going to end up with a slightly wrong string of Hello, /. But as we deflect up we hit the ( which ditches the final character. This ( is doing double duty and we will reuse it again in a bit.

World \

Once again we use a similar trick to push the second string we want, except this one is even wonkier. We have three extra characters and are missing the ! still.

Since ! is such a painful character to deal with we want to avoid it altogether. It's an unconditional jump so it really messes with whatever we want to do. Instead we push a space which is one less than a ! so we can increment it later.

That means that we spend 3 bytes to make !. That's how awful it is to have a ! in your lost program.

As to why we have \\ it's a little more esoteric. Obviously we need a entrance and an exit on the line, but last time they were the same character, why do we have them separate this time?

The thing is that if both lines have the same character to enter and exit then they would have to be in the same column. Which would mean that we would have to end up right back in the stream where we started dooming us to an infinite loop. So one of them has to have them separate so that we can finish in a different column than we started. Here we are finishing in the ?'s column. ? is not a hard redirect so we can escape the stream. Plus ? also gets rid of a character for us, just what we wanted to do! But wait ? also skips over the " which would have been a big issue otherwise.1

The ? is doing a lot of work for this program.

Clean up

After the ? removes the first extra character, we land on the mirror \ which deflects us to the left. And at this point we run right back into the ( from earlier. This gets rid of our second extra character. Now all that's left is to turn the space into a ! and exit and that's what we do. We push 1, add it to the space and exit at @.


1: You might ask why we can't just move the " somewhere else. The issue is that it can only be in one of two places on the left of the / or on the right. But it also can't be in the same column as the other " otherwise they form a closed string and we get a nasty infinite loop. So we end up having to put the " right there.

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

Common Intermediate Language, 126 123 bytes

.assembly H{}.method static void M(){.entrypoint
ldstr"Hello, World!"
call void[mscorlib]System.Console::Write(string)
ret}

With proper indentation:

.assembly H {}
.method static void M()
{
    .entrypoint
    ldstr "Hello, World!"
    call void[mscorlib] System.Console::Write(string)
    ret
}
\$\endgroup\$
1
  • \$\begingroup\$ You can save 2 bytes by removing unneccesary newlines (at least in Mono) \$\endgroup\$
    – ASCII-only
    Apr 20, 2018 at 1:24
23
\$\begingroup\$

Javascript (ES6), 20 bytes

alert`Hello, World!`

Javascript ES6 features are awesome when it comes to code golf!

Here, the use of templates allows for a two byte savings by removing parentheses.

How it works

This syntax is known as tagged templates, and it is not the same as merely calling a function with a single string as a parameter, as I initially thought. The function, in this case alert, is called with an array of the string portions of the template and an array of the inserted values. Since there were no inserted values and only a single string portion of the template, alert is called with the array ["Hello, World!"] as its sole (defined) parameter. alert displays this, conveniently, as Hello, World!

Try replacing alert with console.log, and it won't work! You'll get Array [ "Hello, World!" ] instead, since the console doesn't follow the same display rules as alert.

\$\endgroup\$
6
  • \$\begingroup\$ wait, but alert does not print to STDOUT? \$\endgroup\$
    – an earwig
    Aug 30, 2015 at 23:38
  • 5
    \$\begingroup\$ @James_Parsons Since JavaScript doesn't really have a traditional STDOUT, alert is typically considered acceptable. \$\endgroup\$
    – jrich
    Aug 30, 2015 at 23:41
  • 1
    \$\begingroup\$ @James_Parsons No problem. Welcome to PPCG! \$\endgroup\$
    – jrich
    Aug 30, 2015 at 23:50
  • 7
    \$\begingroup\$ console.log("Hello, World!") (28 bytes) outputs to STDOUT if run in node. \$\endgroup\$
    – jib
    Sep 5, 2015 at 19:20
  • 4
    \$\begingroup\$ You may use Javascript Shell and change alert to print which will print to STDOUT. \$\endgroup\$
    – tsh
    Sep 8, 2015 at 6:27
22
\$\begingroup\$

Hot Soup Processor, 17 bytes

mes"Hello, World!

This one's pretty straightforward, but I'm not aware of any other language which can use mes ("message") to print. The language itself is actually of Japanese origin, as one can tell from their website.

Apparently the closing quote isn't necessary (as of ver 3.4a), which is unusual for a non-esolang.

\$\endgroup\$
1
  • 11
    \$\begingroup\$ "HSP is a development language of the interpreter type. The world can be constructed by expanding the wing of the creation." Did you expand the wing of the creation? \$\endgroup\$
    – 2xsaiko
    Jan 29, 2017 at 21:15
20
\$\begingroup\$

Wordy, 1666 bytes

xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx x x x x x x x.xxx xxx xxx x x.xx x.x x x x x x x x x x x x x x x x.xxx xxx xxx x x x x x x x.xxx x x.xxx xxx xxx x x x x.xxx xxx x x x.xxx xxx xxx x x.xx x.x x x x.xx x.x x x x x x x x.xxx xxx xxx x x x x x x x.xxx x x.xxx xxx xxx x x x x.xxx xxx x x x.xxx xxx xxx x x.xx x.x x x x x x.xx x.x x x x x.xxx xxx xxx x x x x x x x.xxx x x.xxx xxx xxx x x x x.xxx xxx x x x.xxx xxx xxx x x.xx x.x x x x x x.xx x.x x x x x x x x x x x x.xxx xxx xxx x x x x x x x.xxx x x.xxx xxx xxx x x x x.xxx xxx x x x.xxx xxx xxx x x.xx x.x x x x x x.xx x.x x x x x x x x x x x x.xxx xxx xxx x x x x x x x.xxx x x.xxx xxx xxx x x x x.xxx xxx x x x.xxx xxx xxx x x.xx x.x x x x x x.xx x.x x x x x x x x x x x x x x x.xxx xxx xxx x x x x x x x.xxx x x.xxx xxx xxx x x x x.xxx xxx x x x.xxx xxx xxx x x.xx x.x x.xx x.x x x x x x x x x x x x.xxx xxx xxx x x x x x x x.xxx xxx xxx x x x x.xxx xxx x x x.xxx xxx xxx x x.xx x.x x.xxx xxx xxx x x x x x x x.xxx x x.xxx xxx xxx x x x x.xxx xxx x x x.xxx xxx xxx x x.xx x.x x x x x.xx x.x x x x x x x.xxx xxx xxx x x x x x x x.xxx x x.xxx xxx xxx x x x x.xxx xxx x x x.xxx xxx xxx x x.xx x.x x x x x x.xx x.x x x x x x x x x x x x x x x.xxx xxx xxx x x x x x x x.xxx x x.xxx xxx xxx x x x x.xxx xxx x x x.xxx xxx xxx x x.xx x.x x x x x x x.xx x.x x.xxx xxx xxx x x x x x x x.xxx x x.xxx xxx xxx x x x x.xxx xxx x x x.xxx xxx xxx x x.xx x.x x x x x x.xx x.x x x x x x x x x x x x.xxx xxx xxx x x x x x x x.xxx x x.xxx xxx xxx x x x x.xxx xxx x x x.xxx xxx xxx x x.xx x.x x x x x x.xx x.x x x x.xxx xxx xxx x x x x x x x.xxx x x.xxx xxx xxx x x x x.xxx xxx x x x.xxx xxx xxx x x.xx x.x x.xx x.x.

We can greet the World by executing the following instructions:

ASSIGN NOP LITERAL 16
OUTCHAR ADD MULTIPLY VALUE NOP LITERAL 4 LITERAL 8
OUTCHAR ADD MULTIPLY VALUE NOP LITERAL 6 LITERAL 5
OUTCHAR ADD MULTIPLY VALUE NOP LITERAL 6 LITERAL 12
OUTCHAR ADD MULTIPLY VALUE NOP LITERAL 6 LITERAL 12
OUTCHAR ADD MULTIPLY VALUE NOP LITERAL 6 LITERAL 15
OUTCHAR ADD MULTIPLY VALUE NOP LITERAL 2 LITERAL 12
OUTCHAR MULTIPLY VALUE NOP LITERAL 2
OUTCHAR ADD MULTIPLY VALUE NOP LITERAL 5 LITERAL 7
OUTCHAR ADD MULTIPLY VALUE NOP LITERAL 6 LITERAL 15
OUTCHAR ADD MULTIPLY VALUE NOP LITERAL 7 LITERAL 2
OUTCHAR ADD MULTIPLY VALUE NOP LITERAL 6 LITERAL 12
OUTCHAR ADD MULTIPLY VALUE NOP LITERAL 6 LITERAL 4
OUTCHAR ADD MULTIPLY VALUE NOP LITERAL 2 LITERAL 1

Wordy encodes all instructions as sentences, where the fraction of words that are longer and shorter than the rounded average selects the command.

The shortest sentences I could find for the used instructions are:

ASSIGN xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx x x x x x x x.
VALUE xxx xxx x x x.
ADD xxx x x.
MULTIPLY xxx xxx xxx x x x x.
OUTCHAR xxx xxx xxx x x x x x x x.
NOP xxx xxx xxx x x.
LITERAL xx x.
\$\endgroup\$
20
\$\begingroup\$

IRC, 27 bytes

/nick h
/quit Hello, World!

The esolangs page comes with a really lengthy two-file "Hello, World!" example. It turns out that is completely unnecessary. The main file of an IRC program contains the program name, a list of channels (which are found in separate files and define individual threads) as well a generic error message which is displayed for various errors. However, that error message can be anything and goes to STDOUT. So let's define our error message as Hello, World!. The shortest way to raise an appropriate error is simply not to define any channels. Voilà, almost 800 bytes saved.

\$\endgroup\$
3
  • 7
    \$\begingroup\$ You know some of the weirdest esolangs. \$\endgroup\$ Sep 3, 2015 at 23:47
  • \$\begingroup\$ Does it print to STDERR? \$\endgroup\$
    – minmaxavg
    Jul 1, 2016 at 0:02
  • 1
    \$\begingroup\$ @minmaxavg it's been a while, but since I explicitly mention it in the explanation I'm pretty sure that I checked that the error message goes to STDOUT and not too STDERR. \$\endgroup\$ Jul 1, 2016 at 5:49
19
\$\begingroup\$

Minecraft 1.8.7, 26 + 2 = 28 Blytes

This is using this version of byte counting.

the system

The command block contains the code:

tellraw @a "Hello, World!"

This one doesn't really need an explanation.

\$\endgroup\$
4
  • \$\begingroup\$ Use a button instead on this one. \$\endgroup\$ Nov 13, 2015 at 0:42
  • 2
    \$\begingroup\$ This scoring method is called blytes (blocks + bytes). \$\endgroup\$
    – user48538
    Jan 10, 2016 at 15:45
  • \$\begingroup\$ @zyabin101 I know - I created the term. I hadn't updated it though. :P Thanks. \$\endgroup\$ Jan 10, 2016 at 17:58
  • 28
    \$\begingroup\$ You couldn't have taken a screenshot during the day? \$\endgroup\$
    – mbomb007
    Feb 24, 2016 at 19:57
18
\$\begingroup\$

GOTO++, 31 bytes

s=«Hello, World!»
GOTOPRINT()

This one is actually a bit interesting. There is a more intuitive way to output things in GOTO++, which would be this:

GOTOPRINTDUTEXTE()«Hello, World!»

This is however 35 bytes. GOTOPRINTDUTEXTE outputs its arguments to STDOUT (Du texte means some text in french). Note that the arguments of a function don't necessarily have to be inside the brackets, as long as they are to the right of the left bracket. So GOTOPRINTDUTEXTE()«Hello, World!» is just as valid as GOTOPRINTDUTEXTE(«Hello, World!»)

GOTOPRINT() on the other hand, outputs to STDOUT the very last variable modified by a =.

\$\endgroup\$
18
\$\begingroup\$

Funciton, 212 209 bytes

╔══════════╗
║2388215291╟
║3945970717║
║0943959830║
║0709090713║
║3592077341║
║6068961777║
║8210571695║
║52834632  ║
╚══════════╝

I found that 10 digits per row yielded the least bytes, although there may have been a mistake in my calculations.

\$\endgroup\$
0
18
+500
\$\begingroup\$

Wierd (John's), 432 421 302 289 256 225 197 181 bytes

-*******************           !dlroW ,olleH
 *
 R*   *    *     *
 E*  **    **   *
 T*  **    **  *
 U ***   ***  ****
 R   *  *  *      *
 N  *    *  ********
    *  ****
 0   **

Try it online!

Background

Wierd's workspace determines both code and data. While each character sets the workspace's cell to its code point (missing characters are treated as spaces, which have code point 32), the code is defined by a particle that starts in the upper left corner and moves along a wire. This wire is also defined by the characters: non-spaces form wires, spaces separate these wires. Instructions are encoded into the kind of turns the particle takes.

At the beginning, the upper left corner holds the number 45, which is the x-coordinate of the cell to the right of !dlrow ,olleH. Each loop through the asterisks that form the main wire decrements that coordinate, prints the character, then prints the character it points to. After all 13 characters have been printed, the upper left corner becomes a space, causing the particle to traverse RETURN 0 instead of the main wire. Once 0 is reached, the particle can no longer move; the program ends.

For the first 12 iterations, the particle moves as follows.

<style>body,html,svg{display:block;height:100%;margin:0;padding:0;}</style>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 210 105"><path d="M 20 80 L 20 100" fill="none" stroke="#FFC0C0" stroke-width="3"/><path d="M 20 8.5 L 20 80" fill="none" stroke="#C00000" stroke-width="3"/><path d="M 20 98.5 L 20 101.5" fill="none" stroke="#C00000" stroke-width="3"/><path d="M 180 30 L 200 10 L 199 10" fill="none" stroke="#C0C0C0" stroke-width="3"/><path d="M 200 10 L 10 10 L 30 30 L 30 50 L 40 60 L 60 60 L 70 50 L 70 30 L 60 40 L 60 70 L 50 80 L 50 90 L 60 100 L 70 100 L 80 90 L 110 90 L 90 70 L 100 60 L 120 60 L 130 50 L 130 40 L 120 30 L 120 70 L 130 80 L 200 80 L 180 60 L 150 60 L 180 30" fill="none" stroke="#000000" stroke-width="3"/><path d="M 10 10 L 30 30 L 30 50 L 40 60 L 60 60 L 70 50 L 70 30 L 60 40 L 60 70 L 50 80 L 50 90 L 60 100 L 70 100 L 80 90 L 110 90 L 90 70 L 100 60 L 120 60 L 130 50 L 130 40 L 120 30 L 120 70 L 130 80 L 200 80 L 180 60 L 150 60 L 180 30 L 200 10 Z" fill="none" id="move-loop"/><circle r="4" fill="#00C0C0"><animateMotion dur="10s" repeatCount="indefinite"><mpath xlink:href="#move-loop"/></animateMotion></circle></svg>

However, during the thirteenth and last iteration, the upper left corner if removed, so the particle moves down the red wire instead.

Code

As illustrated in the Stack Snippet, the particle takes the following left turns on the main wire.

  • 315° Subtract. Nothing is done, since the stack is empty.

    This turn, like the other no-ops, is made solely to save space.

  • 45° Push 1. STACK: [1]

  • 45° Push 1. STACK: [1 1]

  • 45° Push 1. STACK: [1 1 1]

  • 45° Push 1. STACK: [1 1 1 1]

  • 135° Pop the stack. Since the popped element is 1, pop two more values (1 1) and push the code point of the character at those coordinates. STACK: [1 n]

    Initially, the character at (1, 1) is -, so n = 45.

  • 45° Push 1. STACK: [1 n 1]

  • 315° Subtract. STACK: [1 (n-1)]

  • 45° Push 1. STACK: [1 (n-1) 1]

  • 45° Push 1. STACK: [1 (n-1) 1 1]

  • 45° Push 1. STACK: [1 (n-1) 1 1 1]

  • 45° Push 1. STACK: [1 (n-1) 1 1 1 1]

  • 315° Subtract. STACK: [1 (n-1) 1 1 0]

  • 135° Pop the stack. Since the popped element is 0, pop two more values (1 1) and store the next value on the stack (n-1) at those coordinates. STACK: [1]

    During the first run, the upper left corner changes from - (45) to , (44).

    During the thirteenth and last run, the upper left corner changes from ! (33) to space (32), essentially cutting the wire.

  • 270° Pop the stack. Since the popped element is 1, continue. STACK: []

  • 315° Subtract. Nothing is done, since the stack is empty.

  • 45° Push 1. STACK: [1]

  • 45° Push 1. STACK: [1 1]

  • 45° Push 1. STACK: [1 1 1]

  • 135° Pop the stack. Since the popped element is 1, pop two more values (1 1) and push the code point of the character at those coordinates. STACK: [(n-1)]

  • 45° Push 1. STACK: [(n-1) 1]

  • 45° Push 1. STACK: [(n-1) 1 1]

  • 135° Pop the stack. Since the popped element is 1, pop two more values (1 (n-1)) and push the code point of the character at those coordinates. STACK: [c]

    During the first run, this retrieves the character at (44, 1), which is H.

  • 45° Push 1.

  • 225° Pop the stack. Since the popped element is 1, pop the next item and print it to STDOUT. STACK: []

  • 180° Jump to the rightmost star on the first line.

  • 135° Get/set. Nothing is done, since the stack is empty.

    After this turn in the upper left corner, the particle starts over.

\$\endgroup\$
1
  • \$\begingroup\$ That is amazing. I couldn't figure out how to exit the loop and settled for doing it the long way - big mistake. \$\endgroup\$ Oct 9, 2017 at 9:39
17
\$\begingroup\$

Zsh, 17 bytes

<<<Hello,\ World!
\$\endgroup\$
17
+100
\$\begingroup\$

Piet, 93 codels

The 1 pixel bitmap of the 31x3 program :

Piet 31x3 - Codel 1[1]

There might be still some room for improvement.
But the Direction Pointer & Codel Chooser are not making things easier.

This is the 12 codel image :

Piet 31x3 - Codel 12[2]

Remarks :

Because of the upper-left black codel, npiet online seems to have a problem with it.
But it works on PietDev.

\$\endgroup\$
4
  • \$\begingroup\$ PietDev should be used with caution because it ignores some specs. The black start codel problem is one of them. The other is wrong behavior for the DIV operation that generates float values although the spec says that all values in Piet are integers. Npiet is a good way to check if a program really works. \$\endgroup\$
    – M L
    Sep 8, 2015 at 17:33
  • 1
    \$\begingroup\$ Yes, I noticed that after I posted this solution. The div problem on PietDev is not a problem if you just use it for output, since that only uses the integer part. And i.m.h.o., I do believe it would be an enrichment to npiet if it allowed to start with black codels till another colour is found. You could write piet programs with a black frame that way. \$\endgroup\$
    – LukStorms
    Sep 9, 2015 at 7:45
  • \$\begingroup\$ I'm awarding the bounty to this submission, despite the black codel. The reuse of 2 and 3-large cells is very nice - I thought I'd try golfing this down a column or two but it's surprisingly hard. Makes me think 87 might be possible though. \$\endgroup\$
    – Sp3000
    Sep 9, 2015 at 7:56
  • \$\begingroup\$ @Sp3000 Thanks for the bounty reward. I've been trying to find a solution without the black codel that's below 30x3. But can't seem to find one. But I still believe there should exist a 29x3 solution. Piet is just a immense pain to golf. It's not just a matter of getting the optimal result from the stack. \$\endgroup\$
    – LukStorms
    Sep 14, 2015 at 21:24
17
\$\begingroup\$

Cheddar, 20 bytes

print"Hello, World!"

Yes!!!!!

I have been waiting for this day a long time. After days of banging my head on my desk trying to get Cheddar to work. I have finally made a Cheddar REPL. The REPL is very alpha, so if you'd like to test it out, ping me in chat @Downgoat

Update: To run simply go to cheddar.vihan.org and follow the download instructions

Update 2: Use the experimental online REPL at: cheddar.vihan.org/repl

\$\endgroup\$
1
  • 4
    \$\begingroup\$ -1 Language name makes me want cheese ;) \$\endgroup\$
    – Beta Decay
    Aug 15, 2016 at 20:22
16
\$\begingroup\$

Piet, 15x15(225) 13x15(195) codels

I think Piet program size is counted by codels. If someone wants to know the size in bytes anyway, I could shrink it down to 495 bytes(15x15 codels) and 476 bytes(13x15 codels) using PNGGauntlet.

Codel size 10 for better visibility.

13x15 version:

Piet "Hello, World!" 13x15

First version (15x15):

Piet "Hello, World!"

I was a bit lazy with this solution. I should be able to golf it down a bit more. This solution fills up the stack with ASCII-32 and reads it out in a loop (ASCII+32).

Output:

D:\codegolf\Piet\npiet-1.3a-win32>npiet "Hello World codegolf.png"
Hello, World!
D:\codegolf\Piet\npiet-1.3a-win32>
\$\endgroup\$
16
\$\begingroup\$

Starry, 191 188 186 182 172 169 bytes

        + + +* +  * + + +* + .* +         + +* * +      +* .  + + . + . +        + +   +* + . +          +   * +* + .         + +  * +* . +*      + * . + .* . . .  + * .

This is almost definitely suboptimal, but Starry golfing is surprisingly difficult, due to the cost of pushing a number being higher than that of performing an operation. Thankfully we can reuse a lot of past computations, due to duplicate letters in the message "Hello, World!".

Starry operators are determined by the number of spaces before one of +*.,`. The relevant ones used are:

Spaces       Char      Operation
-----------------------------------------------------
1            +         Duplicate top of stack
2            +         Swap top 2 stack elements
3            +         Rotate top 3 stack elements
n >= 5       +         Push n-5 to stack
0 mod 5      *         Add
1 mod 5      *         Subtract
2 mod 5      *         Multiply
1 mod 2      .         Output as ASCII

And here is the program broken down:

Line                        Explanation            Stack                 Out
-------------------------------------------------------------------------------------
        + + +* +  * +       Push 3 and 36, dup     [3 36 36]
 + +* + .                   Dup, x2, dup, print    [3 36 36 72]            H
*                           Add                    [3 36 108]              H
 +         + +* * +         Dup, sub 8, dup        [3 36 108 100 100]      H
      +* .                  Add 1, print           [3 36 108 100]          He
  + + .                     Swap, dup, print       [3 36 100 108]          Hel
 + .                        Dup, print             [3 36 100 108]          Hell
 +        + +               Dup, push 3, dup       [3 36 100 108 108 3 3]  Hell
   +* + .                   Rot 3, add, dup, print [3 36 100 108 3 111]    Hello
 +          +   * +* + .    Dup, //5*2, dup, print [3 36 100 108 3 111 44] Hello,
         + +  * +* .        Print 32               [3 36 100 108 3 111 44] Hello, 
 +*      + * .              Double, sub 1, print   [3 36 100 108 3 111]    Hello, W
 + .                        Dup, print             [3 36 100 108 3 111]    Hello, Wo
* .                         Add, print             [3 36 100 108]          Hello, Wor
 . .                        Print, print           [3 36]                  Hello, World
  + * .                     Swap, sub, print       []                      Hello, World!
\$\endgroup\$
16
\$\begingroup\$

FiM++, 88 bytes

Dear Princess Celestia:H.Today I learned:I sang "Hello, World!".Your faithful student,M.

FiM++ is an object-oriented language inspired by My Little Pony: Friendship is Magic. Yeah, right.

Printing "Hello, World!" is fairly straightforward, and there was an example in the interpreter's repository which I used as the basis for the above code. The main golfing steps were figuring out which parts could be shortened or left out and which couldn't... and the fact that I could replace I wrote ... with I sang ....

The interpreter prints a bunch of diagnostic information before running the code, but that does not appear to be part of the actual language specification.

\$\endgroup\$
16
\$\begingroup\$

Brain-Flak, 142 140 136 bytes

((((((((((((()()){}){}){}){}()))){}{}())([][]){})[][])[[]]())[((()[]){}){}])([()[]](([]([](((([][]))([]{}{})))[]{}[])[[]])))(([][][]){})

Try it online!

In the time since this answer was originally posted (original code below) Jo-King wrote a computer program that was able to find a shorter Hello World. After careful examination I was able to shave 2 bytes off of the computers program. Jo-King then improved his program to outgolf me. But I'm not beaten that easily and I've golfed it back, taking another 2 bytes off the machine. I won't explain the entire program because I don't understand it and Jo-King has already done that in the linked post but I will explain my golf. My golf pertains the part that looks like:

([][]([](()[][]){}))

From here I noticed that [][] was repeated twice. I thought it might be a good idea to cache this value instead:

(([][])([]((){}){}))

However because there is a [] between the push and the pop this is off by one. We can fix this by moving the () outside of the double to decrease by 1.

(([][])([]()({}){}))

At this point we can increase the [] in between by another one by pushing [][] twice instead of once

((([][]))([]{}{}))

This saves 2 bytes.

A man ain't nothin' but a man, And before I'll let your [metagolfer] beat me down, I'll die with the [keyboard] in my hand.

Original code, 148 bytes

Now that DJMcMayhem's answer has depreciated. I made a replacement (and even removed a few bytes).

(((((((((((()()()()){}){}){}()))){}{}())[][][][])[][])[[]]())[[][][][][]]())([([]([])[][]{})]()()()([[]](([()()()]([([][][])](((({}()){}))){}{})))))

Try it Online!

Explanation

This explanation was create by Poke

(
 (
  (
   (
    (
     (
      (
       (
        (
         (
          (()()()()){} Add 8... to 0
         ){} Double to 16
        ){}() Double and add 1 to 33 which is !
       ) Push the ! to save it for the end
      ) Push an extra 33 to help add to get to the first letter
     ){}{}() Triple the 33 and add 1 for 100 which is d
    )[][][][] Push the d to save it for the end. Add height-2, 4 times for 108 which is l
   )[][] Push the l to save for the end then add height-3, 2 times = 114 which is r
  )[[]]() Push the r to save for the end then subtract height-4 and add 1 = 111 which is o
 )[[][][][][]]() Push the o to save for the end then subtract height-5 5 times and add 1 = 87 which is W
) Push W to save for the end
At this point the stack contains "!dlroW". 87 Floating
( We're now a level lower so we start at 0 for the math here.
 [([]([])[][]{})]()()() Push 6+6+7+7+6=32 which is the space, then negate it + 3 = -29 Floating
 (
  [[]] negate height-7 = -7 Floating
  (
   (
    [()()()] -3 Floating
    (
     [([][][])] Push 3*height-7 = 21 and negate it = -21 Floating
     (
      (
       (
        ({}()){} 21+1+22 = 44 which is the comma
       ) Push the , to save for the end
      ) Push another 44
     ){}{} 44+44+44 = 132
    ) Push 132 plus the -21 we left floating earlier = 111 which is o
   ) Push 111 plus the -3 we left floating earlier = 108 which is l
  ) Push another l
 ) Push 111 plus the -7 we left floating earlier = 101 which is e
) Push 101 plus the -29 we left floating earlier = 72 which is H
At this point the stack contains "!dlroW ,olleH" and our accumulator is at 159 which doesn't get used.
\$\endgroup\$
1
  • 4
    \$\begingroup\$ Here's an explanation... It's not great. I don't know the proper vernacular for this language. Try it online! \$\endgroup\$
    – Poke
    Apr 12, 2017 at 14:37
15
\$\begingroup\$

><>, 23 bytes

"!dlroW ,olleH"l?!;oe0.

><>, or "Fish", is a 2D stack-based language like Befunge. Here's the breakdown:

[setup]

"                    Start string parsing
!dlroW ,olleH        Push each of these chars one-by-one onto the stack
"                    Stop string parsing

[main loop]

l?!;                 If the length of the stack is 0, halt
o                    Otherwise, output the top of the stack as char
e0.                  Jump back to just before the l
\$\endgroup\$
15
\$\begingroup\$

Alchemy, 1013 bytes

Fixate 1 dr Eulerius (1 oz Alkahest): Bius
Fixate 1 dr Periphius (1 oz Alkahest): Cius
Fuse 1 dr Bius, 1 dr Bius, 1 dr Cius, 1 dr Cius (4 oz Alkahest): Zius
Fuse 1 dr Zius, 1 dr Bius (2 oz Alkahest): Hium
Fuse 1 dr Cius, 1 dr Periphius, 1 dr Periphius (3 oz Alkahest): Dius
Project 1 oz Hium, 1 oz Dius (3 oz Alkahest): Eium
Fuse 1 dr Zius, 1 dr Cius (2 oz Alkahest): Lium
Project 1 oz Lium, 1 dr Cius (3 oz Alkahest): Oium
Fuse 1 dr Bius, 1 dr Cius, 1 dr Eulerius, 1 dr Eulerius (4 oz Alkahest): Cium
Ferment 1 dr Zius, 1 dr Periphius (2 oz Alkahest): Sium
Project 1 dr Cium, 1 dr Cium (4 oz Alkahest): Wium
Ferment 1 dr Wium, 1 dr Aquaphidium (4 oz Alkahest): Wium
Project 1 dr Oium, 1 dr Cius (3 oz Alkahest): Rium
Ferment 1 dr Eium, 1 dr Aquasoothius (3 oz Alkahest): Dium
Project 1 dr Sium, 1 dr Aquasoothius (3 oz Alkahest): Xium
Multiply 1 oz Hium, 1 oz Eium, 1 oz Lium, 1 oz Lium, 1 oz Oium, 1 oz Cium, 1 oz Sium, 1 oz Wium, 1 oz Oium, 1 oz Rium, 1 oz Lium, 1 oz Dium, 1 oz Xium (26 oz Alkahest): Scribius

This is one weird language. The above is probably not entirely optimal, but I also don't think that the optimal solution will be significantly shorter (I did try to obtain the numbers as efficiently as possible locally). Also, the language spec seems to imply that the amounts of the reagents should actually match up (when multiplied by their "substance numbers" which are the sums of their ASCII values...), but the only interpreter I could find doesn't seem to be checking that.

In fact, the interpreter had a memory corruption bug which I had to fix to run the above code.

Some explanation would probably be helpful. Let e, π, and φ have their usual meanings. Then the above code translates roughly to the following pseudocode:

b = floor(e)         // 2
c = floor(π)         // 3
z = b * b * c * c    // 36
H = z * b            // 72
d = c * π * π        // 29.6088
E = H + d            // 101.6088
L = z * c            // 108
O = L + c            // 111
C = 2 * 3 * e * e    // 44.3343
S = z - π            // 32.8584
W = C + C            // 88.6686
W = W - φ            // 87.0506
R = O + c            // 114
D = E - 1            // 100
X = S + 1            // 33
Print( H, E, L, L, O, C, S, W, O, R, L, D, X )
\$\endgroup\$
1
2
3 4 5
33

Your Answer

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

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