问:
Make it look like I'm working
Often, I find myself running a script or query that will take a significant amount of time to run.  I can leave that script open and enjoy some guilt-free procrastination.

Now, what if I could write a script that seems to be one of the above scripts to any onlookers, but in looks only?  I could put it up on a screen and enjoy days of kitten livestreams before anyone realised that all the complicated rigmarole on the screen didn't have anything to do with my actual job.

Your challenge is to write this script for me (yes, I'm that lazy).

A good answer will:

Make something appear on the screen that looks like a script is doing work.  "Screen" can be terminal, browser, etc.

Be fairly original (yes, we've all seen the neverending progress bar programs)

Survive cursory examination by a technical person

A bad answer will:

Get me fired

Rehash something we all were forwarded in the 90's

A stellar answer might:

Transcend one of the bad bullet points above (for instance)

Survive critical examination

*gasp* actually do something that's useful or aids in my work shirking

Acceptance will be based on votes, with bonus from real-life results.  I will actually run these scripts (Linux Mint 16) at work when my screen is visible (meetings and the like) to determine detection.  If anyone notices that it's faking, you're out of the running.  If someone comments on how hard I'm working, +5 bonus upvotes for you.

"Useful" in this case can apply to any coder, but if you're looking for that extra shine on your teacher-bound apple, I'm a full-stack webdev who works in code roughly according to my tags.

Question partially inspired by this.

Results

Disappointingly, I didn't get any comments either way on these entries.  They're all awesome, so you're all winners in my heart.  However, Loktar has the most votes by a long shot, so he gets the +15 from the accept.  Congrats!

答:
C#

Slowly type up the full HTML of this webpage in the console. Added random time between "keystrokes" for realistic effect.

```<code>class HTMLConsole
{
    static void Main(string[] args)
    {
        System.Net.WebClient wc = new System.Net.WebClient();
        string webData = wc.DownloadString("http://codegolf.stackexchange.com/questions/30322/make-it-look-like-im-working");
        for(int i = 0; i < webData.Length; i++)
        {
            Console.Write(webData[i]);
            System.Threading.Thread.Sleep(new Random().Next(20, 300));
        }
    }
}
</code>```

Alternatively, here is a program that will download, extract, unzip randomly-named packages, programs, bundles etc. forever.

```<code>class C
{
    static Random rnd = new Random();

    static void Main(string[] args)
    {
        for(;;)
        {
            string dType = GetDType();
            string extension = GetExt(dType);
            Console.Write(GetAction() + ' ' + dType + ' ' + GetName() + extension + "   .");
            for(int i = 0; i < rnd.Next(5, 40);i++)
            {
                Console.Write("\b..");
                Loading();
            }
            Console.Write("\bDone");
            Console.WriteLine();
        }
    }

    static string GetExt(string dType)
    {
        if (dType == "Package")
        {
            int r = rnd.Next(1, 5);
            if (r == 1) return ".crx";
            if (r == 2) return ".zip";
            if (r == 3) return ".rar";
            if (r == 4) return ".tar.gz";
            if (r == 5) return ".ymp";
            if (r == 6) return ".umx";
            if (r == 7) return ".gpk";
        }

        if (dType == "Bundle")
        {
            int r = rnd.Next(1, 3);
            if (r == 1) return ".app";
            if (r == 2) return ".bun";
        }

        if (dType == "Program")
        {
            int r = rnd.Next(1, 14);
            if (r == 1) return ".acc";
            if (r == 2) return ".akp";
            if (r == 3) return ".awk";
            if (r == 4) return ".fas";
            if (r == 5) return ".frx";
            if (r == 6) return ".int";
            if (r == 7) return ".mar";
            if (r == 8) return ".pdm";
            if (r == 9) return ".pgm";
            if (r == 10) return ".rn";
            if (r == 11) return ".sbp";
            if (r == 12) return ".t64";
            if (r == 13) return ".wxh";
        }

        if (dType == "Document")
        {
            int r = rnd.Next(1, 12);
            if (r == 1) return ".abc";
            if (r == 2) return ".rpl";
            if (r == 3) return ".doc";
            if (r == 4) return ".dat";
            if (r == 5) return ".hcg";
            if (r == 6) return ".indd";
            if (r == 7) return ".jw";
            if (r == 8) return ".mnt";
            if (r == 9) return ".neis";
            if (r == 10) return ".odm";
            if (r == 11) return ".pdf";
        }

        if (dType == "Update")
        {
            int r = rnd.Next(1, 5);
            if (r == 1) return ".rtp";
            if (r == 2) return ".mum";
            if (r == 3) return ".upd";
            if (r == 4) return ".bdf";
        }

        return "";

    }

    static string GetAction()
    {
        int r = rnd.Next(1, 6);

        if (r==1) return "Downloading";
        if (r==2) return "Unzipping";
        if (r==3) return "Installing";
        if (r==4) return "Extracting";
        if (r==5) return "Encrypting";

        return "";

    }

    static string GetName()
    {
        int length = rnd.Next(5, 12);
        string output = "";
        for(int i = 0; i < length; i++)
        {
            char c = (char)rnd.Next(97, 122);
            if (i == 0) c = char.ToUpper(c);
            else
            {
                bool same = (("aeiouAEIOU".IndexOf(c) >= 0) && ("aeiouAEIOU".IndexOf(output[i - 1]) >= 0))
                    || (!("aeiouAEIOU".IndexOf(c) >= 0) && !("aeiouAEIOU".IndexOf(output[i - 1]) >= 0));
                if (same)
                {
                    i--;
                    continue;
                }
            }
            output += c;
        }

        string version = "-";
        for(int i = 0; i < rnd.Next(1, 4); i++)
        {
            if (i != 0) version += ".";
            version += rnd.Next(0, 10);
        }

        int r = rnd.Next(1, 5);
        if (r == 1) version += "-BETA";
        if (r == 2) version += "-ALPHA";
        if (r == 3) version += "-" + ((char)rnd.Next(97,122)) + (rnd.Next(1000, 10000));

        output += version;

        return output;
    }

    static string GetDType()
    {

        int r = rnd.Next(1, 6);

        if (r==1) return "Package";
        if (r==2) return "Bundle";
        if (r==3) return "Program";
        if (r==4) return "Document";
        if (r==5) return "Update";

        return "";
    }

    static void Loading()
    {
        char s = '|';
        for(int i = 0; i < rnd.Next(10, 100); i++)
        {
            if (s == '\\') s = '|';
            if (s == '-') s = '\\';
            if (s == '/') s = '-';
            if (s == '|') s = '/';
            Console.Write('\b');
            Console.Write(s);
            System.Threading.Thread.Sleep(50);

        }
    }
}
</code>```

Title: Make it look like I'm working

Body:
C#

Slowly type up the full HTML of this webpage in the console. Added random time between "keystrokes" for realistic effect.

class HTMLConsole
{
    static void Main(string[] args)
    {
        System.Net.WebClient wc = new System.Net.WebClient();
        string webData = wc.DownloadString("http://codegolf.stackexchange.com/questions/30322/make-it-look-like-im-working");
        for(int i = 0; i < webData.Length; i++)
        {
            Console.Write(webData[i]);
            System.Threading.Thread.Sleep(new Random().Next(20, 300));
        }
    }
}

Alternatively, here is a program that will download, extract, unzip randomly-named packages, programs, bundles etc. forever.

class C
{
    static Random rnd = new Random();

    static void Main(string[] args)
    {
        for(;;)
        {
            string dType = GetDType();
            string extension = GetExt(dType);
            Console.Write(GetAction() + ' ' + dType + ' ' + GetName() + extension + "   .");
            for(int i = 0; i < rnd.Next(5, 40);i++)
            {
                Console.Write("\b..");
                Loading();
            }
            Console.Write("\bDone");
            Console.WriteLine();
        }
    }

    static string GetExt(string dType)
    {
        if (dType == "Package")
        {
            int r = rnd.Next(1, 5);
            if (r == 1) return ".crx";
            if (r == 2) return ".zip";
            if (r == 3) return ".rar";
            if (r == 4) return ".tar.gz";
            if (r == 5) return ".ymp";
            if (r == 6) return ".umx";
            if (r == 7) return ".gpk";
        }

        if (dType == "Bundle")
        {
            int r = rnd.Next(1, 3);
            if (r == 1) return ".app";
            if (r == 2) return ".bun";
        }

        if (dType == "Program")
        {
            int r = rnd.Next(1, 14);
            if (r == 1) return ".acc";
            if (r == 2) return ".akp";
            if (r == 3) return ".awk";
            if (r == 4) return ".fas";
            if (r == 5) return ".frx";
            if (r == 6) return ".int";
            if (r == 7) return ".mar";
            if (r == 8) return ".pdm";
            if (r == 9) return ".pgm";
            if (r == 10) return ".rn";
            if (r == 11) return ".sbp";
            if (r == 12) return ".t64";
            if (r == 13) return ".wxh";
        }

        if (dType == "Document")
        {
            int r = rnd.Next(1, 12);
            if (r == 1) return ".abc";
            if (r == 2) return ".rpl";
            if (r == 3) return ".doc";
            if (r == 4) return ".dat";
            if (r == 5) return ".hcg";
            if (r == 6) return ".indd";
            if (r == 7) return ".jw";
            if (r == 8) return ".mnt";
            if (r == 9) return ".neis";
            if (r == 10) return ".odm";
            if (r == 11) return ".pdf";
        }

        if (dType == "Update")
        {
            int r = rnd.Next(1, 5);
            if (r == 1) return ".rtp";
            if (r == 2) return ".mum";
            if (r == 3) return ".upd";
            if (r == 4) return ".bdf";
        }

        return "";

    }

    static string GetAction()
    {
        int r = rnd.Next(1, 6);

        if (r==1) return "Downloading";
        if (r==2) return "Unzipping";
        if (r==3) return "Installing";
        if (r==4) return "Extracting";
        if (r==5) return "Encrypting";

        return "";

    }

    static string GetName()
    {
        int length = rnd.Next(5, 12);
        string output = "";
        for(int i = 0; i < length; i++)
        {
            char c = (char)rnd.Next(97, 122);
            if (i == 0) c = char.ToUpper(c);
            else
            {
                bool same = (("aeiouAEIOU".IndexOf(c) >= 0) && ("aeiouAEIOU".IndexOf(output[i - 1]) >= 0))
                    || (!("aeiouAEIOU".IndexOf(c) >= 0) && !("aeiouAEIOU".IndexOf(output[i - 1]) >= 0));
                if (same)
                {
                    i--;
                    continue;
                }
            }
            output += c;
        }

        string version = "-";
        for(int i = 0; i < rnd.Next(1, 4); i++)
        {
            if (i != 0) version += ".";
            version += rnd.Next(0, 10);
        }

        int r = rnd.Next(1, 5);
        if (r == 1) version += "-BETA";
        if (r == 2) version += "-ALPHA";
        if (r == 3) version += "-" + ((char)rnd.Next(97,122)) + (rnd.Next(1000, 10000));

        output += version;

        return output;
    }

    static string GetDType()
    {

        int r = rnd.Next(1, 6);

        if (r==1) return "Package";
        if (r==2) return "Bundle";
        if (r==3) return "Program";
        if (r==4) return "Document";
        if (r==5) return "Update";

        return "";
    }

    static void Loading()
    {
        char s = '|';
        for(int i = 0; i < rnd.Next(10, 100); i++)
        {
            if (s == '\\') s = '|';
            if (s == '-') s = '\\';
            if (s == '/') s = '-';
            if (s == '|') s = '/';
            Console.Write('\b');
            Console.Write(s);
            System.Threading.Thread.Sleep(50);

        }
    }
}


问:
Find the program that prints this integer sequence (Robbers' thread)
This is the robbers' thread. The cops' thread goes here.

In the cops thread, the task was to write a program/function that takes a positive (or non-negative) integer and outputs/returns another number (not necessarily integer). The robbers task is to unscramble the code the cops used to produce this output.

The cracked code doesn't have to be identical, as long as it has the same length and any revealed characters are in the correct positions. The language must also be the same (version numbers can be different). The output must of course be identical.

No-ops can be used in robber's solution.

The winner of the robbers thread will be the user who has cracked the
most submissions by May 7th 2016. If there's a tie, the user who has cracked submissions with the longest combined code will win.

The submission should be formatted like this:

Language, nn characters (including link to answer), Cop's username

Code:

```<code>function a(n)
    if n<2 then
        return n
    else
        return a(n-1) + a(n-2)
    end
end
</code>```

Output

```<code>a(0) returns 0
a(3) returns 2
</code>```

Optional explanation and comments.

答:
Python, 17 bytes, ASCIIThenANSI, A000027

```<code>def a(n):return n
</code>```

Trivial?

ContentLicense: CC BY-SA 3.0

Body:
Python, 17 bytes, ASCIIThenANSI, A000027

def a(n):return n

Trivial?


答:
Python, 60 bytes, ASCIIThenANSI A000930

```<code>def a(n):
 if n<3:
  return 1
 else:
  return a(n-1)+a(n-3)
</code>```

Still trivial

Title: Find the program that prints this integer sequence (Robbers' thread)

Body:
This is the robbers' thread. The cops' thread goes here.

In the cops thread, the task was to write a program/function that takes a positive (or non-negative) integer and outputs/returns another number (not necessarily integer). The robbers task is to unscramble the code the cops used to produce this output.

The cracked code doesn't have to be identical, as long as it has the same length and any revealed characters are in the correct positions. The language must also be the same (version numbers can be different). The output must of course be identical.

No-ops can be used in robber's solution.

The winner of the robbers thread will be the user who has cracked the
most submissions by May 7th 2016. If there's a tie, the user who has cracked submissions with the longest combined code will win.

The submission should be formatted like this:

Language, nn characters (including link to answer), Cop's username

Code:

```<code>function a(n)
    if n<2 then
        return n
    else
        return a(n-1) + a(n-2)
    end
end
</code>```

Output

```<code>a(0) returns 0
a(3) returns 2
</code>```

Optional explanation and comments.

Body:
Python, 60 bytes, ASCIIThenANSI A000930

def a(n):
 if n<3:
  return 1
 else:
  return a(n-1)+a(n-3)

Still trivial


问:
All Your Base Are Belong To Us (Restricted)
Input must not be required, and output must read "All your base are belong to us".

Restrictions

No external resources.

Plus a minimum of two of the following:

You cannot use "a", "b", "t", "u", or "y" in any case in your code (bonus -10 to your golf score if you can do this)

You cannot use "l", "o", "s", "e", or "r" in any case in your code (bonus -20 to your golf score if you can do this)

You cannot use "n", "g", "0", "1", or "2" in any case in your code (bonus -30 to your golf score if you can do this)

So for example, if you manage to get the code done with 40 characters and use rules 1 and 2, your golf score is 40 - 10 - 20 = 10 chars.

Smallest code golf score wins... Good luck!

答:
Perl 5, 99 − 50 = 49

A subroutine that returns the required string:

```<code>{A.($c=h|d)."$c y".($f=f|k).u.($k=p|b)." ba".($j=c|p).($d=d|a)." a$k$d b$d$c$f".(jf|fc)." t$f u$j"}
</code>```

See it printed thus:

```<code>perl -e'print sub{...}->().$/'
</code>```

Body:
Perl 5, 99 − 50 = 49

A subroutine that returns the required string:

{A.($c=h|d)."$c y".($f=f|k).u.($k=p|b)." ba".($j=c|p).($d=d|a)." a$k$d b$d$c$f".(jf|fc)." t$f u$j"}

See it printed thus:

perl -e'print sub{...}->().$/'


问:
Find the program that prints this integer sequence (Cops' thread)
This is the cops' thread. The robbers' thread goes here.

The last cops-and-robbers thread was already 4 months ago.

The cop's task

The cop's task is to write a program/function that takes a positive (or non-negative) integer and outputs/returns another integer.

The cop must state it if the program is intolerant towards zero.

The cop will provide at least 2 sample inputs/outputs.

For example, if I have decided to write the Fibonacci sequence, I would write this in my answer:

```
a(0) returns 0
a(3) returns 2
```

The number of examples is up to the cop's discretion.

However, the sequence must actually exist in the On-Line Encyclopedia of Integer Sequences®, so no pseudo-random number generator for you. :(

The cop can hide as many characters as is so wished.

For example, if my program is:

```<code>function a(n)
    if n>2 then
        return n
    else
        return a(n-1) + a(n-2)
    end
end
</code>```

Then I would hide these characters as I want:

```<code>function a(n)
    if ### then
        ########
    else
        ######################
    end
end
</code>```

The robber's task

is obviously to find the original source code.

However, any proposed source code that produces the same set of output also counts as valid, as long as it is also found in OEIS.

Tips for the cops

<s>The search function in the OEIS only works for consecutive terms, so if you want to hide your sequence, then just leave a hole anywhere.</s>

Apparently there is no way to hide the sequence. Put this in mind when you choose the sequence.

Your score is the number of bytes in your code.

The winner will be the submission with the lowest score that hasn't been cracked in 7 days.

Only submissions that are posted in 2016 April are eligible for the win. Submissions that are posted later than this are welcome, but cannot win.

In order to claim the win you need to reveal the full code and the OEIS sequence (after 7 days).

Your post should be formatted like this (NN is the number of characters):

Lua, 98 bytes

Output:

```<code>a(0) returns 0
a(3) returns 2
</code>```

Code (# marks unrevealed characters):

```<code>function a(n)
    if ### then
        ########
    else
        ######################
    end
end
</code>```

If the code is cracked, insert [Cracked](link to cracker) in the header.
If the submission is safe, insert "Safe" in the header and reveal the full code in your answer. Only answers that have revealed the full code will be eligible for the win.

答:
05AB1E, 4 bytes, cracked

Well then, I  think I'm addicted to CnR's... Obfuscated code (_ indicates a wild card):

```<code>____
</code>```

Sequence:

```<code>a(1) = 2
a(4) = 6720
</code>```

The sequence in OEIS starts at a(1) = 2.

Try it online!-link

Body:
05AB1E, 4 bytes, cracked

Well then, I  think I'm addicted to CnR's... Obfuscated code (_ indicates a wild card):

____

Sequence:

a(1) = 2
a(4) = 6720

The sequence in OEIS starts at a(1) = 2.

Try it online!-link


答:
Ruby, 46 bytes, safe

Edit to add disclaimer/apology: This sequence starts with f[0], while the OEIS entry starts with f[1]. The values are the same.

Obfuscated code (# is any character):

```<code>->####or x##1###(#..##0#);x*=3;end;#.###ect:+}
</code>```

Call like

```<code>->####or x##1###(#..##0#);x*=3;end;#.###ect:+}[3] (returns 39)
</code>```

Output:

```<code>f[0] = 0
f[1] = 3
f[2] = 12
f[3] = 39
f[4] = 120
f[5] = 363
f[6] = 1092
f[7] = 3279
f[8] = 9840
f[9] = 29523
</code>```

Solution:

 f=->*x{for x[-1]in(0..x[0]);x*=3;end;x.inject:+}

Sequence:

 http://oeis.org/A029858

Explanation:

 The minor trick here is that we declare the parameter as *x rather than x. This means that if you pass in 2, x is set to [2]...at first. The major trick exploits bizarre, and justly obscure, Ruby syntax where you can set the iterator in a for loop to any valid left hand side of an assignment expression, instead of an iterator variable like i. So this loops through from 0 to (in this example) 2, assigning each number to x[-1], meaning it overwrites the last value of x. Then the loop body x*=3, further mutates x by concatenating it to itself 3 times. So first x becomes [0], then [0,0,0]. On the next loop it becomes [0,0,1], then [0,0,1,0,0,1,0,0,1]. Finally we pass in 2 and it becomes [0,0,1,0,0,1,0,0,2], then [0, 0, 1, 0, 0, 1, 0, 0, 2, 0, 0, 1, 0, 0, 1, 0, 0, 2, 0, 0, 1, 0, 0, 1, 0, 0, 2]. We then sum the result using the inject method, which reduces the array by applying + (the passed in method) to each element in turn. If we consider how each iteration changes the sum, we see that we effectively add 1 (by overwriting the last element with an element one higher), then multiply by 3. Since 3*(n+1) = 3*n + 3, this implements Alexandre Wajnberg's recurrence relation for the sequence as described on the page.

Title: Find the program that prints this integer sequence (Cops' thread)

Body:
This is the cops' thread. The robbers' thread goes here.

The last cops-and-robbers thread was already 4 months ago.

The cop's task

The cop's task is to write a program/function that takes a positive (or non-negative) integer and outputs/returns another integer.

The cop must state it if the program is intolerant towards zero.

The cop will provide at least 2 sample inputs/outputs.

For example, if I have decided to write the Fibonacci sequence, I would write this in my answer:

```
a(0) returns 0
a(3) returns 2
```

The number of examples is up to the cop's discretion.

However, the sequence must actually exist in the On-Line Encyclopedia of Integer Sequences®, so no pseudo-random number generator for you. :(

The cop can hide as many characters as is so wished.

For example, if my program is:

```<code>function a(n)
    if n>2 then
        return n
    else
        return a(n-1) + a(n-2)
    end
end
</code>```

Then I would hide these characters as I want:

```<code>function a(n)
    if ### then
        ########
    else
        ######################
    end
end
</code>```

The robber's task

is obviously to find the original source code.

However, any proposed source code that produces the same set of output also counts as valid, as long as it is also found in OEIS.

Tips for the cops

<s>The search function in the OEIS only works for consecutive terms, so if you want to hide your sequence, then just leave a hole anywhere.</s>

Apparently there is no way to hide the sequence. Put this in mind when you choose the sequence.

Your score is the number of bytes in your code.

The winner will be the submission with the lowest score that hasn't been cracked in 7 days.

Only submissions that are posted in 2016 April are eligible for the win. Submissions that are posted later than this are welcome, but cannot win.

In order to claim the win you need to reveal the full code and the OEIS sequence (after 7 days).

Your post should be formatted like this (NN is the number of characters):

Lua, 98 bytes

Output:

```<code>a(0) returns 0
a(3) returns 2
</code>```

Code (# marks unrevealed characters):

```<code>function a(n)
    if ### then
        ########
    else
        ######################
    end
end
</code>```

If the code is cracked, insert [Cracked](link to cracker) in the header.
If the submission is safe, insert "Safe" in the header and reveal the full code in your answer. Only answers that have revealed the full code will be eligible for the win.

Body:
Ruby, 46 bytes, safe

Edit to add disclaimer/apology: This sequence starts with f[0], while the OEIS entry starts with f[1]. The values are the same.

Obfuscated code (# is any character):

->####or x##1###(#..##0#);x*=3;end;#.###ect:+}

Call like

->####or x##1###(#..##0#);x*=3;end;#.###ect:+}[3] (returns 39)

Output:

f[0] = 0
f[1] = 3
f[2] = 12
f[3] = 39
f[4] = 120
f[5] = 363
f[6] = 1092
f[7] = 3279
f[8] = 9840
f[9] = 29523

Solution:

 f=->*x{for x[-1]in(0..x[0]);x*=3;end;x.inject:+}

Sequence:

 http://oeis.org/A029858

Explanation:

 The minor trick here is that we declare the parameter as *x rather than x. This means that if you pass in 2, x is set to [2]...at first. The major trick exploits bizarre, and justly obscure, Ruby syntax where you can set the iterator in a for loop to any valid left hand side of an assignment expression, instead of an iterator variable like i. So this loops through from 0 to (in this example) 2, assigning each number to x[-1], meaning it overwrites the last value of x. Then the loop body x*=3, further mutates x by concatenating it to itself 3 times. So first x becomes [0], then [0,0,0]. On the next loop it becomes [0,0,1], then [0,0,1,0,0,1,0,0,1]. Finally we pass in 2 and it becomes [0,0,1,0,0,1,0,0,2], then [0, 0, 1, 0, 0, 1, 0, 0, 2, 0, 0, 1, 0, 0, 1, 0, 0, 2, 0, 0, 1, 0, 0, 1, 0, 0, 2]. We then sum the result using the inject method, which reduces the array by applying + (the passed in method) to each element in turn. If we consider how each iteration changes the sum, we see that we effectively add 1 (by overwriting the last element with an element one higher), then multiply by 3. Since 3*(n+1) = 3*n + 3, this implements Alexandre Wajnberg's recurrence relation for the sequence as described on the page.


答:
Javascript ES6, 905 bytes

Whew.. The 12 hour clock killed my otherwise short (ahum) solution.

905 bytes to print 898 chars of ascii art yay

```<code>_=>(a=(d=Date)(c=new d(),z=O=>Math.abs(new d(a[3]+O)-c)).split` `)[1]=='Apr'&a[2]==20|~a[4].search(/(04|16):20/)?'0,0,2ca2o,0,10e,0,0,1eu9z4,0,22w,1ulajuo,0,bklxc,2zgg,i,120gdfk,8lc,1s1s,15,j0jf9c,7em8,tac,10,190zcw0,tm8w,ksk,hra0ia,mihog0,3aels,wy,iv8e15,b98u80,cvs1s,575,9fm71g,190zcw0,bg7vgg,1t4,148d4lu,121pblx,b9ea68,2b36,iv8hn5,9zleso,15kytz4,98cp,4fwpwk,zir9ud,1h9u3ln,11c6vb4,84kda8,kbuo05,b98u84,14possy,k9su6i,a26hwk,zvft34,kavrpc,1tn1j4,1r3jis,kamgao,a5bhq8,2b2q,beyt6x,j0y810,muhiww,9xl,a5b7s8,14npcwi,1bkfw1s,4ys,14lipw4,kalr6k,0,1aq,kalqzg,0,48m,2j6hqf,zik0zk,0,33mcjk,0,5'.split`,`.map(a=>('0'.repeat(32)+parseInt(a,36).toString(2)).substr(-32)).join``.match(/.{1,3}/g).map(a=>` .:\`|;'
`[parseInt(a,2)]).join``:~~((T=Math.min(z('/4/20'),z(` ${a[1]} ${++a[2]} 0:4:20`),z(' 4:20'),z(' 0:4:20'),z(' 16:20'),z(' 0:16:20'))/1000)/60)+` minutes and ${~~(T%60)} seconds left until your next hit.`
</code>```

Ungolfed code

Note: The ungolfed code will not execute

```<code>function() {
    // (all vars here are actually global)
    var d = Date; // short reference to Date object
    var dateString = Date() // "Tue Apr 12 2016 20:13:00 GMT+0200 (W. Europe Daylight Time)"
    .split` `; // ["Tue", "Apr", "12", ...]
    var currentDate = new Date();
    dateDiff = function(toAppend) {
        return Math.abs( // no dates in the past
            new Date(dateString[3] + toAppend) // new Date('2016' + something)
            - currentDate // substract the current date.
                          // Thanks JS for the datetime implementation
        );
    }

    if ((dateString[1] == 'Apr' & dateString[2] == 20) |
        ~dateString[4].search(/(04|16):20/)) { // if the time doesn't contain 04:20 or
                                               // 16:20, this will return -1. ~-1 is 0
                                               // and thus falsy
        alert(printAscii());
    } else {
        alert(printTimeLeft());
    }
}

function printAscii() {
    var magicString = '0,0,2ca2o,0,10e,0,0,1eu9z4,0,22w,1ulajuo,0,bklxc,2zgg,i,120gdfk,8lc,1s1s,15,j0jf9c,7em8,tac,10,190zcw0,tm8w,ksk,hra0ia,mihog0,3aels,wy,iv8e15,b98u80,cvs1s,575,9fm71g,190zcw0,bg7vgg,1t4,148d4lu,121pblx,b9ea68,2b36,iv8hn5,9zleso,15kytz4,98cp,4fwpwk,zir9ud,1h9u3ln,11c6vb4,84kda8,kbuo05,b98u84,14possy,k9su6i,a26hwk,zvft34,kavrpc,1tn1j4,1r3jis,kamgao,a5bhq8,2b2q,beyt6x,j0y810,muhiww,9xl,a5b7s8,14npcwi,1bkfw1s,4ys,14lipw4,kalr6k,0,1aq,kalqzg,0,48m,2j6hqf,zik0zk,0,33mcjk,0,5' // ;)
    var splitted = magicString.split`,`;
    var binarySequence = splitted.map(function(piece) {
        return ('0'.repeat(32) + // 000000000... this will be padded
            parseInt(a,36) // parseInt('190zcw0',36) -> 000000002722627584
            .toString(2) // -> 10100010010010000000000000000000
        ).substr(-32) // left pad binary sequence
    }).join``; // create one big binary sequence from several smaller
    var groupsOfThree = binarySequence.match(/.{1,3}/g);
    return groupsOfThree.map(function(three) {
        return ` .:\`|;'\n`[parseInt(a,2)]; // magic.. turn 010 into : etc
    }).join``; // create them blaze
}

function printTimeLeft() {
    // this is way longer than it should be.. probably
    var minimumTimeDifference = Math.min(
        dateDiff('/4/20'), // -> Difference between now and 2016/4/20 00:00:00
        dateDiff(' 4:20'), // 2016 04:20:00.. Sadly the 2016 is needed (i think)
        dateDiff(' 0:4:20'), // 2016 00:04:20
        dateDiff(' 16:20'), // Damn 12 hour clock :(
        dateDiff(' 0:16:20'),
        dateDiff(` ${dateString[1]} // 2016 Apr
                   ${dateString[2]+1} // 2016 Apr 13 (12+1)
                   0:4:20` // Check the first occurrence of 4 minutes and 20 seconds
                           // the next day
    )
    var timeInSeconds = minimumTimeDifference / 1000;
    return Math.floor(timeInSeconds) + // ~~ works like Math.floor
        ` minutes and ${Math.floor(timeInSeconds%60)} seconds left until your next hit.`;
}
</code>```

Try it!

f=
_=>(a=(d=Date)(c=new d(),z=O=>Math.abs(new d(a[3]+O)-c)).split` `)[1]=='Apr'&a[2]==20|~a[4].search(/(04|16):20/)?'0,0,2ca2o,0,10e,0,0,1eu9z4,0,22w,1ulajuo,0,bklxc,2zgg,i,120gdfk,8lc,1s1s,15,j0jf9c,7em8,tac,10,190zcw0,tm8w,ksk,hra0ia,mihog0,3aels,wy,iv8e15,b98u80,cvs1s,575,9fm71g,190zcw0,bg7vgg,1t4,148d4lu,121pblx,b9ea68,2b36,iv8hn5,9zleso,15kytz4,98cp,4fwpwk,zir9ud,1h9u3ln,11c6vb4,84kda8,kbuo05,b98u84,14possy,k9su6i,a26hwk,zvft34,kavrpc,1tn1j4,1r3jis,kamgao,a5bhq8,2b2q,beyt6x,j0y810,muhiww,9xl,a5b7s8,14npcwi,1bkfw1s,4ys,14lipw4,kalr6k,0,1aq,kalqzg,0,48m,2j6hqf,zik0zk,0,33mcjk,0,5'.split`,`.map(a=>('0'.repeat(32)+parseInt(a,36).toString(2)).substr(-32)).join``.match(/.{1,3}/g).map(a=>` .:\`|;'
`[parseInt(a,2)]).join``:~~((T=Math.min(z('/4/20'),z(` ${a[1]} ${++a[2]} 0:4:20`),z(' 4:20'),z(' 0:4:20'),z(' 16:20'),z(' 0:16:20'))/1000)/60)+` minutes and ${~~(T%60)} seconds left until your next hit.`

alert(f())```
</div>
</div>
</p>

<p>In the following code snippet you can set the date to test the ascii art</p>

<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>day=prompt('Day?', 12);
month=prompt('Month?', 'Apr');
f=
_=>(a=(d=Date)(c=new d(),z=O=>Math.abs(new d(a[3]+O)-c)).split` `)[1]==month&a[2]==day|~a[4].search(/(04|16):20/)?'0,0,2ca2o,0,10e,0,0,1eu9z4,0,22w,1ulajuo,0,bklxc,2zgg,i,120gdfk,8lc,1s1s,15,j0jf9c,7em8,tac,10,190zcw0,tm8w,ksk,hra0ia,mihog0,3aels,wy,iv8e15,b98u80,cvs1s,575,9fm71g,190zcw0,bg7vgg,1t4,148d4lu,121pblx,b9ea68,2b36,iv8hn5,9zleso,15kytz4,98cp,4fwpwk,zir9ud,1h9u3ln,11c6vb4,84kda8,kbuo05,b98u84,14possy,k9su6i,a26hwk,zvft34,kavrpc,1tn1j4,1r3jis,kamgao,a5bhq8,2b2q,beyt6x,j0y810,muhiww,9xl,a5b7s8,14npcwi,1bkfw1s,4ys,14lipw4,kalr6k,0,1aq,kalqzg,0,48m,2j6hqf,zik0zk,0,33mcjk,0,5'.split`,`.map(a=>('0'.repeat(32)+parseInt(a,36).toString(2)).substr(-32)).join``.match(/.{1,3}/g).map(a=>` .:\`|;'
`[parseInt(a,2)]).join``:~~((T=Math.min(z('/4/20'),z(` ${a[1]} ${++a[2]} 0:4:20`),z(' 4:20'),z(' 0:4:20'),z(' 16:20'),z(' 0:16:20'))/1000)/60)+` minutes and ${~~(T%60)} seconds left until your next hit.`

alert(f())</code>```

Title: 420 <s>Blaze</s> Golf It

Body:
This is a pretty simple challenge, but (I hope) a fun one.

Task

If right now either the month is 4 and the day is 20, the hour (on a 12 hour clock) is 4 and the minute is 20, or the minute is 4 and the second is 20, print this ascii art:

```<code>                        .
                       .:.
                       :|:
                      .:|:.
                      ::|::
       :.             ::|::             .:
       :|:.          .::|::.          .:|:
       ::|:.         :::|:::         .:|:;
       `::|:.        :::|:::        .:|::'
        ::|::.       :::|:::       .::|:;
        `::|::.      :::|:::      .::|::'
         :::|::.     :::|:::     .::|::;
         `:::|::.    :::|:::    .::|::;'
`::.      `:::|::.   :::|:::   .::|::;'     .:;'
 `:::..    `;::|::.  :::|:::  .::|:::    ::::;
   `:::::.    ':|::. :::|::: .::|:'   ,::::;'
     `:::::.    ':|:::::|:::::|:'   :::::;'
       `:::::.:::::|::::|::::|::::.,:::;'
          ':::::::::|:::|:::|:::::::;:'
             ':::::::|::|::|:::::::''
                  `::::::::::;'
                 .:;'' ::: ``::.
                      :':':
                        ;
</code>```

You can have trailing spaces.

Otherwise, print the number of minutes and seconds left until the next such occasion in the format: %d minutes and %d seconds left until your next hit. with the time being minimized.

This is code-golf, so shortest code in bytes wins!

P.S. If this challenge is too inappropriate for this site, tell me and I'll change it.

Body:
Javascript ES6, 905 bytes

Whew.. The 12 hour clock killed my otherwise short (ahum) solution.

905 bytes to print 898 chars of ascii art yay

_=>(a=(d=Date)(c=new d(),z=O=>Math.abs(new d(a[3]+O)-c)).split` `)[1]=='Apr'&a[2]==20|~a[4].search(/(04|16):20/)?'0,0,2ca2o,0,10e,0,0,1eu9z4,0,22w,1ulajuo,0,bklxc,2zgg,i,120gdfk,8lc,1s1s,15,j0jf9c,7em8,tac,10,190zcw0,tm8w,ksk,hra0ia,mihog0,3aels,wy,iv8e15,b98u80,cvs1s,575,9fm71g,190zcw0,bg7vgg,1t4,148d4lu,121pblx,b9ea68,2b36,iv8hn5,9zleso,15kytz4,98cp,4fwpwk,zir9ud,1h9u3ln,11c6vb4,84kda8,kbuo05,b98u84,14possy,k9su6i,a26hwk,zvft34,kavrpc,1tn1j4,1r3jis,kamgao,a5bhq8,2b2q,beyt6x,j0y810,muhiww,9xl,a5b7s8,14npcwi,1bkfw1s,4ys,14lipw4,kalr6k,0,1aq,kalqzg,0,48m,2j6hqf,zik0zk,0,33mcjk,0,5'.split`,`.map(a=>('0'.repeat(32)+parseInt(a,36).toString(2)).substr(-32)).join``.match(/.{1,3}/g).map(a=>` .:\`|;'
`[parseInt(a,2)]).join``:~~((T=Math.min(z('/4/20'),z(` ${a[1]} ${++a[2]} 0:4:20`),z(' 4:20'),z(' 0:4:20'),z(' 16:20'),z(' 0:16:20'))/1000)/60)+` minutes and ${~~(T%60)} seconds left until your next hit.`

Ungolfed code

Note: The ungolfed code will not execute

function() {
    // (all vars here are actually global)
    var d = Date; // short reference to Date object
    var dateString = Date() // "Tue Apr 12 2016 20:13:00 GMT+0200 (W. Europe Daylight Time)"
    .split` `; // ["Tue", "Apr", "12", ...]
    var currentDate = new Date();
    dateDiff = function(toAppend) {
        return Math.abs( // no dates in the past
            new Date(dateString[3] + toAppend) // new Date('2016' + something)
            - currentDate // substract the current date.
                          // Thanks JS for the datetime implementation
        );
    }

    if ((dateString[1] == 'Apr' & dateString[2] == 20) |
        ~dateString[4].search(/(04|16):20/)) { // if the time doesn't contain 04:20 or
                                               // 16:20, this will return -1. ~-1 is 0
                                               // and thus falsy
        alert(printAscii());
    } else {
        alert(printTimeLeft());
    }
}

function printAscii() {
    var magicString = '0,0,2ca2o,0,10e,0,0,1eu9z4,0,22w,1ulajuo,0,bklxc,2zgg,i,120gdfk,8lc,1s1s,15,j0jf9c,7em8,tac,10,190zcw0,tm8w,ksk,hra0ia,mihog0,3aels,wy,iv8e15,b98u80,cvs1s,575,9fm71g,190zcw0,bg7vgg,1t4,148d4lu,121pblx,b9ea68,2b36,iv8hn5,9zleso,15kytz4,98cp,4fwpwk,zir9ud,1h9u3ln,11c6vb4,84kda8,kbuo05,b98u84,14possy,k9su6i,a26hwk,zvft34,kavrpc,1tn1j4,1r3jis,kamgao,a5bhq8,2b2q,beyt6x,j0y810,muhiww,9xl,a5b7s8,14npcwi,1bkfw1s,4ys,14lipw4,kalr6k,0,1aq,kalqzg,0,48m,2j6hqf,zik0zk,0,33mcjk,0,5' // ;)
    var splitted = magicString.split`,`;
    var binarySequence = splitted.map(function(piece) {
        return ('0'.repeat(32) + // 000000000... this will be padded
            parseInt(a,36) // parseInt('190zcw0',36) -> 000000002722627584
            .toString(2) // -> 10100010010010000000000000000000
        ).substr(-32) // left pad binary sequence
    }).join``; // create one big binary sequence from several smaller
    var groupsOfThree = binarySequence.match(/.{1,3}/g);
    return groupsOfThree.map(function(three) {
        return ` .:\`|;'\n`[parseInt(a,2)]; // magic.. turn 010 into : etc
    }).join``; // create them blaze
}

function printTimeLeft() {
    // this is way longer than it should be.. probably
    var minimumTimeDifference = Math.min(
        dateDiff('/4/20'), // -> Difference between now and 2016/4/20 00:00:00
        dateDiff(' 4:20'), // 2016 04:20:00.. Sadly the 2016 is needed (i think)
        dateDiff(' 0:4:20'), // 2016 00:04:20
        dateDiff(' 16:20'), // Damn 12 hour clock :(
        dateDiff(' 0:16:20'),
        dateDiff(` ${dateString[1]} // 2016 Apr
                   ${dateString[2]+1} // 2016 Apr 13 (12+1)
                   0:4:20` // Check the first occurrence of 4 minutes and 20 seconds
                           // the next day
    )
    var timeInSeconds = minimumTimeDifference / 1000;
    return Math.floor(timeInSeconds) + // ~~ works like Math.floor
        ` minutes and ${Math.floor(timeInSeconds%60)} seconds left until your next hit.`;
}

Try it!

f=
_=>(a=(d=Date)(c=new d(),z=O=>Math.abs(new d(a[3]+O)-c)).split` `)[1]=='Apr'&a[2]==20|~a[4].search(/(04|16):20/)?'0,0,2ca2o,0,10e,0,0,1eu9z4,0,22w,1ulajuo,0,bklxc,2zgg,i,120gdfk,8lc,1s1s,15,j0jf9c,7em8,tac,10,190zcw0,tm8w,ksk,hra0ia,mihog0,3aels,wy,iv8e15,b98u80,cvs1s,575,9fm71g,190zcw0,bg7vgg,1t4,148d4lu,121pblx,b9ea68,2b36,iv8hn5,9zleso,15kytz4,98cp,4fwpwk,zir9ud,1h9u3ln,11c6vb4,84kda8,kbuo05,b98u84,14possy,k9su6i,a26hwk,zvft34,kavrpc,1tn1j4,1r3jis,kamgao,a5bhq8,2b2q,beyt6x,j0y810,muhiww,9xl,a5b7s8,14npcwi,1bkfw1s,4ys,14lipw4,kalr6k,0,1aq,kalqzg,0,48m,2j6hqf,zik0zk,0,33mcjk,0,5'.split`,`.map(a=>('0'.repeat(32)+parseInt(a,36).toString(2)).substr(-32)).join``.match(/.{1,3}/g).map(a=>` .:\`|;'
`[parseInt(a,2)]).join``:~~((T=Math.min(z('/4/20'),z(` ${a[1]} ${++a[2]} 0:4:20`),z(' 4:20'),z(' 0:4:20'),z(' 16:20'),z(' 0:16:20'))/1000)/60)+` minutes and ${~~(T%60)} seconds left until your next hit.`

alert(f())

In the following code snippet you can set the date to test the ascii art

day=prompt('Day?', 12);
month=prompt('Month?', 'Apr');
f=
_=>(a=(d=Date)(c=new d(),z=O=>Math.abs(new d(a[3]+O)-c)).split` `)[1]==month&a[2]==day|~a[4].search(/(04|16):20/)?'0,0,2ca2o,0,10e,0,0,1eu9z4,0,22w,1ulajuo,0,bklxc,2zgg,i,120gdfk,8lc,1s1s,15,j0jf9c,7em8,tac,10,190zcw0,tm8w,ksk,hra0ia,mihog0,3aels,wy,iv8e15,b98u80,cvs1s,575,9fm71g,190zcw0,bg7vgg,1t4,148d4lu,121pblx,b9ea68,2b36,iv8hn5,9zleso,15kytz4,98cp,4fwpwk,zir9ud,1h9u3ln,11c6vb4,84kda8,kbuo05,b98u84,14possy,k9su6i,a26hwk,zvft34,kavrpc,1tn1j4,1r3jis,kamgao,a5bhq8,2b2q,beyt6x,j0y810,muhiww,9xl,a5b7s8,14npcwi,1bkfw1s,4ys,14lipw4,kalr6k,0,1aq,kalqzg,0,48m,2j6hqf,zik0zk,0,33mcjk,0,5'.split`,`.map(a=>('0'.repeat(32)+parseInt(a,36).toString(2)).substr(-32)).join``.match(/.{1,3}/g).map(a=>` .:\`|;'
`[parseInt(a,2)]).join``:~~((T=Math.min(z('/4/20'),z(` ${a[1]} ${++a[2]} 0:4:20`),z(' 4:20'),z(' 0:4:20'),z(' 16:20'),z(' 0:16:20'))/1000)/60)+` minutes and ${~~(T%60)} seconds left until your next hit.`

alert(f())


问:
All together now
Given a list of digits 1 through 9, output whether each digit is grouped together as a single contiguous block. In other words, no two of the same digit are separated by different digits. It's OK if a digit doesn't appear at all. Fewest bytes wins.

Input: A non-empty list of digits 1 through 9. This can be as a decimal number, string, list, or similar sequence.

Output: A consistent Truthy value if all the digits are grouped in contiguous blocks, and a consistent Falsey value if they are not.

True cases:

```<code>3
51
44999911
123456789
222222222222222222222
</code>```

False cases:

```<code>818
8884443334
4545
554553
1234567891
</code>```

var QUESTION_ID=77608,OVERRIDE_USER=20260;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/77608/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="
"+e.body.replace(OVERRIDE_REG,"")+"
")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}</code>```

 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

```

答:
Factor, 22 bytes

```<code>[ dup natural-sort = ]
</code>```

Does what it says on the tin. As an anonymouse function, you should call this, or make it a : word ;.

Title: All together now

Body:
Factor, 22 bytes

[ dup natural-sort = ]

Does what it says on the tin. As an anonymouse function, you should call this, or make it a : word ;.


问:
Drawing a gradient in ASCII art
Task description:

Write a program as short as possible to draw a radial gradient in ASCII art. The size of the output grid is predefined. The center point and the characters to be used for the gradient are provided as input to the program.

The gradient will be 70×25 character cells in size with the following specifications

The upper-left corner of the grid has the coordinates (0, 0).

The gradient, consisting of the characters provided, is mapped into 35 length units. A length unit is one character tall and two characters wide (since monospaced fonts usually have characters twice as high as they are wide).

Within those 35 LU the current distance from the center point is multiplied by number of gradient characters/35 to get the index of the character to draw at that point. Fractional numbers for the index are rounded towards zero here. The length units are to be left as a real number. (Of course, if the results are the same, the implementation doesn't matter.)

Beyond those 35 LU only the last gradient character appears. However, since the last gradient »band« already starts within the 35 LU, the last character starts appearing short of 35 LU already.

Input:

The input is given on standard input and consists of three lines, each terminated by a line break:

The x coordinate of the gradient center point

The y coordinate of the gradient center point

The characters to use for drawing the gradient. Those may include spaces.

Output:

Output is the gradient as defined by the rules above on standard output. The standard error stream is ignored. Each line of the gradient is terminated by a line break. No other characters except those defined by the input may occur.

Sample input 1:

```<code>58
14
 .:;+=xX$&
</code>```

Sample output 1:

```<code>&&$$$$$$$$XXXXXXXXxxxxxxxxx===========++++++++++++++++++++++++++++++++
&$$$$$$$$XXXXXXXXxxxxxxxxx=========+++++++++++++;;;;;;;;;;;;;;;;;;;;;+
$$$$$$$$XXXXXXXXxxxxxxxx=========+++++++++++;;;;;;;;;;;;;;;;;;;;;;;;;;
$$$$$$$XXXXXXXXxxxxxxxx========++++++++++;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$$$$$$XXXXXXXXxxxxxxxx========+++++++++;;;;;;;;;;;;;:::::::::::::;;;;;
$$$$$XXXXXXXXxxxxxxxx=======+++++++++;;;;;;;;;;;:::::::::::::::::::::;
$$$$$XXXXXXXxxxxxxxx=======+++++++++;;;;;;;;;:::::::::::::::::::::::::
$$$$XXXXXXXXxxxxxxx=======++++++++;;;;;;;;;:::::::::::::::::::::::::::
$$$$XXXXXXXxxxxxxx========+++++++;;;;;;;;::::::::::...............::::
$$$XXXXXXXXxxxxxxx=======+++++++;;;;;;;;:::::::::...................::
$$$XXXXXXXxxxxxxx=======++++++++;;;;;;;::::::::.......................
$$$XXXXXXXxxxxxxx=======+++++++;;;;;;;::::::::.........       ........
$$$XXXXXXXxxxxxxx=======+++++++;;;;;;;:::::::........           ......
$$$XXXXXXXxxxxxxx=======+++++++;;;;;;;:::::::.......             .....
$$$XXXXXXXxxxxxxx=======+++++++;;;;;;;:::::::.......             .....
$$$XXXXXXXxxxxxxx=======+++++++;;;;;;;:::::::.......             .....
$$$XXXXXXXxxxxxxx=======+++++++;;;;;;;:::::::........           ......
$$$XXXXXXXxxxxxxx=======+++++++;;;;;;;::::::::.........       ........
$$$XXXXXXXxxxxxxx=======++++++++;;;;;;;::::::::.......................
$$$XXXXXXXXxxxxxxx=======+++++++;;;;;;;;:::::::::...................::
$$$$XXXXXXXxxxxxxx========+++++++;;;;;;;;::::::::::...............::::
$$$$XXXXXXXXxxxxxxx=======++++++++;;;;;;;;;:::::::::::::::::::::::::::
$$$$$XXXXXXXxxxxxxxx=======+++++++++;;;;;;;;;:::::::::::::::::::::::::
$$$$$XXXXXXXXxxxxxxxx=======+++++++++;;;;;;;;;;;:::::::::::::::::::::;
$$$$$$XXXXXXXXxxxxxxxx========+++++++++;;;;;;;;;;;;;:::::::::::::;;;;;
</code>```

Sample input 2:

```<code>0
0
X.X.X.X
</code>```

Sample output 2:

```<code>XXXXXXXXXX..........XXXXXXXXXX..........XXXXXXXXXX..........XXXXXXXXXX
XXXXXXXXXX..........XXXXXXXXXX..........XXXXXXXXXX..........XXXXXXXXXX
XXXXXXXXXX..........XXXXXXXXXX..........XXXXXXXXXX..........XXXXXXXXXX
XXXXXXXX............XXXXXXXXXX..........XXXXXXXXXX..........XXXXXXXXXX
XXXXXX.............XXXXXXXXXX...........XXXXXXXXXX..........XXXXXXXXXX
..................XXXXXXXXXXX..........XXXXXXXXXX...........XXXXXXXXXX
................XXXXXXXXXXXX...........XXXXXXXXXX..........XXXXXXXXXXX
...............XXXXXXXXXXXX...........XXXXXXXXXX...........XXXXXXXXXXX
............XXXXXXXXXXXXXX...........XXXXXXXXXXX..........XXXXXXXXXXXX
.........XXXXXXXXXXXXXXX............XXXXXXXXXXX...........XXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXX............XXXXXXXXXXX...........XXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXX.............XXXXXXXXXXX...........XXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXX..............XXXXXXXXXXXX...........XXXXXXXXXXXXXXX
XXXXXXXXXXXXXXX................XXXXXXXXXXXX............XXXXXXXXXXXXXXX
XXXXXXXXXXX..................XXXXXXXXXXXXX............XXXXXXXXXXXXXXXX
...........................XXXXXXXXXXXXX............XXXXXXXXXXXXXXXXXX
........................XXXXXXXXXXXXXXX............XXXXXXXXXXXXXXXXXXX
......................XXXXXXXXXXXXXXX.............XXXXXXXXXXXXXXXXXXXX
..................XXXXXXXXXXXXXXXXX.............XXXXXXXXXXXXXXXXXXXXXX
.............XXXXXXXXXXXXXXXXXXXX..............XXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...............XXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXX...............XXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXX.................XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXX...................XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXX......................XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
</code>```

Sample input 3:

```<code>70
25
.:+#
</code>```

Sample output 3:

```<code>######################################################++++++++++++++++
#################################################+++++++++++++++++++++
#############################################+++++++++++++++++++++++++
##########################################++++++++++++++++++++++++++++
#######################################+++++++++++++++++++++++++++++++
####################################++++++++++++++++++++++++++++++++++
##################################++++++++++++++++++++++++++++++++++++
################################++++++++++++++++++++++++++++++++++++++
##############################++++++++++++++++++++++++++++++++::::::::
#############################+++++++++++++++++++++++++++::::::::::::::
###########################+++++++++++++++++++++++++::::::::::::::::::
##########################++++++++++++++++++++++++::::::::::::::::::::
#########################++++++++++++++++++++++:::::::::::::::::::::::
########################+++++++++++++++++++++:::::::::::::::::::::::::
#######################++++++++++++++++++++:::::::::::::::::::::::::::
######################++++++++++++++++++++::::::::::::::::::::::::::::
#####################+++++++++++++++++++::::::::::::::::::::::::::::::
####################+++++++++++++++++++::::::::::::::::::::::::.......
####################++++++++++++++++++::::::::::::::::::::::..........
###################+++++++++++++++++++::::::::::::::::::::............
###################++++++++++++++++++:::::::::::::::::::..............
###################+++++++++++++++++:::::::::::::::::::...............
##################++++++++++++++++++::::::::::::::::::................
##################++++++++++++++++++:::::::::::::::::.................
##################++++++++++++++++++:::::::::::::::::.................
</code>```

Sample input 4

```<code>59
1
 abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789<>|,.-#+!$%&/()=?*'_:;
</code>```

Sample output 4

```<code>!+#-,|><87654210ZYWVUTRQPONLKJIHFEDCBzyxwutsrqonmlkjhgfedcbbbcdefghjkl
!+#-,|><87654210ZYWVUTRQPONLKJIHFEDCAzyxwutsrqonmljihgfdcba abcdfghijl
!+#-,|><87654210ZYWVUTRQPONLKJIHFEDCBzyxwutsrqonmlkjhgfedcbbbcdefghjkl
!+#-,|><97654310ZYXVUTSQPONMKJIHGEDCBAyxwvutrqponmkjihgffeedeeffghijkm
$+#-.|><98654320ZYXWUTSRQONMLKIHGFEDBAzyxwutsrqponmlkjihhggggghhijklmn
$!#-.,|<987643210YXWVUSRQPONLKJIHGEDCBAzywvutsrqponmllkjjjiiijjjkllmno
$!+#.,|><87654210ZYXVUTSRQONMLKJHGFEDCBAzywvutsrrqponnmmlllllllmmnnopq
%!+#-.|><987543210YXWVUTRQPONMLJIHGFEDCBAzyxwvutsrrqppooonnnnnoooppqrr
%$!+-.,|><87654310ZYXWVTSRQPONMLJIHGFEDCBAzyxxwvuttssrrqqqqqqqqqrrsstt
&%!+#-.,><987643210ZYXVUTSRQPONMLKJIHGFEDCBAzyyxwvvuutttssssssstttuuvv
&%$!+#.,|><986543210ZYWVUTSRQPONMLKJIHGFEDDCBAzzyyxwwwvvvuuuuuvvvwwwxy
/&%$!#-.,|><976543210ZYXVUTSRQPONMLKKJIHGFEEDCBBAAzzyyyxxxxxxxxxyyyzzA
(/&%!+#-.,|><876543210ZYXWVUTSRQPONMLKJJIHGGFEEDCCBBBAAAzzzzzzzAAABBBC
)(/%$!+#-.,|><876543210ZYXWVUTSRQPPONMLKKJIIHGGFFEEDDDCCCCCCCCCCCDDDEE
=)(&%$!+#-.,|><986543210ZYYXWVUTSRQPPONMMLKKJIIHHGGGFFFEEEEEEEEEFFFGGG
?=)(&%$!+#-.,|><9876543210ZYXWVVUTSRRQPOONMMLLKJJJIIIHHHHHHHHHHHHHIIIJ
*?=)(/%$!+#-.,|><98765432210ZYXWWVUTSSRQQPOONNMMLLLKKKJJJJJJJJJJJKKKLL
'*?=)(/&%$!+#-.,|><98765432110ZYXXWVUUTSSRRQPPOOONNNMMMMMLLLLLMMMMMNNN
_'*?=)(/&%$!+#-.,|><988765432210ZYYXWWVUUTTSSRRQQQPPPOOOOOOOOOOOOOPPPQ
:_'*?=)(/&%$!+##-.,|><9877654332100ZYYXXWVVUUTTTSSSRRRRQQQQQQQQQRRRRSS
;;:_'*?=)(/&%$!+#-.,,|><98876554322100ZZYYXXWWVVVUUUTTTTTTTTTTTTTTTUUU
;;;:_'*?=)(/&&%$!+#-.,,|><9987665443321100ZZYYYXXXWWWWVVVVVVVVVVVWWWWX
;;;;;:_'*?=)(/&%$$!+#-..,|>><9887665544322211000ZZZYYYYYYYYYYYYYYYYYZZ
;;;;;;:_'*??=)(/&%%$!+##-.,,|><<99877665544333222111100000000000001111
;;;;;;;;:_'*?==)(/&&%$!++#--.,,|>><<9887766655544433333322222223333334
</code>```

A week has passed. It is time to unveil the solution lengths from our university's contest:

167 – Python

  189 – Haskell

  203 – C

  210 – VB.NET

  219 – C

And our own solutions:

  91 – GolfScript

  125 – Ruby

  157 – PowerShell

ContentLicense: CC BY-SA 2.5

Title: Drawing a gradient in ASCII art

Body:
Ruby 1.9, 116 114 108 101 characters

x,y,z=*$<;25.times{|r|70.times{|c|$><<z[[(c-x.to_i+2.i*(r-y.to_i)).abs/70.0*k=z=~/$/,k-1].min]};puts}


问:
Addition on Elliptic Curves
Disclaimer: This does not do any justice on the rich topic of elliptic curves. It is simplified a lot. As elliptic curves recently got a lot of media attention in the context of encryption, I wanted to provide some small insight how "calculating" on an elliptic curve actually works.

Introduction

Elliptic curves are sets of points \$(x,y)\$ in the plane of the form \$y^2 = x^3+Ax+B\$. (Additionally, \$4A^3+27B^2 ≠ 0\$ to avoid nasty singularities.) You can consider these curves in any field. If you use the field of real numbers, the curves can be visualized and they look like this:

Source

The special thing about these curves is that they have a built in arithmetic operation that is the analogue of addition. You can add and subtract points, and this operation is both associative and commutative (an abelian group).

How does addition work?

Note: addition of points on elliptic curves is not intuitive. This kind of addition is defined the way it is because it has certain nice properties. It's weird, but it works.

As elliptic curves form a group, there is an additive identity that is the equivalent of 0. That is, adding \$0\$ to any point will not change the result. This additive identity is the "point" at infinity. All lines on the plane include this point at infinity, so adding it makes no difference.

Let's say that any given line intersects the curve at three points, which may be \$0\$, and that the sum of these three points is \$0\$. Keeping that in mind, take a look at this image.

Source

Now, the natural question is, what is \$P+Q\$? Well, if \$P+Q+R = 0\$, then \$P+Q = -R\$ (alternatively written as \$R'\$). Where is \$-R\$? It is where \$R + (-R) = 0\$, which is on the other side of the x-axis from \$R\$ so that the line through them is vertical, intersecting only \$R\$, \$-R\$, and \$0\$. You can see this in the first part of this image:

Source

Another thing you can see in these images is that the sum of a point with itself means the line is tangent to the curve.

How to find intersections of lines and elliptic curves

In the case of two distinct points

Generally there is exactly one line through two points \$P=(x_0,y_0), Q=(x_1,y_1)\$. Assuming it is not vertical and the two points are distinct, we can write it as \$y = mx+q\$. When we want to find the points of intersection with the elliptic curve we can just write

$$0 = x^3+Ax+B-y^2 = x^3+Ax+B-(mx+q)^2$$

which is a third degree polynomial. These are generally not that easy to solve, but we already know two zeros of this polynomial: The two \$x\$-coordinates \$x_0, x_1\$ of the two points we want to add!

That way we factor out the linear factors \$(x-x_0)\$ and \$(x-x_1)\$ and are left with a third linear factor whose root is the \$x\$-coordinate of the point \$R\$. (\$-R\$ too because of the symmetry. Note that if \$R = (x_2,y_2)\$ then \$-R = (x_2,-y_2)\$. The \$-\$ is from the group; it is not a vectorial minus.)

In the case of adding one point \$P\$ to itself

In this case we have to calculate the tangent of the curve at \$P=(x_0,y_0)\$. We can directly write \$m\$ and \$q\$ in terms of \$A,B,x_0\$ and \$y_0\$:

$$m = \frac{3x_0^2+A}{2y_0}$$

$$q = \frac{-x_0^3+Ax_0+2B}{2y_0}$$

We get the equation \$y = mx+q\$ and can proceed the same way as in the paragraph above.

A complete case tree

This is a complete list of how to handle all those cases:

Let \$P,Q\$ be points on the elliptic curve (including the "infinity" point \$0\$)

If \$P = 0\$ or \$Q = 0\$, then \$P+Q = Q\$ or \$P+Q = P\$, respectively

Else \$P ≠ 0\$ and \$Q ≠ 0\$, so let \$P = (x_0,y_0)\$ and \$Q = (x_1,y_1)\$:

If \$P = -Q\$ (that means \$x_0 = x_1\$ and \$y_0 = -y_1\$) then \$P+Q = 0\$

Else \$P ≠ -Q\$

If \$x_0 = x_1\$ then we have \$P=Q\$ and we calculate the tangent (see section above) in order to get \$R\$. Then \$P+Q = P+P = 2P = -R\$

Else: We can construct a line of the form \$y = mx+q\$ through those two points (see section above) in order to calculate \$R\$. Then \$P+Q=-R\$

Finite fields

For this challenge we will only consider fields of size \$p\$ where \$p\$ is prime (and because of some details \$p ≠ 2, p ≠ 3\$). This has the advantage that you can simply calculate \$\bmod p\$. The arithmetic in other fields is much more complicated.

This in this example we set \$p = 5\$ and all equalities here are congruences \$\bmod 5\$.

```<code>2+4 ≡ 6 ≡ 1
2-4 ≡ -2 ≡ 3
2*4 ≡ 8 ≡ 3
2/4 ≡ 2*4 ≡ 3 because 4*4 ≡ 16 ≡ 1, therefore 1/4 ≡ 4
</code>```

Challenge

Given the parameters \$A,B\$ of an elliptic curve, a prime field characteristic \$p\$ and two points \$P,Q\$ on the elliptic curve, return their sum.

You can assume that the parameters \$A,B\$ actually describe an elliptic curve, that means that \$4A^3+27B^2 ≠ 0\$.

You can assume that \$P,Q\$ are actually points on the elliptic curve or the \$0\$-point.

You can assume that \$p ≠ 2,3\$ is prime.

Test Cases

I made a (not very elegant) implementation in MATLAB/Octave, that you can use for your own test cases: ideone.com I hope it is correct. It did at least reproduce a few calculations I made by hand.

Note the trivial test cases that work for all curves we consider here:

Adding zero: \$P+0 = P\$

Adding the inverse: \$(x,y) + (x,-y) = 0\$

For \$p = 7, A = 0, B = 5\$ the two points \$P = (3,2)\$ and \$Q = (6,2)\$ are on the elliptic curve. Then following holds:

```<code>2*Q = Q+Q = P
2*P = P+P = (5,2)
3*P = P+P+P = (5,2)+P = (6,5)
4*P = P+P+P+P = (5,2)+(5,2) = (6,5)+(5,2) = Q
</code>```

All the points on the elliptic curve are \$(3,2),(5,2),(6,2),(3,5),(5,5),(6,5),0\$

For \$p = 13, A = 3, B = 8\$ we get

```<code>(1,8)+(9,7) = (2,10)
(2,3)+(12,11) = (9,7)
2*(9,6) = (9,7)
3*(9,6) = 0
</code>```

For \$p = 17, A = 2, B = 2\$ and \$P=(5,1)\$ we get

```<code>2*P = (6,3)
3*P = (10,6)
4*P = (3,1)
5*P = (9,16)
6*P = (16,13)
7*P = (0,6)
8*P = (13,7)
9*P = (7,6)
10*P = (7,11)
</code>```

If you are really ambitious, take

```<code>p = 1550031797834347859248576414813139942411
A = 1009296542191532464076260367525816293976
x0 = 1317953763239595888465524145589872695690
y0 = 434829348619031278460656303481105428081
x1 = 1247392211317907151303247721489640699240
y1 = 207534858442090452193999571026315995117
</code>```

and try to find a natural number \$n\$ such that \$n\times(x_0,y_0) = (x_1,y_1)\$. Further information here.

Appendix

First of all a big THANK YOU to @El'endiaStarman for reviewing and editing my draft!

Why elliptic curves?

Well it might appear like some kind of arbitrary equation, but it is not, it is quite general:
Generally we consider those geometric "shapes" in the projective plane (that is where the "infinity" is coming from. There we consider all homogeneous polynomials of third degree. (Those of lower or higher degree would be too difficult or just trivial to examine.) After applying some restrictions in order to get the nice properties we want, and after dehomogenizing those polynomials (projecting into one of three affine planes) we end up with equations like \$y^2+axy+by = x^3+cx^2+dx+e\$ This is an elliptic curve in the long Weierstrass form. These are basically the same curves as we considered, but just somewhat skewed. With a linear coordinate transform, you can easily make a short Weierstras equation out of that. example, which still hold all the interesting properties.

Why did we exclude \$p=2,3\$?

This has to do with the fact that for the short Weierstrass form we need the restriction \$4A^3+27B^2 ≠ 0\$ in order to avoid singularities (more on that below). In a field of characteristic 2 we have \$4 = 0\$ and in a field of characteristic 3 we have \$27 = 0\$, this makes it impossible to have curves in short Weierstrass form for those kinds of fields.

What are singularities?

If the equation \$4A^3+27B^2=0\$ holds, we have singularities like following: As you see at those points you cannot find a derivative and therefore no tangent, which "kills" the operation. You might look at the equations \$y^2 = x^3\$ or \$y^2 = x^3-3x+2\$

Why are they called elliptic curves anyway?

The reason is that equations of this shape pop up in elliptic integrals, e.g. which are what you get when you want to caclulate the e.g. the arclength of an ellipse. A short slideshow about the origin of the name.

What do they have to do with cryptography?

There are ways to compute \$nP = P+P+...+P\$ very efficiently. This can be used for example in the Diffie Hellman key exchange. The modular arithmetic can be replaced by the addition on torsion subgroups, these are just the points on the curve that have finite order. (That means that \$mP = 0\$ for some \$m\$, which is basically just calculating \$\bmod m\$ ).

答:
Python 3, <s>193</s> 191 bytes

A solution based on Rhyzomatic's Pyth answer and their Python logic. In particular. I liked how they found the third root of a monic cubic polynomial x^3 + bx^2 + cx + d when you have two roots x_1 and x_2 by noting that b == x_1 + x_2 + x_3 and subtracting accordingly. I plan to add an explanation, golf this, and perhaps transpile it into Ruby, if Ruby turns out to be shorter.

def e(p,A,B,P,Q):
 if P==0:return Q
 if Q==0:return P
 f,g=P;j,k=Q
 if f==j:
  if g==-k%p:return 0
  m=(3*f*f+A)*pow(2*j,p-2)
 else:m=(g-k)*pow(f-j,p-2)
 x=m*m-f-j;y=m*(f-x)-g;return(x%p,y%p)
```

<p><strong>Ungolfing:</strong></p>

<pre class="lang-python prettyprint-override"><code>def elliptic_curve_addition(p, A, B, P, Q):
    if P == 0:
        return Q
    if Q == 0:
        return P
    f,q = P
    j,k = Q
    if f==j:
        if g == (-k) % p:
            return 0
        m = (3 * f**2 + A) * pow(2*j, p-2)
    else:
        m = (g-k) * pow(f-j, p-2)
    x = m**2 - f - j
    y = m * (f-x) - g
    return (x%p, y%p)
</code>```

ContentLicense: CC BY-SA 4.0

Title: Addition on Elliptic Curves

Body:
Python 3, <s>193</s> 191 bytes

A solution based on Rhyzomatic's Pyth answer and their Python logic. In particular. I liked how they found the third root of a monic cubic polynomial x^3 + bx^2 + cx + d when you have two roots x_1 and x_2 by noting that b == x_1 + x_2 + x_3 and subtracting accordingly. I plan to add an explanation, golf this, and perhaps transpile it into Ruby, if Ruby turns out to be shorter.

def e(p,A,B,P,Q):
 if P==0:return Q
 if Q==0:return P
 f,g=P;j,k=Q
 if f==j:
  if g==-k%p:return 0
  m=(3*f*f+A)*pow(2*j,p-2)
 else:m=(g-k)*pow(f-j,p-2)
 x=m*m-f-j;y=m*(f-x)-g;return(x%p,y%p)

Ungolfing:

def elliptic_curve_addition(p, A, B, P, Q):
    if P == 0:
        return Q
    if Q == 0:
        return P
    f,q = P
    j,k = Q
    if f==j:
        if g == (-k) % p:
            return 0
        m = (3 * f**2 + A) * pow(2*j, p-2)
    else:
        m = (g-k) * pow(f-j, p-2)
    x = m**2 - f - j
    y = m * (f-x) - g
    return (x%p, y%p)


问:
Tips for golfing in dc
What general tips do you have for golfing in dc?

dc is a calculator utility for UNIX/Linux that predates the C language. I am interested in how to make my dc programs (calculations?) shorter. I'm looking for ideas that can be applied to general code-golf that are at least a little bit specific to dc (eg. removing comments is not a helpful answer)

Please post one tip per answer.

答:
You can save input with d

By using d, which duplicates the ToS (top of stack) you can move the input out of the way for later use, while still being able to use it.

Title: Tips for golfing in dc


Title: 420 <s>Blaze</s> Golf It

Body:
Python 2, 371 bytes

This source contains non-printable bytes, so it is presented as a hexdump that can be decoded with xxd -r.

00000000: efbb bf66 726f 6d20 7469 6d65 2069 6d70  ...from time imp
00000010: 6f72 742a 0a74 3d74 696d 6528 290a 693d  ort*.t=time().i=
00000020: 300a 7768 696c 6527 3034 3a32 3027 6e6f  0.while'04:20'no
00000030: 7420 696e 2073 7472 6674 696d 6528 2725  t in strftime('%
00000040: 6d3a 2564 2572 272c 6c6f 6361 6c74 696d  m:%d%r',localtim
00000050: 6528 742b 6929 293a 692b 3d31 0a70 7269  e(t+i)):i+=1.pri
00000060: 6e74 5b22 7801 74cd c701 c430 0844 d1bb  nt["x.t....0.D..
00000070: aaf0 cd99 0286 6654 887a dfa0 f41d 7136  ......fT.z....q6
00000080: 8f61 7829 0b6f 5c72 bdb6 9414 de86 d2eb  .ax).o\r........
00000090: 9894 d4e7 64f7 de39 099a 8ed8 32b5 d34a  ....d..9....2..J
000000a0: e8c9 2a53 9da4 371a b1d0 a3d4 18e8 b212  ..*S..7.........
000000b0: 5a25 a139 158a ac90 4cba 7692 4007 c62e  Z%.9....L.v.@...
000000c0: 81b8 31c4 9682 04e2 6ab8 8f21 3bb3 3ce1  ..1.....j..!;.<.
000000d0: 7582 0163 8524 79a8 c175 cb58 7ce5 45ff  u..c.$y..u.X|.E.
000000e0: b3b7 8cc7 bfbe fbaa 9b95 b068 1837 db90  ...........h.7..
000000f0: a546 b54a 5cb9 5c38 6801 0936 a2a8 a85e  .F.J\.\8h..6...^
00000100: 6ca3 4c3e 8e83 a4ef 1412 12ac 7027 7075  l.L>........p'pu
00000110: 2084 ca61 026b 5c30 286e a1fe 222e 6465   ..a.k\0(n..".de
00000120: 636f 6465 2827 7a69 7027 292c 2725 6420  code('zip'),'%d
00000130: 6d69 6e75 7465 7320 616e 6420 2564 2073  minutes and %d s
00000140: 6563 6f6e 6473 206c 6566 7420 756e 7469  econds left unti
00000150: 6c20 796f 7572 206e 6578 7420 6869 742e  l your next hit.
00000160: 2725 2869 2f36 302c 6925 3630 295d 5b69  '%(i/60,i%60)][i
00000170: 3e30 5d                                  >0]

Readable part:

from time import*
t=time()
i=0
while'04:20'not in strftime('%m:%d%r',localtime(t+i)):i+=1
print["(ZLIB DATA)".decode('zip'),'%d minutes and %d seconds left until your next hit.'%(i/60,i%60)][i>0]


答:
J, 8 bytes

```<code>-:]/:i.~
</code>```

Test it with J.js.

How it works

```<code>-:]/:i.~  Monadic verb. Argument: y (list of digits)

     i.~  Find the index in y of each d in y.
  ]/:     Sort y by the indices.
-:        Match; compare the reordering with the original y.
</code>```

Title: All together now

Body:
Given a list of digits 1 through 9, output whether each digit is grouped together as a single contiguous block. In other words, no two of the same digit are separated by different digits. It's OK if a digit doesn't appear at all. Fewest bytes wins.

Input: A non-empty list of digits 1 through 9. This can be as a decimal number, string, list, or similar sequence.

Output: A consistent Truthy value if all the digits are grouped in contiguous blocks, and a consistent Falsey value if they are not.

True cases:

```<code>3
51
44999911
123456789
222222222222222222222
</code>```

False cases:

```<code>818
8884443334
4545
554553
1234567891
</code>```

var QUESTION_ID=77608,OVERRIDE_USER=20260;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/77608/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="
"+e.body.replace(OVERRIDE_REG,"")+"
")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}</code>```

 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

```

Body:
J, 8 bytes

-:]/:i.~

Test it with J.js.

How it works

-:]/:i.~  Monadic verb. Argument: y (list of digits)

     i.~  Find the index in y of each d in y.
  ]/:     Sort y by the indices.
-:        Match; compare the reordering with the original y.


问:
Convert phrases to reverse style

The Challenge

Convert a phrase of two words to reverse style: candy bar -> bar le candy.

Specifications

There will be one word (only a-zA-Z0-9 + -), a space (), and then another word.

For equal length, score is used to determine winner.

Test cases:

```<code>candy bar -> bar le candy
code golf -> golf le code
programming puzzles -> puzzles le programming
</code>```

答:
C# - 43 bytes

```<code>string.Join(" le ",x.Split(' ').Reverse());
</code>```

Title: Convert phrases to reverse style

Body:
C# - 43 bytes

string.Join(" le ",x.Split(' ').Reverse());


答:
05AB1E, (4 bytes) by Adnan

The sequence is A126804, and the code to produce it is

```<code>D·ŸP
</code>```

Try it online

I've never even looked at a program in 05AB1E before, it looks like a pretty cool language!

Body:
05AB1E, (4 bytes) by Adnan

The sequence is A126804, and the code to produce it is

D·ŸP

Try it online

I've never even looked at a program in 05AB1E before, it looks like a pretty cool language!


问:
Golf the xᵗʰ root of x
While bored in high-school (when I was half my current age...), I found that \$f(x) = x^{x^{-1}}\$ had some interesting properties, including e.g. that the maximum \$f\$ for \$0 ≤ x\$ is \$f(e)\$, and that the binding energy per nucleon of an isotope can be approximated as \$6 × f(x ÷ 21)\$...

Anyway, write the shortest function or program that calculates the xth root of x for any number in your language's domain.

Examples cases

For all languages

```<code>     -1   >       -1
   ¯0.2   >    -3125
   ¯0.5   >        4
    0.5   >     0.25
      1   >        1
      2   >    1.414
      e   >    1.444
      3   >    1.442
    100   >    1.047
  10000   >    1.001
</code>```

For languages that handle complex numbers

```<code>   -2   >        -0.7071i
    i   >            4.81
   2i   >    2.063-0.745i
 1+2i   >   1.820-0.1834i
 2+2i   >   1.575-0.1003i
</code>```

For languages that handle infinities

```<code>-1/∞   >   0    (or ∞ or ̃∞)
   0   >   0    (or 1 or ∞)
 1/∞   >   0
   ∞   >   1
  -∞   >   1
</code>```

For languages that handle both infinities and complex numbers

```<code> -∞-2i   >   1      (or ̃∞)
</code>```

 ̃∞ denotes directed infinity.

答:
SQL (MySQL), 60 bytes

```<code>CREATE FUNCTION G(X REAL) RETURNS REAL RETURN POWER(X,1./X);
</code>```

Caps lock is cruise control for <s>cool</s> golf.

Title: Golf the xᵗʰ root of x

Body:
SQL (MySQL), 60 bytes

CREATE FUNCTION G(X REAL) RETURNS REAL RETURN POWER(X,1./X);

Caps lock is cruise control for <s>cool</s> golf.


答:
JavaScript (ES6), 537 bytes

alert((f=t=>new Date(Date.now()+t*1e3).toISOString().match`(T16|04)[-:]20`)(i=0)?"À\u0019\u0002û1!°?4\u0002ë14!°>C3\u0002=\u0001Ê34\u0003Ê1\u0002=4\u00011C3\u000114\u0002=C\u0013ð4\u0009\u001fCS\u0002m34\u0001>Ià14s\u0002>C3\u0001=IÐ1CS\u0002n34\u0013À4\u0009\u001c34s\u0002?I3\u0001;I°1C3%ð6I3\u0001:I 1C3ub3\u0001l4\u00134\u0009\u001934S\u0007\u001bS'`\u0011 V34\u0013\u00004\u0009\u001034\u0009:Z\u0002i³\u0001zC3\u00014\u00091Cs8Z'°6\u001b 74K³4\u00079['Ð6\u001b³4J£4\u001a8Y' yó4I4]s\u0002Ê7M34CÓw\u0002«6u\u00021u\u0007`6\u0013\u0002ëss#ÀY".replace(/./g,c=>(l=" .\n:|;`',0123456")[(n=c.charCodeAt())&15]+l[n>>4]).replace(/.\d+/g,c=>c[0].repeat(parseInt(c.slice(1),7)+3)):eval('for(;!f(++i););`${i/60|0} minutes and ${i%60|0} seconds left until your next hit.`'))```
</div>
</div>
</p>

<p>Uses the CP-1252 encoding.</p>

<p><em>Note: All unreadables in this post are escaped with <code>\u00xx</code> so that the Stack Exchange system doesn't automatically remove them. They should be considered to have a size of one byte.</em></p>

<h2>Explanation</h2>

<p>Uses a run-length encoding scheme along with packing each character into 4 bits. The main logic of the code is 174 bytes and the leaf string (including decompression) is 364 bytes. Further details of the compression method are found below.</p>

<pre class="lang-js prettyprint-override"><code>alert((
  f=t=>                                   // f checks for 4:20 in a date
    new Date(Date.now()+t*1e3)            // get the date at now + t seconds
    .toISOString().match`(T16|04)[-:]20`  // find 4:20 in the ISO date string
)(i=0)?

  // Leaf decompression
  "À\u0019\u0002û1!°?4\u0002ë14!°>C3\u0002=\u0001Ê34\u0003Ê1\u0002=4\u00011C3\u000114\u0002=C\u0013ð4\u0009\u001fCS\u0002m34\u0001>Ià14s\u0002>C3\u0001=IÐ1CS\u0002n34\u0013À4\u0009\u001c34s\u0002?I3\u0001;I°1C3%ð6I3\u0001:I 1C3ub3\u0001l4\u00134\u0009\u001934S\u0007\u001bS'`\u0011 V34\u0013\u00004\u0009\u001034\u0009:Z\u0002i³\u0001zC3\u00014\u00091Cs8Z'°6\u001b 74K³4\u00079['Ð6\u001b³4J£4\u001a8Y' yó4I4]s\u0002Ê7M34CÓw\u0002«6u\u00021u\u0007`6\u0013\u0002ëss#ÀY"
  .replace(/./g,c=>                       // unpack each 4-bit character
    (l=" .\n:|;`',0123456")               // l = lookup table of characters
    [(n=c.charCodeAt())&15]+l[n>>4]       // return the two characters in the byte
  )
  .replace(/.\d+/g,c=>                    // run-length decoding
    c[0].repeat(parseInt(c.slice(1),7)+3) // repeat character n + 3 times (base-7)
  )

:eval(`                                   // eval just to allow a for loop here...
  for(;!f(++i););                         // check each second up until a match

  \`${i/60|0} minutes and ${i%60|0} seconds left until your next hit.\`
`))
</code>```

Compression Algorithms

No Compression, 911 bytes

This is the leaf string with no compression at all.

`                        .
                       .:.
                       :|:
                      .:|:.
                      ::|::
       :.             ::|::             .:
       :|:.          .::|::.          .:|:
       ::|:.         :::|:::         .:|:;
       \`::|:.        :::|:::        .:|::'
        ::|::.       :::|:::       .::|:;
        \`::|::.      :::|:::      .::|::'
         :::|::.     :::|:::     .::|::;
         \`:::|::.    :::|:::    .::|::;'
\`::.      \`:::|::.   :::|:::   .::|::;'     .:;'
 \`:::..    \`;::|::.  :::|:::  .::|:::    ::::;
   \`:::::.    ':|::. :::|::: .::|:'   ,::::;'
     \`:::::.    ':|:::::|:::::|:'   :::::;'
       \`:::::.:::::|::::|::::|::::.,:::;'
          ':::::::::|:::|:::|:::::::;:'
             ':::::::|::|::|:::::::''
                  \`::::::::::;'
                 .:;'' ::: \`\`::.
                      :':':
                        ;`
```

<h3>Run-Length Encoding, 542 bytes</h3>

<p>Since there are many consecutive repeated characters, run-length encoding improves the byte count significantly.</p>

<pre class="lang-js prettyprint-override"><code>` 21.
 20.:.
 20:|:
 19.:|:.
 19::|::
 4:. 10::|:: 10.:
 4:|:. 7.::|::. 7.:|:
 4::|:. 6:0|:0 6.:|:;
 4\`::|:. 5:0|:0 5.:|::'
 5::|::. 4:0|:0 4.::|:;
 5\`::|::. 3:0|:0 3.::|::'
 6:0|::. 2:0|:0 2.::|::;
 6\`:0|::. 1:0|:0 1.::|::;'
\`::. 3\`:0|::. 0:0|:0 0.::|::;' 2.:;'
 \`:0.. 1\`;::|::.  :0|:0  .::|:0 1:1;
 0\`:2. 1':|::. :0|:0 .::|:' 0,:1;'
 2\`:2. 1':|:2|:2|:' 0:2;'
 4\`:2.:2|:1|:1|:1.,:0;'
 7':6|:0|:0|:4;:'
 10':4|::|::|:4''
 15\`:7;'
 14.:;'' :0 \`\`::.
 19:':':
 21;`.replace(/.\d+/g,c=>c[0].repeat(+c.slice(1)+3))
</code>```

Each character repeated 3 or more times is replaced with the character followed by a decimal number of amount - 3. The encoded string is generated with this code:

uncompressed.replace(/(.)\1{2,}/g,c=>c[0]+(c.length-3))
```

<h3>4-bit Packing + RLE, 364 bytes</h3>

<p>There are 9 distinct characters in the original string, which means 4 is the minimum number of bits to represent each. Conveniently, this allows for exactly two character representations to fit into a single byte, enabling a simple (and golf-friendly) decompression algorithm to be used. On top of that, there are 7 characters left over, which allows base-7 run-length encoding to be used before packing. Putting each 4-bit index into the upper and lower nibbles of each compressed character means 2 characters are stored per byte, because the CP-1252 encoding encodes every character under code point 256 as a single byte.</p>

<pre class="lang-js prettyprint-override"><code>"À\u0019\u0002û1!°?4\u0002ë14!°>C3\u0002=\u0001Ê34\u0003Ê1\u0002=4\u00011C3\u000114\u0002=C\u0013ð4\u0009\u001fCS\u0002m34\u0001>Ià14s\u0002>C3\u0001=IÐ1CS\u0002n34\u0013À4\u0009\u001c34s\u0002?I3\u0001;I°1C3%ð6I3\u0001:I 1C3ub3\u0001l4\u00134\u0009\u001934S\u0007\u001bS'`\u0011 V34\u0013\u00004\u0009\u001034\u0009:Z\u0002i³\u0001zC3\u00014\u00091Cs8Z'°6\u001b 74K³4\u00079['Ð6\u001b³4J£4\u001a8Y' yó4I4]s\u0002Ê7M34CÓw\u0002«6u\u00021u\u0007`6\u0013\u0002ëss#ÀY"
.replace(/./g,c=>(l=" .\n:|;`',0123456")[(n=c.charCodeAt())&15]+l[n>>4])
.replace(/.\d+/g,c=>c[0].repeat(parseInt(c.slice(1),7)+3))
</code>```

The following code is used to do the run-length encoding and packing:

chars="",max=16;
[...uncompressed].map(c=>~chars.indexOf(c)?0:chars+=c);
base=max-chars.length;
chars+=[...Array(base).keys()].join``;
unpacked=uncompressed.replace(/(.)\1{2,}/g,c=>c[0]+(c.length-3).toString(base));
packed=unpacked.replace(/(.|\n){2}/g,s=> // Note: unpacked length must be even!
  String.fromCharCode(chars.indexOf(s[0])|(chars.indexOf(s[1])<<4)));
```

Huffman Coding, (Possible Future Improvement)

Certain characters occur much more than others, so a Huffman encoding (variable-length integers representing each character) could save some further bytes. However this will introduce a lot more complexity into the decompression algorithm, so aside from being a lot more work it may also cost more bytes to decompress it than it saves in the encoded string.

Title: 420 <s>Blaze</s> Golf It

Body:
JavaScript (ES6), 537 bytes

alert((f=t=>new Date(Date.now()+t*1e3).toISOString().match`(T16|04)[-:]20`)(i=0)?"À\u0019\u0002û1!°?4\u0002ë14!°>C3\u0002=\u0001Ê34\u0003Ê1\u0002=4\u00011C3\u000114\u0002=C\u0013ð4\u0009\u001fCS\u0002m34\u0001>Ià14s\u0002>C3\u0001=IÐ1CS\u0002n34\u0013À4\u0009\u001c34s\u0002?I3\u0001;I°1C3%ð6I3\u0001:I 1C3ub3\u0001l4\u00134\u0009\u001934S\u0007\u001bS'`\u0011 V34\u0013\u00004\u0009\u001034\u0009:Z\u0002i³\u0001zC3\u00014\u00091Cs8Z'°6\u001b 74K³4\u00079['Ð6\u001b³4J£4\u001a8Y' yó4I4]s\u0002Ê7M34CÓw\u0002«6u\u00021u\u0007`6\u0013\u0002ëss#ÀY".replace(/./g,c=>(l=" .\n:|;`',0123456")[(n=c.charCodeAt())&15]+l[n>>4]).replace(/.\d+/g,c=>c[0].repeat(parseInt(c.slice(1),7)+3)):eval('for(;!f(++i););`${i/60|0} minutes and ${i%60|0} seconds left until your next hit.`'))

Uses the CP-1252 encoding.

Note: All unreadables in this post are escaped with \u00xx so that the Stack Exchange system doesn't automatically remove them. They should be considered to have a size of one byte.

Explanation

Uses a run-length encoding scheme along with packing each character into 4 bits. The main logic of the code is 174 bytes and the leaf string (including decompression) is 364 bytes. Further details of the compression method are found below.

alert((
  f=t=>                                   // f checks for 4:20 in a date
    new Date(Date.now()+t*1e3)            // get the date at now + t seconds
    .toISOString().match`(T16|04)[-:]20`  // find 4:20 in the ISO date string
)(i=0)?

  // Leaf decompression
  "À\u0019\u0002û1!°?4\u0002ë14!°>C3\u0002=\u0001Ê34\u0003Ê1\u0002=4\u00011C3\u000114\u0002=C\u0013ð4\u0009\u001fCS\u0002m34\u0001>Ià14s\u0002>C3\u0001=IÐ1CS\u0002n34\u0013À4\u0009\u001c34s\u0002?I3\u0001;I°1C3%ð6I3\u0001:I 1C3ub3\u0001l4\u00134\u0009\u001934S\u0007\u001bS'`\u0011 V34\u0013\u00004\u0009\u001034\u0009:Z\u0002i³\u0001zC3\u00014\u00091Cs8Z'°6\u001b 74K³4\u00079['Ð6\u001b³4J£4\u001a8Y' yó4I4]s\u0002Ê7M34CÓw\u0002«6u\u00021u\u0007`6\u0013\u0002ëss#ÀY"
  .replace(/./g,c=>                       // unpack each 4-bit character
    (l=" .\n:|;`',0123456")               // l = lookup table of characters
    [(n=c.charCodeAt())&15]+l[n>>4]       // return the two characters in the byte
  )
  .replace(/.\d+/g,c=>                    // run-length decoding
    c[0].repeat(parseInt(c.slice(1),7)+3) // repeat character n + 3 times (base-7)
  )

:eval(`                                   // eval just to allow a for loop here...
  for(;!f(++i););                         // check each second up until a match

  \`${i/60|0} minutes and ${i%60|0} seconds left until your next hit.\`
`))

Compression Algorithms

No Compression, 911 bytes

This is the leaf string with no compression at all.

`                        .
                       .:.
                       :|:
                      .:|:.
                      ::|::
       :.             ::|::             .:
       :|:.          .::|::.          .:|:
       ::|:.         :::|:::         .:|:;
       \`::|:.        :::|:::        .:|::'
        ::|::.       :::|:::       .::|:;
        \`::|::.      :::|:::      .::|::'
         :::|::.     :::|:::     .::|::;
         \`:::|::.    :::|:::    .::|::;'
\`::.      \`:::|::.   :::|:::   .::|::;'     .:;'
 \`:::..    \`;::|::.  :::|:::  .::|:::    ::::;
   \`:::::.    ':|::. :::|::: .::|:'   ,::::;'
     \`:::::.    ':|:::::|:::::|:'   :::::;'
       \`:::::.:::::|::::|::::|::::.,:::;'
          ':::::::::|:::|:::|:::::::;:'
             ':::::::|::|::|:::::::''
                  \`::::::::::;'
                 .:;'' ::: \`\`::.
                      :':':
                        ;`

Run-Length Encoding, 542 bytes

Since there are many consecutive repeated characters, run-length encoding improves the byte count significantly.

` 21.
 20.:.
 20:|:
 19.:|:.
 19::|::
 4:. 10::|:: 10.:
 4:|:. 7.::|::. 7.:|:
 4::|:. 6:0|:0 6.:|:;
 4\`::|:. 5:0|:0 5.:|::'
 5::|::. 4:0|:0 4.::|:;
 5\`::|::. 3:0|:0 3.::|::'
 6:0|::. 2:0|:0 2.::|::;
 6\`:0|::. 1:0|:0 1.::|::;'
\`::. 3\`:0|::. 0:0|:0 0.::|::;' 2.:;'
 \`:0.. 1\`;::|::.  :0|:0  .::|:0 1:1;
 0\`:2. 1':|::. :0|:0 .::|:' 0,:1;'
 2\`:2. 1':|:2|:2|:' 0:2;'
 4\`:2.:2|:1|:1|:1.,:0;'
 7':6|:0|:0|:4;:'
 10':4|::|::|:4''
 15\`:7;'
 14.:;'' :0 \`\`::.
 19:':':
 21;`.replace(/.\d+/g,c=>c[0].repeat(+c.slice(1)+3))

Each character repeated 3 or more times is replaced with the character followed by a decimal number of amount - 3. The encoded string is generated with this code:

uncompressed.replace(/(.)\1{2,}/g,c=>c[0]+(c.length-3))

4-bit Packing + RLE, 364 bytes

There are 9 distinct characters in the original string, which means 4 is the minimum number of bits to represent each. Conveniently, this allows for exactly two character representations to fit into a single byte, enabling a simple (and golf-friendly) decompression algorithm to be used. On top of that, there are 7 characters left over, which allows base-7 run-length encoding to be used before packing. Putting each 4-bit index into the upper and lower nibbles of each compressed character means 2 characters are stored per byte, because the CP-1252 encoding encodes every character under code point 256 as a single byte.

"À\u0019\u0002û1!°?4\u0002ë14!°>C3\u0002=\u0001Ê34\u0003Ê1\u0002=4\u00011C3\u000114\u0002=C\u0013ð4\u0009\u001fCS\u0002m34\u0001>Ià14s\u0002>C3\u0001=IÐ1CS\u0002n34\u0013À4\u0009\u001c34s\u0002?I3\u0001;I°1C3%ð6I3\u0001:I 1C3ub3\u0001l4\u00134\u0009\u001934S\u0007\u001bS'`\u0011 V34\u0013\u00004\u0009\u001034\u0009:Z\u0002i³\u0001zC3\u00014\u00091Cs8Z'°6\u001b 74K³4\u00079['Ð6\u001b³4J£4\u001a8Y' yó4I4]s\u0002Ê7M34CÓw\u0002«6u\u00021u\u0007`6\u0013\u0002ëss#ÀY"
.replace(/./g,c=>(l=" .\n:|;`',0123456")[(n=c.charCodeAt())&15]+l[n>>4])
.replace(/.\d+/g,c=>c[0].repeat(parseInt(c.slice(1),7)+3))

The following code is used to do the run-length encoding and packing:

chars="",max=16;
[...uncompressed].map(c=>~chars.indexOf(c)?0:chars+=c);
base=max-chars.length;
chars+=[...Array(base).keys()].join``;
unpacked=uncompressed.replace(/(.)\1{2,}/g,c=>c[0]+(c.length-3).toString(base));
packed=unpacked.replace(/(.|\n){2}/g,s=> // Note: unpacked length must be even!
  String.fromCharCode(chars.indexOf(s[0])|(chars.indexOf(s[1])<<4)));

Huffman Coding, (Possible Future Improvement)

Certain characters occur much more than others, so a Huffman encoding (variable-length integers representing each character) could save some further bytes. However this will introduce a lot more complexity into the decompression algorithm, so aside from being a lot more work it may also cost more bytes to decompress it than it saves in the encoded string.


答:
Pyke, 10 bytes

```<code>dcX"le"RdJ
</code>```

Try it here!

Or 9 bytes (noncompeting, add insert)

```<code>Dd@" le":
</code>```

Try it here!

Title: Convert phrases to reverse style

Body:
The Challenge

Convert a phrase of two words to reverse style: candy bar -> bar le candy.

Specifications

There will be one word (only a-zA-Z0-9 + -), a space (), and then another word.

For equal length, score is used to determine winner.

Test cases:

```<code>candy bar -> bar le candy
code golf -> golf le code
programming puzzles -> puzzles le programming
</code>```

Body:
Pyke, 10 bytes

dcX"le"RdJ

Try it here!

Or 9 bytes (noncompeting, add insert)

Dd@" le":

Try it here!


答:
Seriously, 13 bytes

```<code>"le"' ,so/' j
</code>```

Try it online

Explanation:

```<code>"le"' ,so/' j
    ' ,s       split input on space
"le"    o/     stick "le" between words
          ' j  join on space
</code>```

Title: Convert phrases to reverse style

Body:
Seriously, 13 bytes

"le"' ,so/' j

Try it online

Explanation:

"le"' ,so/' j
    ' ,s       split input on space
"le"    o/     stick "le" between words
          ' j  join on space


答:
C, <s>74</s> <s>73</s> 71 bytes

Shaved <s>one</s> three byte thanks to @xsot!

```<code>a[99],c,m;main(d){for(;~c;m|=c^d&&a[d=c]++)c=getchar();putchar(48+!m);}
</code>```

Title: All together now

Body:
C, <s>74</s> <s>73</s> 71 bytes

Shaved <s>one</s> three byte thanks to @xsot!

a[99],c,m;main(d){for(;~c;m|=c^d&&a[d=c]++)c=getchar();putchar(48+!m);}


问:
Interlocking Brackets
Write a program or function that takes in an eight byte string containing one of each of the characters ()[]{}<> arranged in any way such that the four respective bracket types match. For example, ]<([){}> is invalid input because the square brackets don't match (though all the others do).

Print or return an integer from 0 to 6 that denotes how many of the six possible pairings of the four bracket types are interlocked. Bracket type pairs are considered interlocked if exactly one bracket of one type occurs between the brackets of the other type. So ([)] and [(]) are interlocked but ()[], [](), ([]), and [()] are not.

The shortest code in bytes wins.

Input/Output Examples

```<code>()[]{}<> : 0
([{<>}]) : 0
<>{[]}() : 0
{<>([])} : 0
<(>)[{}] : 1
<[({)}]> : 1
[{<}]>() : 2
{<>([}]) : 2
<{(>})[] : 3
[(]<){>} : 3
<([>{)}] : 4
(<{[>})] : 4
(<[{)>}] : 5
<{[(>})] : 5
[{<(]}>) : 6
(<{[)>}] : 6
</code>```

答:
Oracle SQL 11.2, 206 bytes

```<code>WITH v AS(SELECT b,MIN(p)i,MAX(p)a FROM(SELECT SUBSTR(TRANSLATE(:1,'])>}','[(<{'),LEVEL,1)b,LEVEL p FROM DUAL CONNECT BY LEVEL<9)GROUP BY b)SELECT COUNT(*)FROM v x,v y WHERE x.i<y.i AND x.a<y.a AND y.i<x.a;
</code>```

Un-golfed :

```<code>WITH v AS( -- Compute min and max pos for each bracket type
           SELECT b,MIN(p)i,MAX(p)a
           FROM   ( -- replace ending brackets by opening brakets and split the string
                    SELECT SUBSTR(TRANSLATE(:1,'])>}','[(<{'),LEVEL,1)b,LEVEL p
                    FROM DUAL
                    CONNECT BY LEVEL<9
                  )
           GROUP BY b
         )
SELECT COUNT(*)
FROM   v x,v y
WHERE  x.i<y.i AND x.a<y.a AND y.i<x.a -- Apply restrictions for interlocking brackets
</code>```

Title: Interlocking Brackets

Body:
Oracle SQL 11.2, 206 bytes

WITH v AS(SELECT b,MIN(p)i,MAX(p)a FROM(SELECT SUBSTR(TRANSLATE(:1,'])>}','[(<{'),LEVEL,1)b,LEVEL p FROM DUAL CONNECT BY LEVEL<9)GROUP BY b)SELECT COUNT(*)FROM v x,v y WHERE x.i<y.i AND x.a<y.a AND y.i<x.a;

Un-golfed :

WITH v AS( -- Compute min and max pos for each bracket type
           SELECT b,MIN(p)i,MAX(p)a
           FROM   ( -- replace ending brackets by opening brakets and split the string
                    SELECT SUBSTR(TRANSLATE(:1,'])>}','[(<{'),LEVEL,1)b,LEVEL p
                    FROM DUAL
                    CONNECT BY LEVEL<9
                  )
           GROUP BY b
         )
SELECT COUNT(*)
FROM   v x,v y
WHERE  x.i<y.i AND x.a<y.a AND y.i<x.a -- Apply restrictions for interlocking brackets


问:
Parenthifiable Binary Numbers
If you express some positive integer in binary with no leading zeros and replace every 1 with a ( and every 0 with a ), then will all the parentheses match?

In most cases they won't. For example, 9 is 1001 in binary, which becomes ())(, where only the first two parentheses match.

But sometimes they will match. For example, 44 is 101100 in binary, which becomes ()(()), where all the left parentheses have a matching right parenthesis.

Write a program or function that takes in a positive base ten integer and prints or returns a truthy value if the binary-parentheses version of the number has all matching parentheses. If it doesn't, print or return a falsy value.

The shortest code in bytes wins.

Related OEIS sequence.

Truthy examples below 100:

```<code>2, 10, 12, 42, 44, 50, 52, 56
</code>```

Falsy examples below 100:

```<code>1, 3, 4, 5, 6, 7, 8, 9, 11, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 43, 45, 46, 47, 48, 49, 51, 53, 54, 55, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99
</code>```

答:
C# 98 bytes

```<code>bool f(int m){int i=0;foreach(char s in Convert.ToString((m),2)){if(s=='1')i+=2;i--;}return i==0;}
</code>```

open for any suggestions. i like this challange even tho it is old-ish

Title: Parenthifiable Binary Numbers

Body:
C# 98 bytes

bool f(int m){int i=0;foreach(char s in Convert.ToString((m),2)){if(s=='1')i+=2;i--;}return i==0;}

open for any suggestions. i like this challange even tho it is old-ish


问:
Solve a quadratic equation using Vieta's formulas

Exposition

Your mathematics teacher is a big fan of Vieta's formulas, and he believes that you should use them to solve quadratic equations. Given the equation

```<code>ax^2 + bx + c = 0
</code>```

the product of its roots is c/a, and their sum is -b/a. When all of a, b and c are nonzero integers, assuming the roots are rational numbers, it's enough to try all possible numbers in the form

```<code>r1 = ±s/t
</code>```

where s is a divisor of abs(c), and t is a divisor of abs(a). For each such r1, plug it into ax^2 + bx + c, and see whether the result is 0. If yes, then r1 is a root. The second root is -b/a-r1 or (c/a)/r1 - you can choose whatever formula you like.

Your teacher decided to give you many exercises, and he expects you to describe how you used Vieta's formulas to solve each one. Each exercise looks like this (example):

```<code>9x^2+12x+4=0
</code>```

Write a subroutine or a program that gets an exercise as input, and outputs your alleged "solving process" to appease your teacher.

Input

Since you will feed the exercise to your program manually, format it in any convenient form. For example, use space-separated values on stdin:

```<code>9 12 4
</code>```

or call a function with 3 parameters:

```<code>SolveExercise(9, 12, 4);
</code>```

or parse the exercise literally:

```<code>9x^2+12x+4=0
</code>```

Your output should be formatted as described below. Use the standard output device or return it as a string from your subroutine.

Output (example)

```<code>x = 1? 9x^2+12x+4 = 25
x = 2? 9x^2+12x+4 = 64
x = 1/3? 9x^2+12x+4 = 9
x = 2/3? 9x^2+12x+4 = 16
... (as many or as few failed attempts as you like)
x = -2/3? 9x^2+12x+4 = 0
r1 = -2/3
r2 = -12/9-(-2/3) = -2/3
</code>```

Alternatively, the last line can be:

```<code>r2 = 4/9/(-2/3) = -2/3
</code>```

Some additional notes:

The minimum number of line-breaks in the output is as described in the example (trailing line-break is not required). Additional line-breaks are permitted.

All coefficients in input are integers in the range [-9999...9999], none can be equal to 0

All roots are rational numbers, and should be output as such - e.g. 0.66666667 is not equal to 2/3 and so is incorrect

In the final expressions for r1 and r2, integers should be output as such, e.g. -99/1 is unacceptable, and should be output as -99; in other places in the output, denominator equal to ±1 is acceptable

Reduced form for rational numbers is not required - e.g. 2/4 is a good substitute for 1/2, even though it's ugly, even for roots r1 and r2

Parentheses in the output are sometimes required by rules of mathematics, e.g. in the expression 12/9/(2/3). When precedence rules of mathematics permit omission of parentheses, they are not required, e.g. -12/9--2/3. Superfluous parentheses are permitted: 4-(2) is OK, even though it's ugly

There should be at least one case (input) for which your program tries 3 or more non-integer values for r1; however, it's allowed to "guess the right answer" almost always on the first try

All trial values for r1 must be rational numbers ±s/t, where s and t are constrained as described above

Test cases

Input

```<code>x^2-x-2=0
</code>```

or

```<code>1 -1 -2
</code>```

Possible output

```<code>r1 = ±s/t
</code>```0

Input

```<code>r1 = ±s/t
</code>```1

or

```<code>r1 = ±s/t
</code>```2

Possible output

```<code>x=1? -x^2+2x-1=0
r1=1
r2=-2/-1-1=1
</code>```

Input

```<code>7x^2-316x+924=0
</code>```

or

```<code>X(7, -316, 924);
</code>```

Possible output (a divisor of 924 is 42, which solves the equation by "luck")

```<code>x=42? 7x^2-316x+924=0
r1=42
r2=316/7-42=22/7
</code>```

Input

```<code>6x^2-35x-6=0
</code>```

or

```<code>[6 -35 -6]
</code>```

Possible output (even though your program may "know" that 6 is a root, it decides to show some failed trials)

```<code>x=1/2? 6x^2-35x-6=-88/4
x=1/3? 6x^2-35x-6=-153/9
x=3/2? 6x^2-35x-6=-180/4
x=6/1? 6x^2-35x-6=0
r1=6
r2=35/6-6=-1/6
</code>```

Alternative versions for the last line:

```<code>9x^2+12x+4=0
</code>```0

Impossible input (no rational solutions)

```<code>9x^2+12x+4=0
</code>```1

Impossible input (zero coefficient)

```<code>9x^2+12x+4=0
</code>```2

答:
Python - <s>202</s> 200 bytes

2 bytes saved thanks to @FryAmTheEggman.

from fractions import*;f=Fraction
lambda a,b,c:"\n".join(["x=%s?%dx^2+%dx+%d=%s"%(i,a,b,c,a*i*i+b*i+c)for i in[f(1,a),f(-1,a),f(c,a)]]+["r%d=%s"%((3-i)/2,f(i*(b*b-4*a*c)**.5-b)/f(2*a))for i in[1,-1]])
```