Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

On a lighter note, I recently saw a golfing challenge:

Measure the Diamond Road, on Stackexchange

Among "real" languages, there are currently Python and couple JS solutions with scores 59, 61, 55, which I'm embarrased to admit I can barely read. Another JS solution with score 52 seems to break rules with its "list of chars" input. It's been long time since I tried my hand in this, apparently it's now OK to keep function name in "header" and semicolon in "footer", so I wrote my code as such.

With result of 62, can't move any further:

Perl attempt

can it be improved? Can we beat Python's 59?

Updated by GrandFather to remove pre tags and linkify link

Replies are listed 'Best First'.
Re: Trying to outgolf Python
by choroba (Cardinal) on Jul 18, 2023 at 12:22 UTC
    I was able to come up with
    sub{my%r;for(split$",shift){$h=$p=$i=0;while(/./g){if($p){$h+=('/'eq$& +)*2-1if$&eq$p}else{$h='/'eq$&}$p=$&;$r{$i++,$h}=1}}keys%r}
    which is too long, but I don't have enough time to play with it any more :-(

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
Re: Trying to outgolf Python
by LanX (Saint) on Jul 17, 2023 at 13:54 UTC
    In order to engage the audiance here :

    If you even don't describe the task here, than you should at least linkify your links properly.

    That's trivially done with brackets [...]

    Cheers Rolf
    (addicted to the 𐍀𐌴𐍂𐌻 Programming Language :)
    Wikisyntax for the Monastery

      "That's trivially done with brackets"

      Unless posting anonymously, the site may flag links as spam.

Re: Trying to outgolf Python
by harangzsolt33 (Deacon) on Jul 18, 2023 at 02:14 UTC
    Among the solutions I see some weird stuff like that 'Nekomata' 7 bytes. What is that???? I've never heard about Nekomata. I looked up what it is, and it doesn't seem to be a programming language. So, what is going on here? Can people come up with their own fiction languages? Hey, I'm going to submit my solution. It's only 2 bytes long: "I%" and it's written in "Chukumaka" language which I made up right now. I win! Lol

      Hey, I'm going to submit my solution. It's only 2 bytes long: "I%" and it's written in "Chukumaka" language which I made up right now. I win!

      Nice try, but you're gonna have to work a bit harder. :)

      As noted here, the HQ9+ Programming Language provides one byte solutions to a range of programming problems, including printing the entire lyrics of the 99 Bottles of Beer drinking song in an elegant one byte program: 9

        I'd say a real "programming language" should be Turing Complete.

        But there are indeed extensions listed, which at least claim to be. One even by allowing Perl, tho I think that's meant to be a joke referring to Perl's bad rep.

        Hmm... by using a source filter this shouldn't be to hard to achieve... hehe ;)

        Cheers Rolf
        (addicted to the 𐍀𐌴𐍂𐌻 Programming Language :)
        Wikisyntax for the Monastery