"Hello, World!"

  • 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() {
    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+/);
    answers_hash[id] = a;
    if (!data.has_more) more_answers = false;
    comment_page = 1;

    function getComments() {
    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)
    if (data.has_more) getComments();
    else if (more_answers) getAnswers();
    else process();


    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) {
    body = '<h1>' + c.body.replace(OVERRIDE_REG, '') + '</h1>';

    var match = body.match(SCORE_REG);
    if (match)
    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;

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

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


    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">
    <tbody id="languages">

    <div id="answer-list">
    <table class="answer-list">
    <tbody id="answers">

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

    Must the language meet our usual requirements for what a programming language is, or are we operating by kolmogorov complexity rules?

    @isaacg No it doesn't. I think there would be some interesting languages where it's not obvious whether primality testing is possible.

    If the same program, such as `"Hello, World!"`, is the shortest in many different and unrelated languages, should it be posted separately?

    @aditsu Yes, because there's no way anyone to find to the shortest version in an answer of an unrelated language.

    Is there a way to make the snippet runnable without having to click "Show code snippet" first?

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

    @MartinBüttner About minifying the code, why not minify it with a repeatable minification program, and then include a link to the pre-minified script?

    Or the non-minified code could be included in the post in a html comment.

    Would it be alright for me to answer in my custom esolang that I have not published yet, but have been planning for a few weeks? (I'll only post after I publish it, of course.) It doesn't have any built-ins for "Hello, World!"; the answer will still output it "the hard way".

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

    @MartinBüttner Oh, right, didn't catch that the first time. Thanks!

    This solution of mine causes graphical glitches in the scoreboard when the score is added.

    @LegionMammal978 I'll see if I can do something about it later, but does it really make sense to add a separate Unary solution, if the optimal solution will always be the translation of the optimal BF solution? I think this falls under the "trivial derivatives" bullet point in the spec.

    Can you assume that there is no input?

    @LegionMammal978 Yes.

    _*Each submission must be a full program.*_ ... pleace enforce this! Obeying this rule creates a handicap as long as solutions ignoring it are tolerated.

    @yeti are they? Could you point me to any that ignore it? I try to keep an eye on all new submissions but at almost 350 answers, occasionally one might slip through the cracks.

    @MartinBüttner What if the language doesn't have a conventional STDOUT? My preferred language, Mathcad, doesn't have a STDOUT. It is effectively a virtual whiteboard (or sheets of paper) that allows the user to mix text and mathematical expressions, plus graphics, on the "page". Even simply evaluating an expression using the "=" operator causes the output to appear on the "page" (eg, typing "2+2=" results in "2+2=4" appearing).

    @StuartBruff might be worth asking that on meta, but if stuff appearing on the page is the only way to produce output then I'd call that the closest alternative to STDOUT.

    @MartinBüttner Thanks, Mathcad answer added.

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

  • Stuck, 0 bytes

    Well, can't get shorter than that...
    An empty program will output Hello, World! in Stuck.

    Damn, i was 20 minutes late! :P

    Noooo c'mon fastest gun in the west effect ;)

    Wow ! Thats fascinating :)

    @Shebang Did you create the language just so you can win puzzles like this?

    @Zuck Well yes, Stuck was made for code-golfing, just like CJam/GolfScript/Pyth. The `Hello, World!` thing was just something I had put in as a placeholder early in development. I didn't intend to leave it in so long, just never got around to removing it.

    I've been trying to come up with a shorter solution, but I'm stuck.

    @Shebang 20 minutes, 150+ upvotes. I kinda feel for you

    -1 bytes in jQuery. Have you tried jQuery?

    @Cyoce How can you have negative quantity?

    @10Replies how can this be, show me?

    Also a polyglot with Bound

    @mekb it's a joke

    @Makonede i know lol (imagine commenting on a super old post and you get a response 2 days after lol)

    @mekb haha yep, i honestly wasn't expecting a response xD

    awh i have more rep on codegolf than stackoverflow lmao

  • PHP, 13 bytes

    Hello, World!

    Yes. It works.

    Try it online!

    As usual with PHP, you always wonder how it can work

    It works, of course, because there's no `

    That means this is just an HTML answer...

    @Nelson no, it doesn't. PHP doesn't necessarily have to be placed in to HTML. And plus, HTML doesn't print to the stdout

    This is the most hilarious answer ever

    @Fatalize Let's work on giving the anti-PHP comment more votes than the PHP answer. We're getting closer...

    @georgeniux html is just markup. If you want a "program" to "run" html you could do alias html=cat and then it outputs to stdout.

    This is an html answer. it's lame to call it php. You'd get the same thing for the same reason in any template language. It's pugs/mason/template toolkit too!

    trying this out via CLI with `php -r "Hello, World!"` results in an error.

    @YoYoYonnY Success has been achieved :P

    See, when I did this, I got a -1, not +173

    @StanStrum Because then it would be a duplicate of this answer

    @MilkyWay90 I vaguely remember the context of this (being about 2 years ago) but I had written a similar answer to a similar question and received a -1. Not on this question, being not a duplicate.

    Well, it seems to work at least at ideone.com, outputting `Hello, World!` to stdout.

    Contrary to several comments here, there is no HTML in this answer, and no "HTML mode" in PHP. This is source code, executable by PHP, which is precisely equivalent to ``, because the language's author decided that it should be. From a compiler's point of view, it's just as accurate to say that `` then being an "echo another string literal" marker.

  • Brainfuck, 78 bytes

    Open-ended bounty: If anyone can improve this score, I will pass the bounty (+500) on to them.
    @KSab has found a 76 72 byte solution!


    Try it online!

    The first 28 bytes --<-<<+[+[<+>--->->->-<<<]>] initialize the tape with the following recurrence relation (mod 256):

    fn = 171·(-fn-1 - fn-2 - fn-3 + 1), with f0 = 57, f1 = 123, and f2 = 167.

    The factor of 171 arises because 3-1 ≡ 171 (mod 256). When the current value is translated one cell back (via <+>---) subtracting 3 each time effectively multiplies the value by 171.

    At n = 220 the value to be translated is zero, and the iteration stops. The ten bytes preceding the stop point are the following:

    [130, 7, 43, 111, 32, 109, 87, 95, 74, 0]

    This contains all of the components necessary to produce Hello, World!, in hunt-and-peck fashion, with minor adjustments.

    I've also found an alternative 78 byte solution:


    Try it online!

    I consider this one to be better than the first for several reasons: it uses less cells left of home, it modifies less cells in total, and terminates more quickly.

    More Detail

    Recurrence relations have surprisingly terse representations in Brainfuck. The general layout is the following:


    which represents:

    fn = c1·fn-1 + c2·fn-2 + c3·fn-3 + ... + k


    f0 = s1, f1 = s2 + c1·f0 + k, f2 = s3 + c2·f0 + c1·f1 + k, etc.

    Additionally, the <+> may be changed to multiply the range by a constant without affecting the stop point, and a term may be added before the >{k} to shift the range by a constant, again without affecting the stop point.

    Other Examples

    Fibonacci Sequence


    N-gonal Numbers

    Triangular Numbers


    Defined as fn = 2·fn-1 - fn-2 + 1, with f0 = 0, f1 = 1.

    Square Numbers


    Pentagonal Numbers



    BF Crunch

    I've published the code I used to find some of this solutions on github. Requires .NET 4.0 or higher.

    Usage: bfcrunch [--options] text [limit]

    text The text to produce.
    limit The maximum BF program length to search for. If zero, the length of the
    shortest program found so far will be used (-r). Default = 0

    -i, --max-init=# The maximum length of the initialization segment. If excluded, the
    program will run indefinitely.
    -I, --min-init=# The minimum length of the initialization segment. Default = 14
    -t, --max-tape=# The maximum tape size to consider. Programs that utilize more tape than
    this will be ignored. Default = 1250
    -T, --min-tape=# The minimum tape size to consider. Programs that utilize less tape than
    this will be ignored. Default = 1
    -r, --rolling-limit
    If set, the limit will be adjusted whenever a shorter program is found.
    -?, --help Display this help text.

    Output is given in three lines:

    1. Total length of the program found, and the initialization segment.

    2. Path taken, starting with the current tape pointer. Each node corresponds to one character of output, represented as (pointer, cost).

    3. Utilized tape segment.

    For example, the final result for bfcrunch "hello world" 70 -r -i23 is:

    64: ++++[[<+>->+++++>+<<]>]
    49, (45, 5), (44, 3), (45, 6), (45, 1), (45, 4), (42, 4), (43, 5), (45, 3), (45, 4), (46, 2), (44, 4)
    32, 116, 100, 104, 108, 132, 0, 0, 132, 0

    This corresponds to the full program:


    Other Records

    Hello, World!

    Wrapping, 78 bytes:




    Non-wrapping, 87 bytes (previously 92 bytes (mitchs)):


    Hello, world!

    Wrapping, 80 bytes:


    Non-wrapping, 81 bytes (previously 92 bytes (hirose)):


    hello, world!

    Wrapping, 74 bytes:


    Non-wrapping, 84 bytes:


    Esolangs Version

    Hello World!\n

    Wrapping, 76 bytes:


    This uses one cell left of home, and thus would be considered 77.

    Non-wrapping, 83 bytes:


    Rdebath approved. profilebf output:

    Hello World!
    Program size 83
    Final tape contents:
    : 0 0 73 101 109 115 112 88 33 10 0
    Tape pointer maximum 10
    Hard wrapping would occur for unsigned cells.
    Counts: +: 720 -: 79 >: 221 <: 212
    Counts: [: 9 ]: 84 .: 13 ,: 0
    Total: 1338

    inversed.ru (Peter Karpov)

    Hello World!

    Wrapping, 70 bytes (previously 781):


    Non-wrapping, 77 bytes (previously 89?):


    The author claims that the shortest hand-coded "Hello World!" is 89 bytes, but provides no reference. I hereby claim the record for this, too.

    hello world!

    Wrapping, 65 bytes (previously 66 bytes):


    This is actually hand-coded as well (the best I could find by crunching is 68 bytes). The first cell is initialized to 259 (3), and decremented by 7 each iteration, looping 37 times. The next cell is decremented by 6, resulting in 256 - 6·37 = 34. The rest of the cells are decremented by 4 each time, adding one cell each iteration, with each new cell inialized to 252 (-4). The result is the following:

    [  3,   0,   0,   0,   0,   0,   0, ...]
    [252, 250, 248, 0, 0, 0, 0, ...]
    [245, 244, 244, 248, 0, 0, 0, ...]
    [238, 238, 240, 244, 248, 0, 0, ...]
    [231, 232, 236, 240, 244, 248, 0, ...]
    [224, 226, 232, 236, 240, 244, 248, ...]
    [ 35, 64, 124, 128, 132, 136, 140, ...]
    [ 28, 58, 120, 124, 128, 132, 136, ...]
    [ 21, 52, 116, 120, 124, 128, 132, ...]
    [ 14, 46, 112, 116, 120, 124, 128, ...]
    [ 7, 40, 108, 112, 116, 120, 124, ...]
    [ 0, 34, 104, 108, 112, 116, 120, ...]

    1 The solution given (79 bytes) can be trivially reduced by one:


    This is great! Got the small-w version down to 82 :) `+>---->->+++>++>->+[++++++++[>++++++++>>+++++<<<-]<]>>.+>++>.>..+>>.+>-->--[>-.<<]`

    This is nuts. One of you should submit the 82-byte version to anarchy golf.

    The best Java solution to this question is 76 bytes. Only 9 more bytes to go to prove Java developers should switch to Brainfuck.

    @LevelRiverSt The small-letters one is 2 bytes shorter than Java. The endtimes have come.

    Awesome work Primo! @CᴏɴᴏʀO'Bʀɪᴇɴ the edit was on Jan 29, nearly 4 weeks after my previous comment, and the world has not ended. Remember the fuss about Millenium Bug back in late 1999, and nothing happened in 2000? Just like then, the world remains the same, and developers are STILL using Java. WTF!

    "Only 9 more bytes to go to prove Java developers should switch to Brainfuck." `interface a{static void main(String[]A){System.out.print("No!");}}`

    Sorry to break dreams, but Java got really ahead...

    @dorukayhan `main(){puts("Hahaha");}`

    @OlivierGrégoire that's a really outdated version of Java though, who uses that in production anymore :P

    @ASCII-only I know a few companies...

  • ArnoldC, 71 bytes

    TALK TO THE HAND "Hello, World!"

    Just for lols...

    Try it online!

    Worked for me. Try putting it's showtime on the first line and you have been terminated on the last line

    I really need to learn how to use this language.

    Doesn't a space and a newline take up the same number of bytes? And technically, `IT'S SHOWTIME` and `TALK TO THE HAND` should be on the first and last lines.

    @wizzwizz4 It worked for me like this :D

    @AlCode But it's more correct and takes up the same number of bytes and there is more compatibility and it looks nicer and why am I making a fuss this is a code golf challenge on PPCG and it is a surprise that your code is readable and well done you made a well golfed answer that was readable and +1.

    @wizzwizz4 thank your very much, I try to be as professional as possible with ArnoldC the language of the future!

    The string should be `Hello, World!`

  • Seed, 6016 4234 4203 bytes

    20 854872453003476740699221564322673731945828554947586276010721089172712854441839676581917455319274850944955030258951339804246125714958815519550291630078076933441706558540342671975808828643360922071900333028778314875248417953197990571991784126564752005357199892690656368640420204822142316716413192024742766282266114842280731756458212469988291309261528542889299297601723286769284159107438930448971911102280330101196758384815655479640836157495863547199726234352265518586460633795171196315255736880028338460236768181141732764911402112878175632130129852788301009582463631290071329795384336617491655825493435803011947670180368458659271192428341035912236946048939139042310380278430049252171822721598175984923434205610723412240162418996808671543770639111617709604242882388664919702606792443015941265168129550718541372361144081848761690730764968771245566074501485020726368378675085908872608679630368472956274468410052703615106090238423979678950131481176272880569100533049143775921798055136871254424261001442543122666701145111965968366507060931708140304772342855064834334129143038575569044150428480231956133612367393837580345180691911525531699573096952433882387811884727975431823620782822755161559988205401134640722220804177812794328129589949692446031008866917615922944976151073653201316255518389496411696741029209242119521978920200314572718584995265523235225587228975886710511855501710470163649632761488899317729943053884132314641377747687975638119132094777769497069556255954031537245957811105217875011509899497752696062748928963281605780942517262774976217663461063680912331030221981433051827519906741285738915397005702326447635845195923640649166530310494885569783989508000344280715868581532826832242144647203531393142251025361866506821695860883605004105862208004440476654027574832078603305884731766236740069411566854496824754558761536201352147934963241039597221404341132342297870517293237489233057335406510464277610336142382379135365550299895416613763920950687921780736585299310706573253951966294045814905727514141733220565108490291792987304210662448111170752411153136765318541264632854767660676223663544921028492602135525959428999005153729028491208277493747933069008199074925710651071766675870081314909460661981433426167330215548196538791617762566403934129026219366764038390123622134753742930729751695349588862441999672547791630729398908283091638866715502470152431589429837867944760012419885615525232399584379209285060418518373512154801760060312646951597932345591416241634668119867158079946680321131213357200382937049485606706114467095019612014749723443159443363662563254359712162432143334612180576945072905749883870150120687696027984317320305291407322779803583395375616762530641605634303022155218169343410634115050596030685041633824154135240376022159918501703555881290333205131375705406831260759974112248490451605422031345264183102048614606636275942039438138959188478277971377232005036301145411215067576576667743288951344423152531417111852584846747428443123174595987315325304540564683047858415059703724263652136185848573853965992798725654430360647040362341567082462847275277303225817689141675391972818943419663764371222973269129542760661385278009266471167618553065823580448848795731295589715602705860758954890415040763604082216728159486423396295188510311881004469017351709060492844398219491990895826924575575549615118821417543037296628825303328056839433114519945243963946989899508355224823109677424196639930153649890175062456649384605721510239142861693109687536600667811037619175927995599388547421689316110236566026931360164495251160997857372500940728057700473763884480342708897319990346726967220426504612260565552531158509215849649565188655100774748485416791517853427613458459889062942881409801879085054494129489535044719193283409051007851153504224002807392992520076910314763705776345053922387355156981872691537772657428096384535960466923475731297217863371650154415835785630016335858514130863258775100537612371430357576913148500310344278511588325852376442503898849856566716198848377379400158332792027967216204970114516984638014129252882482309132898416484525230488700253065644547798869056136044415413099076332059572505138116227535024546891015836838323022822272664771489129085797354578016574544759934333471793

    Try it online!
    The resulting Befunge-98 program (based on this) is

    "9!dlroW ,olleH"ck,@

    Very impressive! According to the spec and reference implementation on esolangs, the 21 should come first though. As is, this tries to generate a Befunge program with 10⁶⁰¹¹ characters.

    @Dennis Oops LOL.

    Wow! How did you find this?

    @ETHproductions I'll probably want to see if I can make the seed shorter than the length of the PRNG's state vector before I do an explanation.

    _What_. That's insane.


    Did you reverse engineer the mersenne twister? And does this have any security implications?

    Given the size of the number and the fact that feersum was able to golf it down, this is almost certainly an abuse of some mechanic about the mersenne twister, but I'll leave feersum to answer the second question.

    Inquiring minds want to know !

    @feersum We demand to know.

    I was actually about to start work on this lol. The MT is entirely linear. It isn't a Cryptographically Secure PRNG, so it is possible to reverse a desired output back to a seed.

    @Liam If you're still interested in the problem, you could try to crack this.

    I'll give you another +500 for a detailed (theoretical) explanation.

    I've read **this** before, but his method needs 624 samples. I'd like to see how feersum did it as well.

    Is it possible to output a quote? It doesn't seem easy as there is a second loop in `init_by_array`.

    I think I'll pitch in +250 along with @primo

    @ConorO'Brien As will I

    Trying to golf this... Estimated time: 511576891064129323642698858496 days, 18 hours

    My solution is 6014 bytes. :( This was a fun challenge to attempt. For anyone interested in how he managed to get this answer, take a look at Python's source code on GitHub. You'll be interested in _randommodule.c, random(), and init_by_array()

    Explanation plz!!

    Please. _How did you do this?!?!?!?!?!_

    2018. Still no explanation. I'm beginning to lose hope :(

    Essentially he took advantage of the fact that the Mersenne Twister is not a one-way random number generator (this is part of why it is not cryptographically secure). There are no security implications of this answer. More detailed: You can generate 624 integers to create the state of the Mersenne Twister, then generate the seed from that. He presumably kept generating integers until he found the string he was looking for (in this case the Befunge code above, then generated the seed for the 624 integers before it, which is posted above. Repeated searches is how he reduced the seed.

    @SpenserTruex This is not a good description of my algorithm.

    @feersum Then why not give one? ;)

  • Mornington Crescent, 3614 3568 bytes

    Thanks to NieDzejkob for saving 46 bytes by using shorter line names.

    Take Northern Line to Hendon Central
    Take Northern Line to Bank
    Take Circle Line to Bank
    Take District Line to Gunnersbury
    Take District Line to Victoria
    Take Victoria Line to Seven Sisters
    Take Victoria Line to Victoria
    Take Circle Line to Victoria
    Take Circle Line to Bank
    Take Circle Line to Hammersmith
    Take Circle Line to Cannon Street
    Take Circle Line to Hammersmith
    Take Circle Line to Cannon Street
    Take Circle Line to Bank
    Take Circle Line to Hammersmith
    Take District Line to Upminster
    Take District Line to Hammersmith
    Take District Line to Upminster
    Take District Line to Gunnersbury
    Take District Line to Paddington
    Take District Line to Acton Town
    Take Piccadilly Line to Holloway Road
    Take Piccadilly Line to Acton Town
    Take District Line to Acton Town
    Take District Line to Gunnersbury
    Take District Line to Hammersmith
    Take Circle Line to Notting Hill Gate
    Take District Line to Upminster
    Take District Line to Notting Hill Gate
    Take District Line to Upminster
    Take District Line to Victoria
    Take Victoria Line to Seven Sisters
    Take Victoria Line to Victoria
    Take Circle Line to Victoria
    Take District Line to Upminster
    Take District Line to Gunnersbury
    Take District Line to Mile End
    Take District Line to Hammersmith
    Take Circle Line to Notting Hill Gate
    Take District Line to Upminster
    Take District Line to Upminster
    Take District Line to Mile End
    Take District Line to Paddington
    Take Circle Line to Paddington
    Take District Line to Acton Town
    Take Piccadilly Line to Heathrow Terminals 1, 2, 3
    Take Piccadilly Line to Holborn
    Take Central Line to Holborn
    Take Central Line to Mile End
    Take District Line to Upminster
    Take District Line to Hammersmith
    Take District Line to Upminster
    Take District Line to Barking
    Take District Line to Hammersmith
    Take District Line to Upminster
    Take District Line to Gunnersbury
    Take District Line to Barking
    Take District Line to Gunnersbury
    Take District Line to Paddington
    Take Circle Line to Paddington
    Take Circle Line to Wood Lane
    Take Circle Line to Victoria
    Take Circle Line to Victoria
    Take District Line to Gunnersbury
    Take District Line to Hammersmith
    Take District Line to Upminster
    Take District Line to Gunnersbury
    Take District Line to Paddington
    Take Circle Line to Paddington
    Take District Line to Mile End
    Take Central Line to Fairlop
    Take Central Line to Mile End
    Take District Line to Barking
    Take District Line to Upminster
    Take District Line to Upminster
    Take District Line to Hammersmith
    Take Circle Line to Notting Hill Gate
    Take District Line to Upminster
    Take District Line to Mile End
    Take District Line to Gunnersbury
    Take District Line to Paddington
    Take Circle Line to Paddington
    Take Circle Line to Hammersmith
    Take District Line to Mile End
    Take District Line to Richmond
    Take District Line to Mile End
    Take District Line to Paddington
    Take Circle Line to Paddington
    Take District Line to Richmond
    Take District Line to Bank
    Take Circle Line to Hammersmith
    Take District Line to Upminster
    Take District Line to Stepney Green
    Take District Line to Hammersmith
    Take District Line to Stepney Green
    Take District Line to Upney
    Take District Line to Notting Hill Gate
    Take Circle Line to Notting Hill Gate
    Take Circle Line to Notting Hill Gate
    Take District Line to Upminster
    Take District Line to Upney
    Take District Line to Upminster
    Take District Line to Bank
    Take Circle Line to Bank
    Take Northern Line to Charing Cross
    Take Bakerloo Line to Charing Cross
    Take Bakerloo Line to Paddington
    Take Circle Line to Bank
    Take Circle Line to Bank
    Take Northern Line to Mornington Crescent

    Try it online!

    This is most certainly suboptimal, but it's half the size of the solution on esolangs.

    Hello, World is constructed via slicing the following station names and concatenating the results:

    Hendon Central
    Holloway Road
    Heathrow Terminals 1, 2, 3
    Wood Lane

    Finally, I'm computing the character code of ! as (2<<4)+1 == 33. All these parts are concatenated in Paddington and finally printed in Mornington Crescent.

    Note: The language doesn't specify whether it's possible to travel to same station twice in a row, but the interpreter does allow it, so I've made use of it.

    This is *absolutely brilliant* :D

    I love this language. Excuse me, while I do systems programming in this language.

    Where on EARTH has this language been all my life?

    @ScottMcGready between Camden Town and Euston.

    Mornington Crescent is on TIO now. https://tio.run/#mornington-crescent

    Pushing this to production...

    @NieDzejkob what did you golf? Is it just some minor changes?

    @MartinEnder just using shorter Line names where possible

    @NieDzejkob ah, right. I actually wrote a script for that when doing the primality test. I might see how short it gets using that if I can be bothered to understand the code again.

    @MartinEnder I believe you've misunderstood what I've done. Your script finds intermediate stations, mine finds shortest line names. I wrote a script to do this to get 3568 bytes.

    @NieDzejkob Actually, I misremembered what my script does. I thought it just computes the overall golfiest path (including intermediate stations *and* lines), but apparently it only looks at the length of station names and leaves the rest up to the programmer.

    What the heck is this language?

    Do I recognise the names of the London Underground "tube" lines?! xD

    Nice job! You beat Seed!

  • brainfuck, 72 bytes


    Try it online!

    And the original non-wrapping 76 byte solution:


    Try it online!

    Other shortest known (to my knowledge) solutions I've found

    'Hello, world!' 77 bytes:


    Try it online!

    'hello, world!' 70 bytes:


    Try it online!

    These were found using a c++ program I wrote here: https://github.com/ksabry/bfbrute

    Note: I originally wanted to clean up this code before I posted it to make it actually somewhat readable and usable, but since I haven't gotten around to it in over a year I figure I'll just post it as is. It makes heavy use of templates and compile time constants for any potential optimizations and it has a bunch of commented out code from my testing but no helpful comments so sorry but it's a bit horrible.

    There is nothing terribly clever about the code, it's brute forcer at it's core, however it is quite optimized. The major optimization is that it first iterates through all programs without loops (no [ or ]) up to a specified length (16 currently) and caches an array of all the changes it will make on the data array. It will only store a single program per unique array of changes so for example only one of >+<<-> and <->>+< will be stored. It then iterates through all possible programs which are composed of any program in this cache with any combination of loops between them. After executing each program it does a simple greedy hunt and peck for the characters and appends this to the end of the program.

    After running this through the space of all programs I noticed that almost all the shortest programs (up to length ~19) were of the form *[*[*]*]. Restricting the search to programs of this form sped up the search considerably. The current record holder was found at length 27. This one was actually computed to be length 74, but I noticed a particular sequence .>.>.>. which was lucky enough to have a 0 in the data cell to it's right allowing it to be simplified to [.>]< bringing it down to 72.

    I let it run for quite awhile and completed the search with the current parameters up to length 29, I suspect it will be difficult to beat the current one by simply going higher, I think the most promising approach would probably be increasing the search space in some intelligent way.

    How on Earth did you find this?

    @Dennis I will probably post an explanation of my process when I get the chance, along with the source code I used (once I clean it up)

    Hey you beat Java.

    @KSab I wonder if this is optimal

    That's some device, it doesn't even require wrapping cells ó_Ò

    This is extremely impressive! For reference, the initialization loop leaves the tape as `...35 42 87 106 99 72 35 (0)...`

    Would love to see the algorithm behind this :)

    Are those other shortest solutions from a source that is not your brain? If so, can you post those sources?

    @EngineerToast sorry for the unclear wording, I did find those using the same method as the main solution

    I like how this uses a loop even during the "find and print" second half of the program.

    When are you going to explain it :P

    We want an explanation!

    @EsolangingFruit I've been busy and honestly sort of forgot about this. It might not be too in depth but this weekend I think I'll make some time to write an explanation and upload the source code.

  • evil, 70 bytes


    Try it online!

    It uses the following four commands:

    a - increment the register
    u - decrement the register
    e - interweave the register's bits (01234567 -> 20416375)
    w - write the value of the register as an ASCII character

    Especially since your avatar is Black Hat.

    can u explain me the interweave process.

    @KishanKumar the register is one byte. Its 8 bits, bit 0 to bit 7, are reordered to form a new byte: (bit 2, bit 0, bit 4, bit 1, bit 6, bit 3, bit 7, bit 5).

    @KishanKumar yes

    @grc thanks. Any offline compiler will also be great

    @KishanKumar there's a java implementation here.

    If you read this program out loud, it sounds like a dubstep bass.

  • Piet, 90 codels

    enter image description here

    This is a 30 by 3 image. Alternatively, at codel size 10:

    enter image description here

    The uses a 3-high layout so that I only need to pointer once. If this is still golfable I could probably shave at most another column, since there's a push-pop no-op in there.

    Edit: @primo's 84 codel solution.

    Trying to take your own bounty? I thought more of you Sp3000 ;)

    Hah, just because I set a bounty doesn't mean I can't join in the fun :P

    Have a +1 anyway. I love Piet

    This is the smallest Piet "Hello, World!" that I've seen.

    Great job! I’m trying to find a smaller solution, although I doubt I’ll be able to. Yeah, pointering is a pain in the butt.

    Nice! My Piet solution was the shortest one for a good half hour that's already something I guess :) Have you tried redrawing it with the first codel in the upper left corner black? (you won't have to rotate the pointer at all then).

    @plannapus I saw yours and thought about doing that, but as far as I can tell from the spec that's undefined behaviour, and in particular the interpreter I'm using doesn't do anything if the top left is black...

    oh i didn't realize it was, as I always used PietDev.

    PietDev does not behave according to the specification, at least not in all respects. One major flaw is that PietDev does not work with integers once you use the DIV operation, which produces floating point values as a result. That’s why I always check my results with npiet.

    @plannapus one can, however, put a black codel on the second row, with largely the same effect: http://codegolf.stackexchange.com/a/67601

    A push-pop isn't a no-op to me. It's this.

    What the hell is this "language"? I love it!

    "push-pop no-op" is now my favourite phrase

    Modern international spies must use this language.

    You should be able to consider one codel equals 3 bytes, right? There are 2 bytes for x and y and one byte for the color.

    @MegaMan Base 18 encoding would take 47 bytes, plus 2 bytes for dimensions makes 49. A better compression probably exists.

    TIO.run allows you to use piet can you add a tio.run?

  • Haystack, 17 Bytes

    Haystack is a 2D programming language that executes until it finds the needle in the haystack |, all while performing stack-based operations. All programs start from the top left corner, and can use the directional characters ><^v to move around the program. Direction is inherited, so you do not need to keep using > to go right, direction will only change when it hits a different directional character.

    By default, the interpreter reads from the top left going right, so we can just put "Hello, World!" onto the stack, use o to print it, then place the needle to finish executing.

    "Hello, World!"o|

    Bonus: A more exciting version:

    v      >;+o|
    v "
    v !
    v d
    v l
    v r
    >>"Hello, ">>>v
    W v
    " v

    Just out of curiosity, what happens if you include one of the characters in a string?

    @Random832 In a string, directional characters are treated as regular characters, i.e. you can include them in a string.

    Is there somewhere a detailed description or specification of the language? In particular I'm interested, what happens if you "step" on a whitespace?

    @Kritzefitz I haven't written an official spec, but whitespace will preserve the direction that was used to travel to it. So, if your program is using right, it will continue right on a whitespace or a noop.

    Most entertaining solution here; this one wins.

    I wish I was half as smart as everyone here, but in the "documentation" (read: some guy's forum post) it says `o` outputs as a number. Shouldn't it be `c` at the end? Is there proper documentation anywhere? This is super interesting!

    @Scott Super late to reply to this, that forum post was probably me! `o` outputs the top stack item as-is, i.e. if a number is there it prints that. `c` would simply cast that to a char. So, if you have a string or char on the top of the stack `o` would be what you want :) Eventually these docs will be updated..

License under CC-BY-SA with attribution

Content dated before 7/24/2021 11:53 AM