• underscore_@sopuli.xyz
    link
    fedilink
    arrow-up
    61
    arrow-down
    1
    ·
    edit-2
    3 months ago

    LGTM. Though do people really code with ligatures turned on?

    Edit: Ok so there are some big advocates of ligatures, I’m going to have to give them a second chance. I’ll try for a week, and either way that Fira Code font looks great.

  • Arthur Besse@lemmy.ml
    link
    fedilink
    arrow-up
    40
    ·
    edit-2
    3 months ago

    python -c 'print((61966753*385408813*916167677<<2).to_bytes(11).decode())'

    how?
    $ python
    >>> b"Hello World".hex()
    '48656c6c6f20576f726c64'
    >>> 0x48656c6c6f20576f726c64
    87521618088882533792115812
    $ factor 87521618088882533792115812
    87521618088882533792115812: 2 2 61966753 385408813 916167677
    
    • palordrolap@kbin.run
      link
      fedilink
      arrow-up
      21
      ·
      3 months ago

      perl -le 'use bignum;print+pack"H22",(61966753*385408813*916167677<<2)->to_hex()'

      Alas, Perl doesn’t bignum by default

    • magic_lobster_party@kbin.run
      link
      fedilink
      arrow-up
      60
      ·
      edit-2
      3 months ago

      Bit shift magic.

      My guess is that all the individual characters of Hello World are found inside the 0xC894 number. Every 4 bits of x shows where in this number we can find the characters for Hello World.

      You can read x right to left. (Skip the rightmost 0 as it’s immediately bit shifted away in first iteration)

      3 becomes H 2 becomes e 1 becomes l 5 becomes o

      etc.

      I guess when we’ve exhausted all bits of x only 0 will be remaining for one final iteration, which translates to !

      • CanadaPlus@lemmy.sdf.org
        link
        fedilink
        arrow-up
        17
        ·
        edit-2
        3 months ago

        Too readable. You’ve gotta encode the characters as the solutions of a polynomial over a finite field, implemented with linear feedback on the bit shifts. /s

      • barsoap@lemm.ee
        link
        fedilink
        arrow-up
        4
        ·
        edit-2
        3 months ago

        32 is ASCII space, the highest number you need is 114 for r (or 122 for z if you want to be generic), that’s a range of 82 or 90 values.

        The target string has 13 characters, a long long has 8 bytes or 16 nibbles – 13 fits into 16 so nibbles (the (x >>= 4) & 15) it is. Also the initial x happens to have 13 nibbles in it so that makes sense. But a nibble only has 16 values, not 82, so you need some kind of compression and that’s the rest of the math, no idea how it was derived.

        If I were to write that thing I’d throw PAQ at it it can probably spit out an arithmetic coding that works, and look even more arcane as you wouldn’t have the obvious nibble steps. Or, wait, throw NEAT at it: Train it to, given a specific initial seed, produce a second seed and a character, score by edit distance. The problem space is small enough for the approach to be feasible even though it’s actually a terrible use of the technique, but using evolution will produce something that’s utterly, utterly inscrutable.

      • s12@sopuli.xyz
        link
        fedilink
        arrow-up
        4
        ·
        3 months ago

        I understand that the characters are probably encoded into that number, but I’m struggling to understand that C/C++ code.

  • Mikelius@lemmy.ml
    link
    fedilink
    arrow-up
    16
    ·
    3 months ago

    What is that weird >>=== symbol? Looks like a cross breed between C and JavaScript here.

    • underscore_@sopuli.xyz
      link
      fedilink
      arrow-up
      21
      ·
      edit-2
      3 months ago

      It’s a the right shift assignment operator so x >>= 4 right shifts x by 4 and assigns the result back to x. The code editor is displaying single double wide symbol (ligature) instead of the three character long operator >>=, I discovered today these are in fact well loved by some coders.

      • PlexSheep@infosec.pub
        link
        fedilink
        arrow-up
        3
        ·
        3 months ago

        If someone likes it but doesn’t know where to find it, FiraCode does linea tires really good IMO

      • Mikelius@lemmy.ml
        link
        fedilink
        arrow-up
        2
        ·
        3 months ago

        I totally thought because of how long the equals looked, it was multiple equals characters, not just >>= lol. That’s what got me confused. Don’t think these are things I’d personally use but each to their own preferences right xD

  • call_me_xale@lemmy.zip
    link
    fedilink
    arrow-up
    15
    arrow-down
    1
    ·
    edit-2
    3 months ago

    As long as I don’t have to maintain it.

    (Who tf downvoted this? The “legacy code” lobby?)

  • state_electrician@discuss.tchncs.de
    link
    fedilink
    arrow-up
    6
    ·
    3 months ago

    The best Hello World I saw used a random library. Because there’s no true random without hardware, the author figured out the correct seed to write Hello World with “random” characters. I’ve used that to show junior devs that random in programming doesn’t mean truly random.