UserScript

From Esolang
Jump to navigation Jump to search

UserScript is a Joke Language invented by User:A that outputs how long a CGCC submission is. (Inspired by this post.)

Apparently the language is simple: find the first and second matches of ```, and then output the length of the text between it. If there is no match, output the first consecutive matches of the length of the texts prepended with 4 spaces, with the spaces removed.

The output will then be checked against the header of the post prepended with ##; the last number in the header is the intended length. If they are not equal, this outputs a falsy value. Otherwise, this outputs a truthy value.

Sample program

## Golfscript - 66 chars

    "placeholder text for userscript which counts chars             ";

`xxd`: (use `xxd -r` to revert)


    0000000: 332c 7b3a 533b 2e7b 3438 2d22 5e70 285d  3,{:S;.{48-"^p(]
    0000010: 7025 d3c4 4ab1 7d4a b8dc 4469 ce41 2222  p%..J.}J..Di.A""
    0000020: f303 227b 6261 7365 7d2f 3330 2f53 3d33  .."{base}/30/S=3
    0000030: 2f3d 7b22 5f20 7c22 3d7d 257d 256e 407d  /={"_ |"=}%}%n@}
    0000040: 2f3b                                     /;

This follows most of the other answers in that there are no spaces between numbers and trailing spaces are kept in. A space between numbers can easily be added with `1+` before `{"_ |"=}%`. Packed into a base 3 number, and then as base 243 into a string.

This program scans for lines prepended with 4 spaces. It finds just one: "placeholder text for userscript which counts chars ";. Then, it removes the prepending 4 spaces and outputs its length, which is 66. It checks the number against the number in the header, and then outputs a truthy value.