Fault-Tolerant Hello World At the end of your interview, the Evil Interviewer tells you, "We make all of our applicants take a short coding test, to see if they really know what they are talking about.  Don't worry; it's easy.  And if you create a working program, I'll offer you the job immediately."  He gestures for you to sit down at a nearby computer.  "All you have to do is create a working  Hello World program.  But"--and he grins broadly--"there's a catch.  Unfortunately the only compiler we have on this machine has a small bug.  It randomly deletes one character from the source code file before compiling.  Ok, see you in five minutes!"  And he walks out of the room, whistling happily.
Can you guarantee that you will get the job?
The Task
Write a program that will print Hello, world! to standard output even after a single character is removed from any position in the file. Or come as close to this as possible.
The Rules
No Extraneous Output - Hello, world! must be the only substantive thing printed to standard output.  It is ok to include other characters if they are naturally produced by your language of choice--such as a trailing newline or even something like [1] "Hello, world!" (for example if you were using R), but it must print the exact same thing every time.  It cannot print Hello, world!Hello, world! or Hello world!" && x==1 some of the time, for example.  Warnings, however, are allowed.
Testing In order to test determine your score, you have to test each possible permutation of the program: test it with each character removed, and see if it produces the correct output.  I have included a simple Perl program for this purpose below, which should work for many languages.  If it doesn't work for you, please create a test program and include it in your answer.
Scoring Your score is the number of times your program fails.  In other words, the number of individual positions in your file where deleting a character prevents your program from working.  Lowest score wins.  In the event of a tie, the shortest code wins.
Trivial Solutions such as "Hello, world!" in several languages (score of 15) are acceptable, but they aren't going to win.
Happy programming, and may you get the job. But if you fail, you probably didn't want to work for that evil boss anyway.
Perl test script:
use warnings;
use strict;

my $program   = 'test.pl';
my $temp_file = 'corrupt.pl';
my $command = "perl -X $temp_file"; #Disabled warnings for cleaner output.
my $expected_result = "Hello, world!";

open my $in,'<',$program or die $!;
local $/;           #Undef the line separator
my $code = <$in>;   #Read the entire file in.

my $fails = 0;
for my $omit_pos (0..length($code)-1)
{
    my $corrupt = $code;
    $corrupt =~ s/^.{$omit_pos}\K.//s;  #Delete a single character

    open my $out,'>',$temp_file or die $!;
    print {$out} $corrupt;  #Write the corrupt program to a file
    close $out;

    my $result = `$command`;    #Execute system command.
    if ($result ne $expected_result)
    {
        $fails++;
        print "Failure $fails:\nResult: ($result)\n$corrupt";
    }
}

print "\n$fails failed out of " . length $code;

Befunge, Score 0

I think I cracked it - no single character deletion will change the output.
Deleting any character from line 1 changes nothing - it still goes down at the same place.
Lines 2 and 3 are redundant. Normally line 2 is executed, but if you delete a character from it, the < is missed, and line 3 takes charge.
Deleting newlines doesn't break it either (it did break my previous version).
No test program, sorry.

EDIT: simplified a lot.

                              vv
@,,,,,,,,,,,,,"Hello, world!"<<
@,,,,,,,,,,,,,"Hello, world!"<<

A short explanation of the flow:

Befunge starts executing from top-left, moving right. Spaces do nothing.
v turns the execution flow downward, so it goes down one line.
< turns the execution flow left, so it reads line 2 in reversed order.
"Hello, world!" pushes the string to the stack. It's pushed in reversed order, because we're executing right to left.
, pops a character and prints it. The last character pushed is printed first, which reverses the string once more.
@ terminates the program.


Join N copies of a snippet to produce N^2 characters Challenge
Write the shortest snippet of code possible such that, when N copies of it are concatenated together, the number of characters output is N2. N will be a positive integer.
For example if the snippet was soln();, then running soln(); would print exactly 1 character, and running soln();soln(); would print exactly 4 characters, and running soln();soln();soln(); would print exactly 9 characters, etc.
Any characters may be in the output as long as the total number of characters is correct. To avoid cross-OS confusion, \r\n newlines are counted as one character.
Programs may not read their own source or read their file size or use other such loopholes. Treat this like a strict quine challenge.
The output may go to stdout or a file or a similar alternative. There is no input.
Comments in the code are fine, as is exiting mid-execution.
Any characters may be in the program. The shortest submission in bytes wins.

TECO, 4 bytes
V1\V

V prints the contents of the current line in the text buffer. 1\ inserts the string representation of the number 1 at the current position.
So on the Nth iteration of the program, the first V will output N - 1 copies of the character 1, then add another 1 to the text, then output N 1s.


Challenge Similarity Detector Challenge

Given two question IDs, try to figure out how similar they are by looking at the answers.

Details

You will be given two question IDs for codegolf.stackexchange.com; you may assume that there exist questions for both IDs that are not deleted, but are not necessarily open. You must run through all of the answers and determine the minimum Levenshtein distance between the code in the answers to the two questions (not including deleted answers). That is, you should compare every answer in question 1 to every answer in question 2, and determine the minimum Levenshtein distance. To find the code in an answer, assume the following procedure:

How to find the code snippet

A body of text is the answer's actual code if it is in backticks and is on its own line, or if it is indented with 4 spaces, with an empty line above it, unless there is no text above.

Examples of valid and not-valid code snippets (with . as a space) (separated by a ton of equal signs)

This is `not a valid code snippet because it is not on its own line`
========================================
This is:
`A valid code snippet`
========================================
This is
....not a valid code snippet because there's no spacing line above
========================================
This is

....A valid code snippet because there's a spacing line above
========================================
....Valid code snippet because there's no other text
========================================

If there are no valid code snippets in the answer, ignore the answer completely. Note that you should only take the first codeblock.

Final Specs

The two question IDs can be inputted in any reasonable format for 2 integers. The output should be the smallest Levenshtein distance between any two valid answers from either challenge. If there are no "valid" answers for one or both of the challenges, output -1.

Test Case

For challenge 115715 (Embedded Hexagons) and 116616 (Embedded Triangles) both by Comrade SparklePony, the two Charcoal answers (both by KritixiLithos) had a Levenshtein distance of 23, which was the smallest. Thus, your output for 115715, 116616 would be 23.

Edit

You may assume that the question has at most 100 answers because of an API pagesize restriction. You should not ignore backticks in code blocks, only if the code block itself is created using backticks and not on its own line.

Edit

I terminated the bounty period early because I made a request to a mod to get a one-week suspension and I didn't want the bounty to be automatically awarded to the highest scoring answer (which happens to be the longest). If a new submission comes in or a submission is golfed enough to become shorter than 532 bytes before the actual end of the bounty period (UTC 00:00 on Jun 1), I will give that a bounty to stay true to my promise, after the suspension expires. If I remember correctly, I need to double the bounty period next time so if you do get an answer in, you might get +200 :)

Java + Jsoup, 1027 bytes

The first two arguments are the question IDs.

Golfed:

import org.jsoup.*;import org.jsoup.nodes.*;class M{String a1[]=new String[100],a2[]=new String[100],c[];int i1=0,i2=0;public static void main(String a[])throws Exception{String r="https://codegolf.stackexchange.com/questions/";M m=new M();m.c=m.a1;m.r(Jsoup.connect(r+a[0]).get());m.c=m.a2;m.r(Jsoup.connect(r+a[1]).get());int s=m.ld(m.a1[1],m.a2[1]);for(int i=2;i<m.a1.length;i++)for(int j=2;j<m.a2.length;i++){if(m.a1[i]==null)break;int d=m.ld(m.a1[i],m.a2[j]);if(d<s)s=d;}System.out.print(s);}void r(Document d){a:for(Element e:d.select("td")){for(Element p:e.select("pre")){ a(p.select("code").get(0).html());continue a;}}}void a(String d){c[c==a1?i1++:i2++]=d;}int ld(String a,String b){a=a.toLowerCase();b=b.toLowerCase();int[]costs=new int[b.length()+1];for(int j=0;j<costs.length;j++)costs[j]=j;for(int i=1;i<=a.length();i++){costs[0]=i;int nw=i-1;for(int j=1;j<=b.length();j++){int cj=Math.min(1+Math.min(costs[j],costs[j-1]),a.charAt(i-1)==b.charAt(j-1)?nw:nw+1);nw=costs[j];costs[j]=cj;}}return costs[b.length()];}}

Readable:

import org.jsoup.*;import org.jsoup.nodes.*;

class M {
    String a1[]=new String[100],a2[]=new String[100],c[];
    int i1=0,i2=0;
    public static void main(String a[])throws Exception{
    String r="https://codegolf.stackexchange.com/questions/";
    M m=new M();

    m.c=m.a1;
    m.r(Jsoup.connect(r+a[0]).get());
    m.c=m.a2;
    m.r(Jsoup.connect(r+a[1]).get());

    int s=m.ld(m.a1[1],m.a2[1]);
    for(int i=2;i<m.a1.length;i++)for(int j=2;j<m.a2.length;i++){if(m.a1[i]==null)break;int d=m.ld(m.a1[i],m.a2[j]);if(d<s)s=d;}
    System.out.print(s);
}

void r(Document d) {
    a:for(Element e:d.select("td")) {for(Element p:e.select("pre")) {
        a(p.select("code").get(0).html());
        continue a;
    }}
}

void a(String d){c[c==a1?i1++:i2++]=d;}

int ld(String a, String b) {
    a = a.toLowerCase();
    b = b.toLowerCase();
    int [] costs = new int [b.length() + 1];
    for (int j = 0; j < costs.length; j++)costs[j] = j;
    for (int i = 1; i <= a.length(); i++) {
        costs[0] = i;
        int nw = i - 1;
        for (int j = 1; j <= b.length(); j++) {
            int cj = Math.min(1 + Math.min(costs[j], costs[j - 1]), a.charAt(i - 1) == b.charAt(j - 1) ? nw : nw + 1);
            nw = costs[j];
            costs[j] = cj;
        }
    }
    return costs[b.length()];
}

}


Range, Reverse, Sum! Given a positive integer n as input, output the reversed range sum of n.

A reversed range sum is created by making an inclusive range up to n, starting with 1 and including n, reversing each of the numbers inside, and summing it.

Example:

Here is what would happen for an input of 10:

Range: [1,2,3,4,5,6,7,8,9,10]

Reverse: [1,2,3,4,5,6,7,8,9,01] (1-char numbers reversed are themselves, 10 reversed is 01 or 1)

Sum: 46

Numbers with 3+ digits are reversed the same way numbers with 2 digits are. For example, 1234 would become 4321.

Test cases:

Input -> Output

10 -> 46
5 -> 15
21 -> 519
58 -> 2350
75 -> 3147
999 -> 454545

Complete text cases to input of 999 can be found here, thanks very much to @fireflame241.

05AB1E, 3 bytes

Code

LíO

Uses the 05AB1E encoding. Try it online!

Explanation

L       # Range
 í      # Reverse
  O     # Sum


Encrypted In Numbers! The Problem:

Two enemy secret agents have devised a wonderful (for you) method of communication!

Here’s how the encryption process works:

1) Take the ascii equivalents of each letter. (No spaces, numbers, or punctuation are sent)

2) For each letter in the message, the ascii equivalent of it and the letter after it (If it exists, if it doesn’t, it should be considered 0), are multiplied (this product is stored in an array/list) and summed (this number is also stored in a different list).

3) The two lists (of sums and products) are joined together (the sums list, then the multiples list, into the same array) and transmitted.

You need to write the smallest program able to reverse this process and decrypt messages sent in this format!

Example Input and Output Pairs:

[173, 209, 216, 219, 198, 198, 225, 222, 208, 100, 7272, 10908, 11664, 11988, 9657, 9657, 12654, 12312, 10800, 0] -> “HelloWorld”
[131, 133, 164, 195, 197, 99, 4290, 4422, 6499, 9506, 9702, 0] -> “ABCabc”

This is code-golf, so the smallest solution in bytes wins.

Error messages are allowed.

Your program can be given either a list/1-dimensional array or a comma-separated string, if you specify in your submission. The default is an array/list.

brainfuck, 66 bytes

,[>>>+<[-<+>>-<]<[->+<],]>[<<,>>[-<+>]<-]<<<[>[-<->>+<]<<]>.>>[.>]

Input is the encrypted string. Assumes infinite sized cells and 0 on EOF.

How it Works:

,[>>>+<[-<+>>-<]<[->+<],] Gets input and the number of characters divided by 2
>[<<,>>[-<+>]<-]<<< Remove the second half of the string (the multiplication part)
[>[-<->>+<]<<] Subtract each character from the previous one, while keeping a copy of the previous one.
>.>>[.>] Print the characters


Stuffing primes in a box Your task is write a program or function that can fill a given rectangle with
prime numbers. The width and height of the rectangle will be the input. The
output must be a list of height strings consisting of width digits and
spaces. Each horizontal (left to right) and vertical (top to bottom) digit
sequence (delimited by space or rectangle borders) of length 2 or greater must
be a prime number. Each prime number may be used only once. Leading zeros are
not allowed. A trailing new line is optional on the output.

Example:

With input (5, 3) a valid output would be:
11 13
7  0
 173

which scores 11, 13, 173, 17, 103 for a total of 5 points.

Score:

The rectangle size for scoring will be 80, 60.
Each horizontal or vertical prime number of length 2 or more in the rectangle
scores one point. The answer with the most points wins. In the event of a tie,
the earliest answer will win.

Rules:

Standard loopholes are prohibited.
Your program must not be designed for the 80, 60 size. If I suspect an
answer is optimised for this size, I reserve the right to change the rectangle
size up to 100, 100.
The primes used must be real primes (not probabilistic or pseudoprimes). Your program may compute or check numbers at run time, or have them hard coded. The method of finding the primes is not an important part of the challenge.
Your answer should include the output text and your code. If your program is too large, you may just include some core algorithm code, with a little explanation.

Edit: Clarified that real primes needed. Added maximum rectangle size.

Edit 2: Clarified what code needs to be posted.

Smalltalk, 1098 primes

First off, nice hard question - as evidenced by the lack of non-trivial responses thus far.

I had a solution cooking at work, but had to wait for the long weekend to have time to clean it up a bit. Even so, it's quite "heavy", so excuse the length of this answer - thankfully this isn't a code-golf question. There were plenty of little gotchas along the way, but I'm pretty sure it's bug-free now, though there is plenty of room for improvement and fine-tuning.

Language

My language of choice for this sort of thing is Smalltalk - the superior debugging and the ability to test-as-you-code beats anything else I know. Plus, even non-coders can read it and understand the basics of what's going on. I've limited the code below to the interesting part, because I thought the approach and results would be more interesting than the boilerplate code, but a file-out of the full code is pasted here if anyone wants to try it out (just save as a *.st and file it in from a file browser in Pharo). I used Pharo 4.0, which is FOSS and can be downloaded from pharo.org for Win/Mac/Linux. Also happy to paste the full code here, but I took the "should include the output text and your code" as a suggestion - let me know if I'm wrong.

Approach

So, my thinking was, what if you could start in the middle, stuff as many long primes as you could in the box, and work your way outwards from there? Let's start with a Box object, containing a matrix of characters, and then use a Stuffer object to try to fill it up by finding the best Insertion (another object) for each point in the matrix and for each prime (starting with the long ones). Pharo has nice Matrix and Point classes with a bunch of useful methods (though the matrix way of using row-major notation versus using x-y-coordinates of points can get a little confusing if you're not careful).

The basic steps of my algorithm are:

Create a Stuffer instance for given dimensions.
Have the stuffer initialise its box to size 5x5 (unless dimensions
are smaller).
Ask the Stuffer to stuff its box.

Iterate over a list of primes from largest to smallest.
Iterate over all points in the matrix.
Find the best spot to insert the prime, and insert if possible.

While the box can "grow" (until the target dimensions are reached),
increase it by one row/column on each side and copy the old contents
into the middle of the bigger one, then go to step 3.

Configurable:

The dimensions
The largest prime to start from
The "rating" of insertions (when choosing from multiple possible places to insert a prime)

For the matrix below, I used 80x60, primes below 20,000 (since the combined length of those is just under 10,000 characters, i.e. the maximum for a stuffed, though invalid, 100x100 box), and, after some experimentation, the following rating for each insertion:

(each accidentalPrimes size * 1) + (each numberOfOverlaps * 2)

where accidentalPrimes are the perpendicular primes "accidentally" created when inserting between neighbouring primes, and numberOfOverlaps is how many characters are overwritten (e.g. when adding a 3 at the end of 11 to insert 113). I initially had it weighted more towards accidentalPrimes, but got a few more primes in the box by doing it this way - not entirely sure why (feel free to test/tweak).

Result

| 1  3449 8    19489 8 7 9277 2 7 419  6   9533   19211    19373 4  79379 9 6 1 1|
|8861 1 7 26701 6   19219 6  97577 6 319211  84631   3 9649  8  19207 6 7 10399 9|
| 7 8 98669    19469 5 0  19301 2 6997 4   9787   19441  7 18899 9  2 47297 1 0 0|
|8839 8 7  1613 5 6  149837  0 97213 319289  6 8291  915991 431  909113 1 3382373|
| 7 7607 1 9 9 19543  1 8  3779   5743  6 19813  1946981    19423  139 9 9431 1 1|
|  6911 8933 2 9  9 1 4198013  9497   19447    1093 9 1194899 8  569 4 487749433 |
|  1 1 1 3 0 5653 19583 5  101429 4691  4 119813 9923  9 5 9  1811 47293 3533 1 1|
| 8849 8 86959 0 1  0 4 195071 7589 19429 5 1  4    3863 219763  9 2 1 9391 87833|
|  9 813613 7  719 19471   6 19727 809 7 19759 619867 6 988069 1 5 11 191 9 1 9 8|
|541 0 7 3547 1  70919 93715816451 19609 3  6  3 41  757219717 9803 9 9 9283  4 7|
|  3 1 9  1  691 6 4 177493124562997 7 1 719483  152993 8 9 6173 7 4871 0 7 15797|
|5171 373 9 1 4  318191 263 19843  19919  8 19889953 4  169639 9679 6 8887  9    |
| 8 8 1  5449 2 9 9399647333  7907  8 8 677   2 6 6 9967 101 8111 7 7 3 7 1907 1 |
| 7 67901 2 2 757 8 5 9 119759 7499 19853 19751 19913  59879 0  6469 171179 6 487|
|8747 0 9 78167 4 8 78839  6 99317  1 3 9 9 9   9  16993 7 8117 3373 9 9  8093 9 |
| 3 913457  31193 9 107 7 198439   9 19861 19697  99125471 1   16979 2819 0  9 1 |
|9 1951 0 1879 1 7 1 1 6569 853 18397  83 8 656269159547193329 97871 7 2  1 4337 |
|14831 9157 6449 0 9 9613 8 15619 148436196977821 19597 9 9 6907 8 383 16573 1  1|
|7 9 8   4518803 15647 9 941 19661 19963 149 19937  43913 2393 1433   1 1 1 9 9 8|
|3 1 3613719596827 8 2 6 5163998629 467 6271    13967 29399 51673 9 15973 87473 9|
| 9127 9  927191 19157 0 8 66938969 176597 19949 5779513 1319 6 92779 14717 3 7 1|
| 1  98849 8  9  9  8  3371771169929  169937 4 65519 79769 9 906473 58699 9 78173|
| 8    0 6 9907 682771709 9  9 3319763 947387669 479978309 8597 35393 369731 5   |
| 6211 1823 1 318691 96918839 9 19 918481 1997911733 58271 6 2 9 1  1  92219 661 |
| 7 8 7349  9 369739 7297 1 8641 4 12983    6 61991 619793 7 3 8297  15791 0 3   |
| 9 8 1 1 1 5  619 8 510589 396932999 7 5897537 997379 6   39313 4 439 69911   1 |
|1  64969 9 54139 7069 739 99639719 58693 4951 977   9 9151 8 9 6689 257 4 37199 |
|8  9 0 37529 9 4 91193  6 6 9 7  6 8 11117 3970331  11969963 661911661 727  9 3 |
|3613 0 8 5   3 2 8 9 1 499787 9137 71 19997 971939 13999 787 0 9 9  701 7 151 8 |
|7 8 6961 97607 1 15569 9 8 1 1 1171 99929 99733 1759 9817931 3 8941  193  968819|
|9 8 0 6    0 99767 8 769 88969 9859 979871393 1733 9377113 95111 5  8 2 94033  1|
| 9041 6 14519   1063 6 937 8 8 8999 92993171 11519 313 89417 7 317 5233 4 3  9 8|
|433  8179 6113 8971  3191 7559 17 63313 939793919 971 198769 5693 9 7 14657  6 7|
| 9  1  725189 1 7591139 9 93911 3919 9257 33739 9293 29 1973 2  9161 9511  17239|
|349 87151 99349 57529 7 36637 6359 81999119371933 4 98573 7549 6317 6619 8 9 3 3|
| 3  8 99371 8 8 374718269 1144935789717977  83177 9 233  1499 8 1571 4 8 6803 9 |
| 9 15641  3 1607  3 8 761 393388937 9    3967  9 9719 13997 1259 7 9639079 0 443|
|  1 9 2 14969 1109 8313931 8  198174119963 5 997 9 9 991 8 1217 52579  1 3911 1 |
|5281 277    1979 32909 9 986983 19991  61399991 127997 9 82939 907 571847 4 9 3 |
|  7 8  9 617 8 4 21613 2 95792383  919979 4951997317 93719 4 641379379 1 12487  |
|1 9 66959 8  8 4 3339313613 5119963  189967 359 337361 25933 83891   8 8191 7  1|
|8 7 8 61516883 1619 839 799859 2 7 19927 5 19777 6737 9769 37799 9 19079 0 9 1 9|
|57331 2 4 9 1 1  7691 9697 61 19577 6 9949 9 9 31979399 1 1 8737 509 1 49871 8 8|
|9  1 6397 109 99133 3 313888397 59419699  1986133  8387 9 988319 5 47237 7 8 9 0|
|3  62131 1  38629 8699 9 8599 953 397   736903  1991933 877 3 4799 1 1     77171|
| 1 8 8 9091 7 86491  627673 593 1  19853377 9781  8  3 76919  7  49739 1511  9  |
| 8 76991 0 938747 9 924629743 193873 2 699823 8719801 907871 19181   4 9 9 93371|
|6959 7 88867 6 7757 792383  8 9  0  1981337 3947  3 3917 2089979 9 92831 0 4 2 8|
| 4  5953 1 3739   69473 7 19709 99016787  379 9619759 196991 6 56393 9 3 82373 9|
|273613  1163  13883 919531 8  7433 6337 8893 6917   9 9 1693 8 0 7 709 93199 9 1|
|631 97159 8  181 9 6   0 0 7819753 673  9    9  9901 19699   18119 7  1 1 111779|
|9 8 0 9 0 2 7919 4419559 98179  6  9  19553 9851 4 9 9067 9857 4957 14939 9397  |
| 8753 0 3631 4 4 18973 9 7  89923 19793 1 8  3491954199497 53 2969  9 0 0 0 0 6 |
|1 9 1 5 1    5 24337 9  19603 7 9 3  4 195312373619977 9 119489 8 96293 643 0 4 |
|8 3   18461  7577 1 19541 8 3929 19463 6  3 49937 3 9 98297 71347 3 4 7 9 1 9 1 |
|87541   9 92707 9817  2 58237 1 4 6  919423 5    19403 77383 194179 9601 1 1 1 1|
|6 9 38923 4 261631 61937389 19387 390739 9 19319 6 495617 9 5  9  7  93979 8 8 8|
|9 449 5 4658147899073 7  3   60293 5  7 8231 2641930937 7 1950139511 6 0 26993 7|
|  0 0 2 34789739 1 3619501   61930959767 7 19237 7 9 9829   7    7   27773 5 7 5|
|823 7211 7 3 3 919231     9631 337 1  3    7 9 3      1 3943 19141 653 3 15971 7|

This matrix contains 1098 primes, which is a "load" of about 70%.

These are the primes (box primesUsed asSortedCollection printString):

11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 107 109 113 127 131 137 139 149 151 163 167 173 179 181 191 193 197 199 233 257 263 269 271 277 283 293 307 311 313 317 331 337 347 349 359 367 373 379 383 389 397 419 431 433 439 443 449 467 479 487 491 499 509 541 547 557 563 569 571 577 587 593 599 601 617 619 631 641 643 647 653 659 661 673 677 683 691 701 709 719 727 733 739 743 751 757 761 769 773 787 797 809 811 821 823 827 829 839 853 857 859 863 877 881 883 887 907 911 919 929 937 941 947 953 967 971 977 983 991 997 1063 1093 1109 1117 1153 1163 1171 1181 1217 1259 1319 1361 1399 1433 1499 1511 1571 1607 1613 1619 1637 1663 1667 1693 1697 1699 1733 1759 1811 1823 1879 1907 1913 1933 1949 1951 1973 1979 1987 1993 1997 1999 2393 2459 2617 2819 2927 2939 2969 3191 3229 3343 3373 3389 3449 3533 3539 3547 3613 3617 3631 3643 3733 3739 3769 3779 3793 3797 3821 3863 3911 3917 3919 3929 3931 3943 3947 3967 3989 4337 4409 4493 4691 4799 4871 4951 4957 4967 4999 5039 5099 5101 5171 5233 5281 5347 5399 5449 5479 5653 5693 5743 5939 5953 6079 6113 6131 6173 6197 6199 6211 6271 6317 6337 6359 6397 6449 6469 6569 6571 6599 6607 6619 6653 6661 6689 6737 6779 6781 6793 6803 6823 6829 6899 6907 6911 6917 6949 6959 6961 6967 6977 6997 7069 7079 7109 7193 7211 7219 7229 7297 7307 7349 7393 7433 7499 7549 7559 7577 7589 7607 7621 7691 7727 7757 7883 7907 7919 7949 7951 8093 8111 8117 8171 8179 8191 8219 8231 8291 8293 8297 8387 8419 8537 8539 8563 8597 8599 8641 8647 8681 8689 8693 8699 8719 8737 8747 8753 8779 8831 8839 8849 8861 8863 8887 8893 8929 8933 8941 8951 8963 8969 8971 8999 9007 9041 9067 9091 9109 9127 9137 9151 9157 9161 9173 9181 9187 9199 9257 9277 9281 9283 9293 9371 9377 9391 9397 9413 9419 9421 9431 9437 9461 9463 9467 9473 9479 9491 9497 9511 9521 9533 9539 9547 9551 9587 9601 9613 9619 9623 9629 9631 9643 9649 9661 9677 9679 9689 9697 9719 9721 9733 9739 9743 9749 9767 9769 9781 9787 9791 9803 9811 9817 9829 9833 9839 9851 9857 9859 9871 9883 9887 9901 9907 9923 9929 9931 9941 9949 9967 9973 10399 10979 11117 11519 11939 11959 11981 12487 12983 13313 13339 13463 13499 13763 13877 13883 13907 13931 13963 13967 13997 13999 14519 14657 14717 14831 14939 14969 15091 15569 15619 15641 15647 15791 15797 15971 15973 16573 16699 16937 16979 16993 17239 17333 17519 17761 17891 18119 18371 18379 18397 18461 18593 18691 18719 18757 18773 18787 18803 18839 18859 18869 18899 18911 18913 18917 18919 18959 18973 18979 19001 19009 19013 19031 19037 19051 19069 19073 19079 19081 19087 19121 19139 19141 19157 19163 19181 19183 19207 19211 19213 19219 19231 19237 19249 19259 19267 19273 19289 19301 19309 19319 19333 19373 19379 19381 19387 19391 19403 19417 19421 19423 19427 19429 19433 19441 19447 19457 19463 19469 19471 19477 19483 19489 19501 19507 19531 19541 19543 19553 19559 19571 19577 19583 19597 19603 19609 19661 19681 19687 19697 19699 19709 19717 19727 19739 19751 19753 19759 19763 19777 19793 19801 19813 19819 19841 19843 19853 19861 19867 19889 19891 19913 19919 19927 19937 19949 19961 19963 19973 19979 19991 19993 19997 21613 24239 24337 25933 26449 26701 26959 26993 27773 27919 29399 31193 32909 33739 35393 36637 36761 37199 37529 37799 38333 38629 38839 38861 38923 39293 39313 39733 43913 43943 45281 47237 47293 47297 47933 47939 48311 48761 49123 49199 49739 49871 49937 49999 51193 51673 52379 52579 54139 55313 56393 56983 57173 57331 57529 58237 58271 58693 58699 59743 59879 60293 61979 61991 62131 62873 63313 64969 65519 66491 66959 67339 67901 67993 69337 69473 69623 69697 69911 69941 70919 71347 71777 71933 75347 76163 76733 76919 76991 77171 77213 77383 77591 78167 78173 78839 78941 79379 79613 79631 79769 79967 80933 81919 82373 82939 83177 83891 84631 86491 86959 87151 87473 87541 87833 88499 88867 88951 88969 89413 89417 89519 89923 91193 91813 91997 92219 92593 92647 92707 92779 92831 93199 93371 93719 93911 93913 93971 93979 94033 94397 94399 95111 96233 96293 96587 96911 96959 96979 97159 97213 97577 97607 97787 97871 97919 98179 98297 98299 98573 98669 98837 98849 99133 99233 99317 99349 99371 99497 99733 99767 99907 99929 101429 111149 111779 119489 119759 119813 127997 149837 152993 167747 168863 169639 169937 171179 176597 179099 179111 183797 187973 188693 189473 189967 190811 191837 193813 193873 194179 195071 195319 196817 196871 196991 197273 197599 198013 198017 198439 198673 198769 199373 199679 199739 219763 261631 273613 277793 316879 318191 318691 319031 319069 319211 319289 319427 319727 319973 337361 369731 369739 390739 391753 414347 419801 439883 495617 499787 510589 519031 571847 601189 615749 616367 618719 619543 619583 619753 619763 619793 619813 619867 627673 639631 669923 698339 699823 716987 719009 719441 719483 719801 719813 725189 736903 792383 796553 799859 809339 813613 815569 819373 819457 829733 906473 907871 909113 912797 913457 914813 915641 915991 917159 918481 918679 918793 919183 919231 919381 919421 919423 919531 919559 919913 919979 927191 935639 938747 939439 943913 962971 968819 971939 976777 986983 988069 988319 991733 997319 997379 1194899 1518379 1678739 1691189 1867993 1899907 1903703 1923151 1942771 1946981 1950149 1981337 1986133 1988999 1991933 2089979 2919031 3110651 3190871 3193913 3197633 3319763 3382373 3619501 3970331 4198013 4419559 4518803 5119963 5195077 5319289 5619139 5779513 5897537 6119801 6129587 6189137 6194891 6198139 6649871 7219427 7591139 7819753 7937939 7982969 8019727 8313931 8419381 8719801 8783371 9119909 9189797 9323173 9377113 9619759 9639079 9679799 9717317 9721301 9721991 9817931 9911789 9923369 9967759 11969963 15619867 16981331 19669931 19717099 19793479 19853377 19889953 21968773 27519469 31979399 34789739 40699733 59419699 61399991 61516883 61897937 61937389 63519427 66938969 69719801 74969767 91938191 92993171 93369931 95792383 96918839 99016787 99125471 99639719 126919421 179319979 199733981 199739717 313888397 342719753 374718269 393388937 396932999 439314797 479978309 487749433 577519913 613799299 631819381 641379379 661911661 682771709 689194217 757219717 924629743 936195479 939793919 947387669 979871393 991579637 1903149343 1921376857 1945706473 1950139511 1960317529 1997911733 2641930937 3339313613 4951997317 4952523041 5163998629 7017198679 7981707577 9013119991 9119993297 9399647333 9945519919 18919323977 19031318947 19919788793 31879359403 61930959767 61960309907 91734751987 92774649739 93715816451 95479219889 98371979359 99551395387 191830198139 198012194899 198017187931 198174119963 213963819763 419801418947 819853319867 1937327699987 3189735598139 3371771169929 3491954199497 3613719596827 4658147899073 81999119371933 148436196977821 177493124562997 195312373619977 1144935789717977 656269159547193329 735547997331319937 11572771955941937959

As you can see, some of the "accidental" primes get quite long... 20 digits for the longest one. :-)

Details

To understand how it works, here is the output from doing the first few steps - inserting 19997 first (if you look in the middle of the big matrix, you'll see 19997 there as well), then down the list where there's space in the 5x5 box (> means insert going right, v means going down; anything in {} are accidentally added primes:

Insertion at: (1@1) > {} of 19997
Box 5x5 (1 prime, load: 20%):
|19997|
|     |
|     |
|     |
|     |

Insertion at: (1@1) v {} of 19993
Box 5x5 (2 primes, load: 36%):
|19997|
|9    |
|9    |
|9    |
|3    |

Insertion at: (3@1) v {} of 9973
Box 5x5 (3 primes, load: 48%):
|19997|
|9 9  |
|9 7  |
|9 3  |
|3    |

Insertion at: (1@4) > {} of 9931
Box 5x5 (4 primes, load: 56%):
|19997|
|9 9  |
|9 7  |
|9931 |
|3    |

Insertion at: (1@3) > {89, 11} of 9871
Box 5x5 (7 primes, load: 64%):
|19997|
|9 9  |
|9871 |
|9931 |
|3    |

Insertion at: (5@1) v {98713, 99317} of 7937
Box 5x5 (10 primes, load: 76%):
|19997|
|9 9 9|
|98713|
|99317|
|3    |

Insertion at: (4@3) v {} of 113
Box 5x5 (11 primes, load: 80%):
|19997|
|9 9 9|
|98713|
|99317|
|3  3 |

11 old primes: 19997, 19993, 9973, 9931, 9871, 89, 11, 7937, 98713, 99317, 113
8 new primes: 19997, 98713, 99317, 19993, 89, 9973, 113, 7937
Insertion at: (4@1) v {} of 19973
Box 7x7 (9 primes, load: 42%):
|   1   |
| 19997 |
| 9 9 9 |
| 98713 |
| 99317 |
| 3  3  |
|       |

In the insertion immediately above, the box becomes a 7x7, and is filled with the 5x5 contents before the next insertion happens. I also re-calculate the primes used at this point, because some are "freed up" due to overwriting (11 was inserted, but then overwritten by 113).

Code

Here are the most relevant parts of the code:

Stuffer class

Class side

forDimensions: aPoint
    ^self new
        width: aPoint x;
        height: aPoint y;
        initializeBox;
        yourself

Instance side

initializeBox
    box := Box width: (width min: 5) height: (height min: 5)

stuffBox
    self stuffCurrentBox.
    [self canGrow] whileTrue: [
        box growMatrixByOneUpTo: width @ height.
        self stuffCurrentBox
        ]

canGrow
    ^width > box width or: [height > box height]

stuffCurrentBox
    self class primes reverseDo: [:eachPrime |
        | string insertion |
        (box primesUsed includes: eachPrime) ifFalse: [
            string := eachPrime asString.
            (insertion := box bestInsertionFor: string) ifNotNil: [
                Transcript crShow: insertion printString, ' of ', string.
                box doInsertion: insertion of: eachPrime.
                Transcript crShow: box
                ]
            ]
        ].
    box updatePrimesUsed.

Box class

Instance side

bestInsertionFor: aString
    | insertions |
    insertions := OrderedCollection new.
    self pointsDo: [:eachPoint |
        insertions
            addIfNotNil: (self insertionOf: aString at: eachPoint isHorizontal: true);
            addIfNotNil: (self insertionOf: aString at: eachPoint isHorizontal: false)
        ].
    insertions removeAllSuchThat: [:each |
        self isInsertion: each invalidWith: aString asInteger
        ].
    ^insertions detectMax: [:each |
        (each accidentalPrimes size * 1) + (each numberOfOverlaps * 2)
        ]

insertionOf: aString at: aPoint isHorizontal: isHorizontal
    | point insertion |
    point := aPoint.
    (self canFitEndsAt: point length: aString size isHorizontal: isHorizontal)
        ifFalse: [^nil].
    (self isAlreadyThere: aString at: aPoint isHorizontal: isHorizontal)
        ifTrue: [^nil].
    insertion := Insertion at: point isHorizontal: isHorizontal.
    1 to: aString size do: [:eachIndex |
        | eachCharacter |
        eachCharacter := aString at: eachIndex.
        (self canDoInsertion: insertion of: eachCharacter at: point)
            ifTrue: [
                (self at: point) == eachCharacter
                    ifTrue: [insertion increaseOverlaps].
                point := point + (self offset: isHorizontal)
                ]
            ifFalse: [^nil]
        ].
    ^insertion

isInsertion: anInsertion invalidWith: aPrime
    | otherPrimes |
    otherPrimes := anInsertion accidentalPrimes.
    ^(primesUsed includesAny: otherPrimes)
        or: [(otherPrimes includes: aPrime)
        or: [otherPrimes copy removeDuplicates size < otherPrimes size]]

canDoInsertion: anInsertion of: aCharacter at: aPoint
    "Answer whether anInsertion of aCharacter is valid at aPoint. If so,
    also update anInsertion with any accidental insertions."

    | perpendicularSequence offset front back |
    (self at: aPoint) == aCharacter
        ifTrue: [^true].
    (self isFreeAt: aPoint)
        ifFalse: [^false].
    perpendicularSequence := OrderedCollection with: aCharacter.
    offset := self offset: anInsertion isHorizontal not.
    front := aPoint - offset.
    back := aPoint + offset.
    [self isFreeOrBorder: front] whileFalse: [
        perpendicularSequence addFirst: (self at: front).
        front := front - offset
        ].
    [self isFreeOrBorder: back] whileFalse: [
        perpendicularSequence addLast: (self at: back).
        back := back + offset
        ].
    ^perpendicularSequence size == 1
        or: [
            | string number |
            string := String withAll: perpendicularSequence.
            number := string asInteger.
            (string first ~~ $0 and: [number isPrime])
                ifTrue: [anInsertion addAccidentalPrime: number. true]
                ifFalse: [false]
            ]

doInsertion: anInsertion of: aPrime
    self
        insert: aPrime printString
        at: anInsertion point
        horizontalIf: anInsertion isHorizontal.
    primesUsed
        add: aPrime;
        addAll: anInsertion accidentalPrimes

growMatrixByOneUpTo: aDimension
    | smallMatrix rowOffset columnOffset |
    smallMatrix := matrix copy.
    matrix := Matrix
        rows: (self height + 2 min: aDimension y)
        columns: (self width + 2 min: aDimension x)
        element: Character space.
    rowOffset := (self height - smallMatrix numberOfRows) min: 1.
    columnOffset := (self width - smallMatrix numberOfColumns) min: 1.
    self copy: smallMatrix to: (1 + columnOffset) @ (1 + rowOffset)

copy: aMatrix to: aPoint
    matrix
        atRows: aPoint y
        to: aPoint y + aMatrix numberOfRows - 1
        columns: aPoint x
        to: aPoint x + aMatrix numberOfColumns - 1
        put: aMatrix

Collection

Oh, and I added one method to the instance side of Collection, just for convenience:

addIfNotNil: anElement
    anElement ifNotNil: [self add: anElement]

Running it

To run my code, all I need to do is select the following code in a workspace ("playground" in Pharo) or in any text pane, and "do it" from the context menu:

(Stuffer forDimensions: 80@60)
    stuffBox

The rest of the code is relatively boring.

As I said, room for improvement, but at 80x60, each run takes over 3 minutes on my machine. Clearly, performance hasn't been my concern, but there are a LOT of primes flying around. This sure has been an interesting challenge. :-)


Partially Solve the halting problem for brainf*** To solve the Halting Problem you are given a description of a program, and must determine whether or not it will ever finish. You can never do this for all programs. Yet for programs like (in brainf***):

>

It obviously will halt, and for programs like:

+[]

It obviously will not. Your challenge is to "solve" the halting problem for as many programs as possible. These programs will not use . or ,, and will not have input or output. You will be given a description of the program and must output either "Halts", "Does not halt", or "Unknown". When your program outputs "Halts" or "Does not halt", you have solved the input program. Here are some requirements.

It must solve at least an infinite amount of programs.
For every program it solves, its solution must be correct.
You may only output 1 of the 3 above choices.
You may assume that the running computer has infinite time and memory, so XKCD 1266 would not work (the tape is unlimited).
No external resources.
You may not use a programming language that can actually solve the halting problem.

You may have a non-code-golfed side program that takes a string that is a program, and generates some sort of abstract syntax tree of it if you like. Note, that isn't really scoring per se, but how to determine if one program beats another.

If program A solves an infinite number of programs that B doesn't, but B only solves finite or no programs that A solves, A automatically wins.
Otherwise, the program with the fewest characters wins. Do not count white space or comments, so do not obfuscate your code.

Tip: Timers won't work. You see, for any time T and given machine, there is an N, such that all programs longer than that have to take more than T time. This means that a timer can only achieve the solution of a finite number of programs, and, as you can see above, solving a finite number of programs doesn't help.

Python, ungolfed spaghetti code

Oh dear.

def will_it_halt(instructions):
    tape_length = 1
    LOOP_BOUND = 1000
    registry = [0] * tape_length
    pos = 0

    jumpbacks = []
    reached_states = set()

    pos_instructions = 0
    while True:
        letter = instructions[pos_instructions]
        if letter == "+":
            registry[pos] = (registry[pos] + 1) % 256
        elif letter == "-":
            registry[pos] = (registry[pos] - 1) % 256
        elif letter == ">":
            pos += 1
            if pos >= tape_length:
                registry += [0]*tape_length
                tape_length = len(registry)
        elif letter == "<":
            pos -= 1
            if pos <= 0:
                registry = [0]*tape_length+registry
                tape_length = len(registry)
                pos += tape_length
        elif letter == "[":
            if registry[pos] == 0:
                nests = 1
                while nests:
                    pos_instructions += 1
                    if instructions[pos_instructions] == "[": nests += 1
                    elif instructions[pos_instructions] == "]": nests -= 1

                if jumpbacks == []:
                    reached_states.clear()

            else:
                jumpbacks.append(pos_instructions-1)

        elif letter == "]":
            stripped_registry = [str(x) for x in registry if x != 0]
            translated_pos = pos - (len(registry) - len(stripped_registry))
            state = (translated_pos, pos_instructions, ".".join(stripped_registry))
            if state in reached_states: return "Does not halt"
            elif len(reached_states) > LOOP_BOUND: return "Unknown"
            else:
                reached_states.add(state)
                pos_instructions = jumpbacks.pop()
        pos_instructions += 1
        if pos_instructions >= len(instructions): break
    return "Halts"

Pretty brute-forcey solution to the problem: just run the bf code. We assume the tape length is arbitrarily long and that individual cells wrap at 256. At the end of every loop, we store the state of the tape with a set. States are of the form (our position on the tape, our position on the instructions, what the tape looks like with leading 0's stripped).

If we store the same state twice, then we're somewhere in an infinite loop, so the program does not halt. If we store over 1,000 states, then cut losses and return unknown. Once we leave a loop we check to see if we aren't in any larger loops. If not, we're never seeing any of the previous states ever again (at the very least, the instruction position will always be different!) so we can clear the set of states.

This should accurately determine any BF program who's loops aren't longer than 1,000 iterations, as well as many programs that repeat a state before 1,000 iterations in a loop. Not all of them, though: something like "{1 million +'s here}[-]>+[+-]" eventually repeats a state, but the [-] loop passes 1,000 iterations first.

Some examples:

>+>->+>-

No loops, so it reaches the end and halts.

+[+]

Loop ends after 256 iterations, so it reaches the end and halts.

+[+-]

Eventually repeats the state (0,5,"1"), so it does not halt.

+[->+]

This doesn't repeat any states but the loop never ends, so it should print "unknown". But the program kind of cheats here. Instead of storing the position on the tape, it adds an offset between the original registry and the stripped one. If all a loop does is translate the tape by some spaces, then it will continue translating it indefinitely (like a life glider), so we can say it does not halt.

+[>+]

Doesn't translate, doesn't repeat any states, prints unknown.

+++++++++++[-]

This does halt, but it would print "unknown" if LOOP_BOUND was 10.

There's a couple of ways to make this smarter. You could obviously increase LOOP_BOUND to reduce the number of unknowns. You could have smarter handling of nested loops. You could probably do something fancy with BB numbers and the size of loops to better detect if something should halt, but I'm not good enough at CS nor at Python to be able to do that yet.


The group of sequential positive numbers with the highest sum? Given the following list of numbers, find the group of
sequential positive numbers with the highest sum.

Example input:

12 2 35 -1 20 9 76 5 4 -3 4 -5 19 80 32 -1

Example output:

131

The most succinct code wins.

My approach via Perl is 87 chars (with input as command-line args):

print((sort { $b <=> $a } do { push @s, $_ > 0 ? pop(@s) + $_ : 0 for @ARGV; @s })[0]);

APL, 35 characters

i←⎕⋄⌈/{{+/⍵/⍨∧\⍵>0}⍵↓i}¨0,(i≤0)/⍳⍴i

I used Dyalog APL for this. ⎕IO should be set to its default of 1.

Example (note that high-minus, ¯, must be used instead of regular minus):

      i←⎕⋄⌈/{{+/⍵/⍨∧\⍵>0}⍵↓i}¨0,(i≤0)/⍳⍴i
⎕:
      12 2 35 ¯1 20 9 76 5 4 ¯3 4 ¯5 19 80 32 ¯1
131

Explanation (roughly right-to-left for each expression):

First, we get (and evaluate) the input: i←⎕. (⋄ separates expressions in a single statement.)
(i≤0)/⍳⍴i is an idiom to get the list of the locations of elements of i that are ≤0.

i≤0 returns a vector of binary values, where each element is 1 if the corresponding element in i is ≤0, and 0 otherwise.
⍳⍴i returns a list of integers, from 1 to the shape (length) of i.
The replication function, /, replicates each value in its right argument n times, where n is the corresponding element in its left argument. Because we have a binary list, this just includes or excludes elements (replicating them 0 or 1 times).
We tack a 0 on the beginning, using the concatenation operator (,).

Now, using the example input, we have the vector 0 4 10 12 16. We use the each operator, ¨, to map a function (its left operand) to each element of this list.
The function is a direct function (basically, an anonymous function), and its definition is surrounded with curly braces. Its right argument is represented by the omega symbol, ⍵.
For each element of our vector:

The outermost function, {{ ... }⍵↓i}, returns the vector i, with ⍵ elements dropped (↓) from the beginning. This is then fed to...
The innermost function, {+/⍵/⍨∧\⍵>0}, in slightly less golfed form is {+/(∧\⍵>0)/⍵}.
(∧\⍵>0)/⍵ is similar to the aforementioned idiom. First we generate a list of elements in ⍵ that are above 0. Then, we use the scan operator, \, along with the bitwise-AND function, ∧, to return the list (⍵1 , ⍵1 ∧ ⍵2 , ⍵1 ∧ ⍵2 ∧ ⍵3 , ...). In other words, this list consists of 1's up until the first non-positive element, where it is then all 0's. We use replication as before.
We now use the reduction operator, (also) represented by /, along with the addition function, +, to fold all positive elements in the current list, up to (but not including) the first non-positive one.

Lastly, we fold again, this time with the maximum function, ⌈.

Here are snapshots showing the results of some stages:

      i≤0
0 0 0 1 0 0 0 0 0 1 0 1 0 0 0 1

      ⍳⍴i
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

      0,(i≤0)/⍳⍴i
0 4 10 12 16

      {⍵↓i}¨0,(i≤0)/⍳⍴i
 12 2 35 ¯1 20 9 76 5 4 ¯3 4 ¯5 19 80 32 ¯1  20 9 76 5 4 ¯3 4 ¯5 19 80 32 ¯1  4 ¯5 19 80 32 ¯1  19 80 32 ¯1

      {{(∧\⍵>0)}⍵↓i}¨0,(i≤0)/⍳⍴i
 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0  1 1 1 1 1 0 0 0 0 0 0 0  1 0 0 0 0 0  1 1 1 0

      {{(∧\⍵>0)/⍵}⍵↓i}¨0,(i≤0)/⍳⍴i
 12 2 35  20 9 76 5 4  4  19 80 32

      {{+/(∧\⍵>0)/⍵}⍵↓i}¨0,(i≤0)/⍳⍴i
49 114 4 131 0

Hopefully some of this makes a bit of sense!


Golf a Compute interpreter Introduction
Compute is a esoteric joke language.
From the esolangs entry:

Compute has no required syntax and has the power to solve any and all
problems. It is smart enough to interpret any human language (English,
Spanish, Latin, etc), any programming language (C++, Java, brainfuck,
etc), or any kind of data you can think of. The only downfall is that
there is absolutely no I/O.

Some example programs
Hello World

A basic Hello World program
What is love?

Determines was love is (baby don't hurt me).
When will we ever graduate?

Determines the exact date of this site to get out of beta.
The Challenge
Your task is to write a full Compute interpreter. This sounds pretty hard, but keep in mind that Compute has absolutly no I/O. So your interpreter will just sleep one second for every line in the input program and output \n\nDone. after this (this is the only exception to the no I/O thing).
You can find the official interpreter at the bottom of this site.
Note that the official interpreter pauses one second for every character in the given source code. To avoid long waiting times while testing your interpreter with meaningful questions we stay with lines in this challenge.
Rules

The input might contain multiple lines seperated by a \n. There will always be at least one line.
Unlike the official implementation you don't have to take a file as input. You can take the Compute program in any form of input you want.
The only output allowed is \n\nDone.. A trailing newline is allowed.
Function or full program allowed.
Default rules for input/output.
Standard loopholes apply.
This is code-golf, so lowest byte-count wins. Tiebreaker is earlier submission.

05AB1E, 16 15 14 13 bytes
Code:
[Ig>#w’

D€µ.

Explanation:
[        # Starts an infinite loop
 I       # Input string
  g>     # Length + 1
    #    # If equal to 1, break out of the loop
     w   # Wait 1 second

This part is equivalent to "\n\nDone.":
      ’  # Push "\n\nDone." on top of the stack

D€µ.     # The compressed string is ended implicitly
         # Implicit, print top of the stack

Try it online!
Uses CP-1252 encoding.


Print all 2 letter Scrabble Words The Challenge:
Print every 2 letter word acceptable in Scrabble using as few bytes as possible. I have created a text file list here. See also below. There are 101 words. No word starts with C or V. Creative, even if nonoptimal, solutions are encouraged.
AA
AB
AD
...
ZA

Rules:

The outputted words must be separated somehow.
Case does not matter, but should be consistent.
Trailing spaces and newlines are allowed. No other characters should be outputted.
The program should not take any input. External resources (dictionaries) cannot be used.
No standard loopholes.

Wordlist:
AA AB AD AE AG AH AI AL AM AN AR AS AT AW AX AY
BA BE BI BO BY
DE DO
ED EF EH EL EM EN ER ES ET EX
FA FE
GO
HA HE HI HM HO
ID IF IN IS IT
JO
KA KI
LA LI LO
MA ME MI MM MO MU MY
NA NE NO NU
OD OE OF OH OI OM ON OP OR OS OW OX OY
PA PE PI
QI
RE
SH SI SO
TA TI TO
UH UM UN UP US UT
WE WO
XI XU
YA YE YO
ZA

Python 3, 194 188 bytes
s="BI ODEXIF BAAX ASOHER LOXUMOPAGOR KI US AMY BOITONOSI MMEMINANEHI UPI AYAHOYOWOMUNUHAID PEFARED QIS BEN JOFETAE KAT ABYESHMALI UTI ZADOELAWE "
while s:" "in s[:2]or print(s[:2]);s=s[1:]

Almost definitely not the shortest method, but I thought this would be a good start. Try to pack each pair into paths by overlapping as much as possible (e.g. "ODEX..." = ["OD", "DE", "EX", ...]). Spaces are used to separate paths, and any pairs with a space in it is removed (the trailing space is to prevent a single E from being printed at the end).
I also tried regex golfing this but it was longer.


Make me an Easter egg! No, not the ^^vv<><>BA kind of Easter eggs, real Easter eggs that we paint.

Here is an (awfully drawn) egg.

  __
 /  \
/    \
|    |
\____/

In easter, we paint them with patterns. Like these:

  __
 /--\
/----\
|----|
\____/
  __
 /%%\
/%%%%\
|%%%%|
\____/
  __
 /~~\
/~~~~\
|~~~~|
\____/

The challenge

Given a character (printable ascii) to paint the egg, print the painted egg.

Examples:

&:
  __
 /&&\
/&&&&\
|&&&&|
\____/

#:
  __
 /##\
/####\
|####|
\____/

Specs

Trailing newlines/spaces are allowed.


Reflective binary ordering The reverse of an n-bit number is just its n binary digits in reverse order:

  001010010 → 010010100

Given a number n, generate all n-bit integers ([0, 2n-1]) in an arbitrary order, with only one restriction: there must be a splitting point such that  the reverse of an integer is on the opposite side of the splitting point. Integers which are their own reverse must come before the splitting point.

Other than this single splitting point there are no restrictions, all the integers before or after it may come in whatever order you desire.

Example for 4 bits (you don't have to generate this order):

0000, 0001, 0010, 0011, 0101, 0110, 0111, 1001, 1011, 1111,
0100, 1000, 1010, 1100, 1101, 1110

You may output the integers as their binary digits or just as integers. You don't have to explicitly output the splitting point.

JavaScript (ES6), 129 114 bytes

f=n=>[...Array(p=1<<n)].map((_,i)=>(p+i).toString(2).slice(1)).sort((a,b)=>g(a)-g(b),g=a=>[...a].reverse().join``<a)

I appear to have stumbled on the code that happens to generate the given example for 4 bits. Edit: Saved 15 bytes thanks to @ConorO'Brien.


Simulate a battle between two creatures Welcome, brave code golfer! Today you will stand in the midst of a great battle between a goblin and an elf!

    goblin attacks elf!
    elf dodges!
    elf attacks goblin!
    elf hits goblin for 13 damage!
    goblin has 37 health left.
    goblin attacks elf!
    goblin hits elf for 1 damage!
    elf has 49 health left.
    elf attacks goblin!
    elf hits goblin for 19 damage!
    goblin has 18 health left.
    goblin attacks elf!
    goblin hits elf for 26 damage!
    elf has 23 health left.
    elf attacks goblin!
    elf hits goblin for 20 damage!
    goblin has been slain!

The Challenge

Your challenge is to simulate a battle, like the above one. You will recieve input in this form:

creatureName health strength defense accuracy agility

For example, the battle between the goblin and elf would be:

goblin 50 40 35 3 2 elf 50 35 30 4 5

The first and second creatures will alternate attacks.

Print 'creatureName attacks otherCreatureName!'
Check to see if the creature dodges. The creature will dodge an attack if (its agility times rand() divided by 2) is greater than (the attacker's accuracy times rand()).

If the creature dodges, print 'creatureName dodges!'
Otherwise, calculate the damage dealt by subtracting (the attacker's strength times rand()) and (the defender's defense times rand() divided by 2). Minimum damage is 1. Print 'creatureName hits otherCreatureName for (x) damage!' Then print 'creatureName has (x) health left.' unless the creature's health is 0 or less, in which case...

If the creature's health is 0 or less, print 'creatureName has been slain!' and end the program.

Rules

Shortest code wins.
Don't literally print 'creatureName,' but replace it with the creature's name. Don't print '(x) damage' or '(x) health;' replace them with the actual amount. (I have to specify this because some people are very creative with bending the rules. :P)

Perl, 254 + 1

for((@a[0..5],@b)=split;$a[1]>0;@c=@a,@a=@b,@b=@c){say"$a[0] attacks $b[0]!\n",rand$b[5]/2<rand$a[4]?do{($==rand($a[2])-rand$b[3]/2)<1and$==1;"$a[0] hits $b[0] for $= damage!\n$b[0] has ",($b[1]-=$=)>0?"$b[1] health left.":"been slain!"}:"$b[0] dodges!"}

Run with perl -nM5.010 (or perl -nE '<code>').  Per meta, the -n switch counts as one extra character.
No fancy golfing tricks in this code, except maybe the use of $= as the damage variable to save an int.

Edit: Hopefully, the damage calculation is correct now.


Change text gravity like the 2048 puzzle In the game 2048, you have a grid, and you can move the elements in four directions. They all move in that direction as far as they can. For this challenge, you will be given a padded, square 2D string (either with newlines, or a list of strings), like so:

ab cd e
 f ghij
      kl
mno p
 q r st
u      v
 w x  y
z

or

['ab cd e ', ' f ghij ', '      kl', 'mno p   ', ' q r st ', 'u      v', ' w x  y ', 'z       ']

The four operations are left, right, up, and down. The result of each on the above input:

Left:

abcde
fghij
kl
mnop
qrst
uv
wxy
z

or

['abcde   ', 'fghij   ', 'kl      ', 'mnop    ', 'qrst    ', 'uv      ', 'wxy     ', 'z       ']

Right:

   abcde
   fghij
      kl
    mnop
    qrst
      uv
     wxy
       z

or

['   abcde', '   fghij', '      kl', '    mnop', '    qrst', '      uv', '     wxy', '       z']

Up:

abocdiel
mf ghsjv
un rp k
zq x  t
 w    y

or

['abocdiel', 'mf ghsjv', 'un rp k ', 'zq x  t ', ' w    y ', '        ', '        ', '        ']

Down:

 b    e
af c  j
mn gd k
uq rhitl
zwoxpsyv

or

['        ', '        ', '        ', ' b    e ', 'af c  j ', 'mn gd k ', 'uq rhitl', 'zwoxpsyv']

Your goal is to rotate which operation is performed each iteration, performing them on the input n times. So if your order is URDL, and the input says to start with D (2, 0-indexed), and you need 5 operations, you perform D-L-U-R-D, then print.

Input:

A string in a format like above

Trailing spaces are not required (but they are probably helpful)
It will be at least 2x2
Will only contain printable ASCII and spaces (and newlines per your input format)
You should theoretically support any length, but memory constraints are okay

A non-negative integer, n, for the number of operations that will be performed
An integer 0-3 or 1-4, or a letter UDLR, describing the operation to start with.

So your program must be able to start or end with any operation
You may define them in any order for starting purposes, but it must be a consistent order, so U cannot sometimes follow R and also sometimes follow L.

Operations must be performed non-trivially

You could do operations in the order LDRU (left, down, right, up) repeatedly, but not DLRU or UDLR (because UD is the same as D, and LR is the same just as doing R.)

Output:

The string after performing the four operations n times
The output format must be the same as your input format
Trailing spaces are not required (but they are probably helpful)

Example:

This example uses the order URDL.

Input:

10  (number of times operations are applied)
0   (starts with Up)

ab cd e
 f ghij
      kl
mno p
 q r st
u      v
 w x  y
z

Outputs for n = 0-5: (just print the end result)

ab cd e
 f ghij
      kl
mno p
 q r st
u      v
 w x  y
z
---------------
abocdiel
mf ghsjv
un rp k
zq x  t
 w    y

---------------
abocdiel
 mfghsjv
   unrpk
    zqxt
      wy

---------------

      el
    dijv
   chspk
 bognrxt
amfuzqwy
---------------

el
dijv
chspk
bognrxt
amfuzqwy
---------------
eljvkxty
disprqw
chgnz
bofu
am

My pretty, ungolfed implementation

Jelly, 23 bytes
UZ
Ç¡=⁶$Þ€Ç$⁴¡ZU$⁵+⁴¤¡Y

Try it online!
I'm a bit unsatisfied, but MATL needed some competition. :P
Uses the order URDL. Inputs:

the input array as an array of padded lines
the number of repetitions
the move to start from (1 = U, 2 = R, 3 = D, 4 = L)

Explanation
UZ       Helper link. Argument: A (the 2D array)
U        Reverse each line and...
 Z       ...transpose. Rotates 90° CCW.

Ç¡=⁶$Þ€Ç$⁴¡ZU$⁵+⁴¤¡Y    Main link. Arguments: A, n (2D array, repetitions)
Ç                       Rotate 90° CCW...
 ¡                      ...m times. (m = which move to start on)

     Þ                  Sort...
      €                 ...each line of the array...
  =⁶                    ...based on the characters' equality to " ".
       Ç                Rotate 90° CCW.
        $               Combine the sort and rotate to one action.
         ⁴¡             Do that n times. (n = repetition count)

           Z            Transpose and...
            U           ...reverse each line. Rotates 90° CW.
             $          Combine the transpose and reverse to one action.
                  ¡     Do that...
              ⁵+⁴¤      ...m + n times.

                   Y    Join the array by newlines.


Find the number of x-digit numbers whose product of digits is N Given two numbers \$N\$ and \$x\$, find the number of \$x\$-digit numbers whose product of digits is \$N\$
\$N <10^6\$ and \$x <12\$
Sample Input (N x):
8 3
Sample Output:
10

Golfscript 42 31

~10\?.10/\,>{10base{*}*1$=},,\;

Input: Expects the numbers N and x as command line arguments (separated by space).

The program can be tested here.


When does hh:mm = mm.ss? Let's begin with a thought experiment. You have a clock and a timer, in which you start the timer when the clock shows exactly hh:mm.00.

Clock: The clock employs 24-hour time. So the range of hh is 0<=h<23. (Because 23 inputs are unsolvable, you aren't required to handle that)
Timer: It starts exactly on 00.00. The number to the right of . isn't milliseconds; it's seconds.

What you need to do is to find out when the two numbers represented by clock time (hh:mm) is respectively equal to the timer time (mm.ss); e.g. 13:24 is "respectively equal" to 13.24. There can potentially be more than one time.
An example
Say the input is 1:59.
Clock: 1:59
Timer: 0.00   (The timer just started)

...
Clock: 1:59
Timer: 0.59   (59 seconds later...)

...

Clock: 2:00
Timer: 1.00   (As the timer's second section rounds up to the minute section, the clock time gets incremented by a minute. And the 59 minutes in the clock section gets rounded up to the hour section, hence the 2:00.)

...
Clock: 2:00
Timer: 1.59 (59 seconds later...)

...
Clock: 2:01
Timer: 2.00 (The timer minute gets rounded up, as the clock time increments by a minute)

...
Clock: 2:01
Timer: 2.01 (Now the clock time is "respectively equal" to the timer time)

Therefore you need to output 2:01 for the 1:59 input.
Examples
Here is a sample program I use to check my test cases.
0:59 -> 0:59 (or 1:00, if your answer supports that)
1:30 -> 1:31
2:59 -> 3:02
1:59 -> 2:01
3:58 -> 4:02
22:01->22:23

Specifications

Although in the test cases, the input is taken as hh:mm, you can nevertheless take input in a list, e.g. [hh,mm], or any format suitable for your answer.
You can output the time in the format [mm,ss].
You could start two physical timers, but you need to optimize their speed somehow. Your code running all of the test cases must terminate in 60 seconds.
You are allowed to take input/output as base 60.
You don't need to handle unsolvable inputs. I.e. The hour section in the clock will never be 23.
If you find more than one time for a specific test case, you can output any of them.

Raku, 14 12 11 bytes

0+|*/.98334

Try it online!
Since we know the bounds of the input, we can substitute a constant operation and a floor on the input in base 60.  That number by the way is around 1358/1381, which is the maximum the input differs from the output in base 60. There may be a smaller constant, or at least a smaller way to represent it. For reference, the shortest constant you can multiply by, rather than divide, is 1.01694.


Convert from postfix notation to infix notation This question may not be that creative, but I believe that it is different enough to pose a new challenge.

The Challenge

Your challenge is to write the shortest program possible that can take any valid expression in Reverse Polish Notation and convert it to infix notation that obeys the order of operations and has the necessary parentheses.

Input

Your program will receive a valid RPN expression on STDIN. This expression will consist of numbers and operators. There can be an arbitrary number of spaces between each item, but there will always be a space between two numbers. Likewise, there will never be a space within a number. Here is a formal grammer description, stolen and modified from the linked question above.

expression := expression expression operator | number
operator   := "+" | "-" | "*" | "/" | "^"
number     := digit number | digit
digit      := "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"

Here are some simple examples

2 3 -10000 +
16 4    12 3 / * -
1 2 +2 3 +^

In the first example, that is not a negation sign, it is a subtraction operator.

Output

Your program should output an equivalent infix expression to STDOUT, which should be a valid infix expression, with numbers, operators, and parentheses.

Here is a formal grammer description, again stolen.

expression     := number | subexpression | expression operator expression
subexpression  := "(" expression ")"
operator       := "+" | "-" | "*" | "/"
number         := digit | digit number
digit          := "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"

With infix notation, there must be an order of operations and a way to group subexpressions. The order of operations will be this:

Expressions inside parentheses
Exponents right to left
Multiplication and division (of equal importance) left to right
Addition and subtraction (of equal importance) left to right

As an example, 2^3^2-(2^3)^2 should equal 448.

The output should not contain any unneeded parentheses. ((2+1))-1 should reduce to 2+1-1. Also, you should not evaluate any expression. You should also not assume the commutative or associative properties. This means that, while the operators will move around, the numbers will always remain in the same order.

Here are the outputs for the above inputs. Note that what would normally be unneeded parenthesis are in the second example: removing them would invoke the associative property.

2-3+10000
16-4*(12/3)
(1+2)^(2+3)

I will add more examples later.

Rules, Regulations, and Notes

This is code golf, standard rules apply.

Clojure - 282 279 271 268 characters

(dorun(map pr((reduce(fn[s v](let[p '{e 2,* 1,/ 1,+ 0,- 0}[t z](rseq s)a
#(if(and(seq? %)(<=(p v)(p(nth % 1))))%`(~%))](if(p v)(conj(pop(pop s))
`(~@(a z)~({'e(symbol"^")}v v)~@(a t)))(conj s v))))[](map read-string
(re-seq #"\d+|[e+*/-]"(.replace(read-line)\^\e))))0)))

(line breaks are totally optional, only included for clarity, if removed ensure there is a single space between a and #( between the first two lines. all other spaces between the lines may be removed).

Assumes input will end after the first line, passes the example programs (outputs more spaces sometimes, but the right number of parentheses :)

Program can be tested here: http://ideone.com/gxykA

Ungolfed:

(defn stackify [s v]
  (let[p '{e 4,* 3,/ 3,+ 2,- 2}
       [t n] (rseq s)
       a #(if (and (coll? %) (<= (p v) (p (nth % 1)))) % `(~%))]
    (if (p v)
      (conj (pop (pop s))
            `(~@(a n) ~({'e(symbol"^")} v v) ~@(a t)))
      (conj s v))))

(defn read-postfix [s]
  "takes a string instead of reading from *in*"
  (->> (.replace s \^ \e)
       (re-seq #"\d+|[e+*/-]")
       (map read-string)
       (reduce stackify [])
       first
       (map pr)
       dorun))

(woo, first stackexchange post)


Solve for N from input string Challenge :

Your job is to find the given number N.

Input :

You will be given a string in the following form:

dN ± Y = X

Where:

d, N, X, Y are all numbers with d , X , Y being integers (not decimals).

Output :

Solve the equation and output the value of N rounded. Round up if decimal is greater than or equal to 0.5 and round down if less than 0.5

Examples :

Input                  Output
 N + 1 = 3        ---> 2
 N - 1 = 5        ---> 6
2N + 1 = 3        ---> 1
2N + 1 = 4        ---> 2

Winning criteria :

This is code-golf so the shortest code in each language wins.

Notes :

Answer must be rounded it cannot be a float
Whitespace do not matter. You can have every element in the string separated by white space if you want or if you don't want leave it as it is.
You do not need to check for invalid input. i.e. All inputs will be strings in the given format.

Python 2, 88 74 70 bytes

-14 bytes thanks to Chas Brown.
-4 bytes thanks to Sunny Patel.

d,w,Y,_,X=input().split()
print round((int(X)-int(w+Y))/float(d[:-1]))

Try it online!


Implement the "Lazy Sort" I'm supposed to sort a list of numbers, but I'm super lazy. It's really hard to figure how to swap all the numbers around until all of them are in increasing order, so I came up with my own algorithm that will guarantee that the new list is sorted¹. Here's how it works:

For a list of size N, we'll need N-1 iterations. On each iteration,

Check if the N'th number is smaller than the N+1'th number. If it is, then these two numbers are already sorted, and we can skip this iteration.
If they are not, then you need to continually decrement the first N numbers until these two numbers are in order.

Let's take a concrete example. Let's say the input was

10 5 7 6 1

On the first iteration, we'll compare 10 and 5. 10 is larger than 5, so we decrement it until it's smaller:

4 5 7 6 1

Now we compare 5 and 7. 5 is smaller than 7, so we don't need to do anything on this iteration. So we go to the next and compare 7 and 6. 7 is larger than 6, so we decrement the first three numbers until it's smaller than 6, and we get this:

2 3 5 6 1

Now we compare 6 and 1. Again, 6 is larger than 1, so we decrement the first four numbers until it's smaller than 1, and we get this:

-4 -3 -1 0 1

And we're done! Now our list is in perfect sorted order. And, to make things even better, we only had to iterate through the list N-1 times, so this algorithm sorts lists in O(N-1) time, which I'm pretty sure is the fastest algorithm there is.²

Your challenge for today is to implement this Lazy Sort. Your program or function will be given an array of integers in whatever standard format you like, and you must perform this lazy sort and return the new "sorted" list. The array will never be empty or contain non-integers.

Here are some examples:

Input: 10 5 7 6 1
Output: -4 -3 -1 0 1

Input: 3 2 1
Output: -1 0 1

Input: 1 2 3
Output: 1 2 3

Input: 19
Output: 19

Input: 1 1 1 1 1 1 1 1 1
Output: -7 -6 -5 -4 -3 -2 -1 0 1

Input: 5 7 11 6 16 2 9 16 6 16
Output: -27 -25 -21 -20 -10 -9 -2 5 6 16

Input: -8 17 9 7
Output: -20 5 6 7

As always, this is code-golf, so write the shortest program you can!

¹ This doesn't mean what it sounds like it means, but it is technically true

² I am completely kidding, please don't hate me

Jelly,  14 12 11  9 bytes

-2 bytes thanks to ETHproductions (use the minimum dyad, «)

I’«0Ṛ+\Ṛ+

A monadic link taking and returning lists of integers.

Try it online! or see the test suite.

I really don't think this is Lazy™ enough!

How?

I’«0Ṛ+\Ṛ+ - Link: list of integers, a              e.g. [ 8, 3, 3, 4, 6, 2]
I         - increments between consecutive items of a   [-5, 0, 1, 2,-4 ]
 ’        - decrement (vectorises)                      [-6,-1, 0, 1,-5 ]
   0      - literal 0
  «       - minimum of decremented increments and zero  [-6,-1, 0, 0,-5 ]
    Ṛ     - reverse                                     [-5, 0, 0,-1,-6 ]
      \   - cumulative reduce with:
     +    -   addition                                  [-5,-5,-5,-6,-12]
       Ṛ  - reverse                                     [-12,-6,-5,-5,-5]
        + - addition (with a)                           [-4,-3,-2,-1, 1, 2]


If A-B be in A-B A else B eh? Given two integers, A and B, output A if A-B (A minus B) is in A-B (A to B), otherwise output B.
"A minus B" is standard subtraction.
"A to B" is the range of integers starting at A and ending at B, including both A and B. For example:
1 to 4: 1, 2, 3, 4
-2 to 5: -2, -1, 0, 1, 2, 3, 4, 5
3 to -1: 3, 2, 1, 0, -1
7 to 7: 7

The shortest code in bytes wins.
Test Cases
A B Output
1 4 4
-2 5 5
3 -1 -1
7 7 7
90 30 90
90 -30 -30
-90 30 30
-90 -30 -90
-2 -2 -2
-2 -1 -2
-2 0 -2
-2 1 1
-2 2 2
-1 -2 -2
-1 -1 -1
-1 0 -1
-1 1 1
-1 2 2
0 -2 -2
0 -1 -1
0 0 0
0 1 1
0 2 2
1 -2 -2
1 -1 -1
1 0 1
1 1 1
1 2 2
2 -2 -2
2 -1 -1
2 0 2
2 1 2
2 2 2

Original Chat-Mini-Challenge

Python, 27 bytes

lambda a,b:[a,b][2*b*b>a*b]

Try it online!

An arithmetic formula. Why is the negation of 2*b*b>a*b equivalent to the problem condition a-b in symrange(a,b)?

Note that x in symrange(a,b) is equivalent to 0 in symrange(a-x,b-x). Applying this to x=a-b gives 0 in symrange(b,2*b-a). The value 0 is included in the interval unless it stretches between two positive values or two negative values. This can be stated arithmetically as  "their product b*(2*b-a) is not positive.

Finally, take b*(2*b-a)<=0, and rewrite to 2*b*b<=a*b. A byte is saved by flipping <= to > and switching the cases.


Recamán's triangular fibonacci This challenge is based upon three sequences, below are their formulae:

Recamán's sequence:

a1 = 0; for n > 0, an = an-1 - n

if positive and not already in the sequence, otherwise

an = an-1 + n

Fibonacci sequence:

an = (Φn – (–Φ)–n) / √5

where Φ denotes the golden ratio, and

a1 = 0

Triangular numbers sequence:

a1 = 0; an = n * (n+1) / 2

Your task is to take specified nth terms of each sequence and perform certain basic mathematical operations on them, namely addition, subtraction, multiplication, division, and the support of parentheses, nothing more is required.
Input is always in infix notation, and output formats are unrestricted.
Your code must be able to handle all real numbers from -10,000,000 to +10,000,000
Standard loopholes apply, and built-in functions for these sequences are not allowed.
Examples:
(These examples use an example output format of 1R = 1st term of R, 3430T = 3430th term of T, and so on, however you are free to use whichever output format you desire.)
Examples:

(1R + 1F) * 3

= ( 0 + 0 ) * 3
= 0

(1R * 1F) - 3

= ( 0 * 0 ) - 3
= - 3

(1R + 2R) + (57R - 35R) / (51R - 41R) ) + (31F + 32F) - (54T)

= { [ (0 + 1) + (30 - 113) ] / (33 - 38) } + (832040 + 1346269) - (1431)
= { [ (0 + 1) + (-83) ] / (-5) } + (2178309) - (1431)
= [ (1 - 83 ) / (-5) ] + (2178309) - (1431)
= (-82 / -5) + (2178309) - (1431)
= (16.4) + (2178309) - (1431)
= 2176894.4


Give me some questions to answer! Introduction

Sometimes I get bored and there are no new questions on PPCG, so I want you to dig a random question from PPCG's past.

Challenge

Given a user's PPCG ID as input (e.g. my ID is 30525), output the URL of a randomly chosen PPCG question. If the question does not meet the following criteria, you must choose another question until it does meet the criteria:

The question asker must not be the user whose ID was inputted to the question
The question must not have already been answered by the  user whose ID was inputted to the question
The question must not be unanswered: it's probably too hard
The question must not have over 10 answers: it's probably too easy
The question must be tagged code-golf

Rules

URL shorteners are disallowed.

You may use the Stack Exchange API and the Stack Exchange Data Explorer.

You will only ever be given a real PPCG user's ID.

In the unlikely event that there are no suitable questions, you do not have to output anything (undefined behaviour is fine).

Side Challenge

Although you won't be awarded extra points, it would be appreciated if someone designed a usable bookmarklet which, when run, opened the browser window to a random PPCG question that follows the above criteria. The user ID should be hardcoded into program (for the bookmarklet only).

Challenge

The shortest code in bytes wins.

JavaScript (ES6), 333 329 327 323 283 bytes

Needs to be run from within the api.stackexchange.com domain (relevant meta). Returns a Promise containing the URL (relevant meta).

f=async i=>await(u="/questions/",s="?tagged=code-golf&site=codegolf",q=await(await(await fetch(u+s)).json()).items.filter(x=>x.owner.user_id!=i&x.answer_count<11).sort(_=>.5-Math.random())[0],await(await fetch(u+q.question_id+s)).json()).items.some(x=>x.owner.user_id==i)?f(i):q.link

Try it

f=async i=>await(u="//api.stackexchange.com/questions/",s="?tagged=code-golf&site=codegolf",q=await(await(await fetch(u+s)).json()).items.filter(x=>x.owner.user_id!=i&x.answer_count<11).sort(_=>.5-Math.random())[0],await(await fetch(u+q.question_id+s)).json()).items.some(x=>x.owner.user_id==i)?f(i):q.link
k.previousSibling.value=58974 // me
k.onclick=_=>f(+k.previousSibling.value).then(p=>k.nextSibling.innerText=p)
<input type=number><button id=k>Fetch</button><pre>

Bookmarklet

And here it is as a customisable bookmarklet, which will load a random question you've yet to answer. To use it, simply add a new bookmark to your browser's toolbar and drop the full code into the URL field.

Unlike the above solution, this works with all questions on a site therefore it may be slow to run (depending on the site and tags) and could also be expensive in the number of queries it needs to make to the API, as the API can only return 100 questions at a time.

To customise, change the following variables

k: Your API key - you can register for one here.
s: The Stack Exchange site you want to grab a question for.
i: Your user ID on that site.
t: The tags you want to filter by. There are 4 options available for this one:

"": An empty string; if you don't want to filter by any tags,
"code-golf;string": A semi-colon separated list of tags you want to filter by,
prompt("Tags:"): You will be prompted to enter the tags you want to filter by, or,
prompt("Tags:","code-golf;string"): You will be prompted to enter the tags you want to filter by, with a default list provided.

javascript:(f=(

/* See https://codegolf.stackexchange.com/a/122400/58974 for documenation */
k="",
s="codegolf",
i=58974,
t="code-golf",

p=1,q=[],r=1)=>fetch((u="//api.stackexchange.com/questions/")+(d=`?key=${k}&tagged=${t}&site=`+s)+`&page=${p}&pagesize=100`).then(r=>r.json()).then(j=>r&&(q=[...q,...j.items.filter(x=>x.owner.user_id!=i&(a=x.answer_count)&a<11)])^j.has_more?f(i,k,s,t,p+1,q,1):q.sort(_=>.5-Math.random())[0]).then(y=>fetch(u+y.question_id+"/answers"+d).then(r=>r.json()).then(j=>j.items.some(x=>x.owner.user_id==i)?f(i,k,s,t,q,0):window.location=y.link)))()


calculate the combinatorial Given two integers - n and r, your task is to calculate the combinatorial nCr.

nCr = n! / r! (n-r)!

The caveat is that you have to write code to do this calculation in minimum number of characters.

Input
The first line will be number of testcases T. Then T lines follow, each containing two positive integers - n and r.

output
Print T lines, each line containing the value of nCr.

Constraints

1 <= T <= 100
1 <= r <= n <= 1000

You can assume that the value nCr will fit into a signed 64 bit integer.

Golfscript, 31 characters
n%(;{~.@.@-]{1\,{)*}/}%~/\/}%n*

Explanation:

n/(;{...}%n* splits the input by a newline, discards the first row (number of testcases), maps the rest and finally joins by a newline.

~.@.@- evals the input, rearranges it to r n n r, then subtracts r from n.
]{...}%~ collects everything on the stack into and array, maps it and explodes the array

1\,{)*}/ is the factorial function: push a 1 below the number, then create an array 0...n, then for each element, multiply the accumulator by the value + 1. The map-reduce implementation is one char longer: ,{)}%{*}*

/\/ divides n! first by factorial of the difference, then by r!.


Little Endian Number to String Conversion Introduction

During work with BMP (bitmap) generator I face problem of converting number to little endian hex string. Here is function which I create in JavaScript - but wonder how small code can works similarly

let liEnd= num => num.toString(16).padStart(8,'0').match(/../g).reverse().join``;
console.log(liEnd(304767)) // 304767 dec = 0x4a67f hex

Challenge

Write function which will take 32bit unsigned integer number on input, and produce 8-digit hexadecimal string with little endian order. The example algorithm which do the job:

convert numb to hex string e.g: 304767 -> '4a67f'
add padding zeros to get 8-char string: '0004a67f'
split string to four 2-char pieces: '00','04','a6','7f'
reverse order of pieces '7f','a6','04','00'
join pieces and return as result: '7fa60400'

Example Input and Output

Input number (or string with dec number) is on the left of ->, output hex string is on the right

2141586432 -> 0004a67f
304767     -> 7fa60400

05AB1E, 10 9 bytes

žJ+h¦2ôRJ

Try it online!

-1 byte by inspiration of the Jelly answer.

žJ+   add 2^32 to input
h     convert to hex
¦     drop leading 1
2ô    split in groups of 2
R     reverse groups
J     and join them


Greatest common substring Create a program or function which takes a list of strings as input, and outputs the longest string that is a substring of all input strings. If there are several substrings of equal length, and no longer substring, output any one of them.

This may mean outputting the empty string.
If there are several valid outputs, you may output any one of them. You are not required to give consistent output for a given input so long as the output is always valid.
There will always be at least one string in the input, but there might not be a non-empty string.
All printable ASCII characters may appear in the input. You may assume those are the only characters that appear.
You may take input or produce output by any of the default methods.
Standard loopholes aren't allowed.
This is code-golf - the fewer bytes of code, the better.

Test cases:
[Inputs] -> [Valid outputs (choose one)]
["hello", "'ello"] -> ["ello"]
["very", "much", "different"] -> [""]
["empty", "", "STRING"] -> [""]
["identical", "identical"] -> ["identical"]
["string", "stRIng"] -> ["st", "ng"]
["this one", "is a substring of this one"] -> ["this one"]
["just one"] -> ["just one"]
["", "", ""] -> [""]
["many outputs", "stuptuo ynam"] -> ["m", "a", "n", "y", " ", "o", "u", "t", "p", "s"]
["many inputs", "any inputs", "ny iii", "yanny"] -> ["ny"]
["%%not&", "ju&#st", "[&]alpha_numeric"] -> ["&"]

Brachylog (v2), 3 9 bytes

{sᵛ}ᶠlᵒtw

Try it online!

Full program. Input from standard input (as a JSON-style list of strings), output to standard output.

Explanation

{sᵛ}ᶠlᵒtw
 s         Find a substring
  ᵛ          of every element {of the input}; the same one for each
{  }ᶠ      Convert generator to list
     lᵒt   Take list element with maximum length
        w  Output it

Apparently, the tiebreak order on s is not what it is in nearly everything else in Brachylog, so we need to manually override it to produce the longest output. (That's a bit frustrating: four extra characters for the override, plus two grouping characters because Brachylog doesn't parse two metapredicates in a row.)

Brachylog's s doesn't return empty substrings, so we need a bit of a trick to get around that: instead of making a function submission (which is what's normally done), we write a full program, outputting to standard output. That way, if there's a common substring, we just output it, and we're done. If there isn't a common substring, the program errors out – but it still prints nothing to standard output, thus it outputs the null string as intended.


Find a divisibility pattern Background
Sometimes when I'm golfing a program, I'm presented with the following situation: I have an integer value \$x\$ on some fixed interval \$[a, b]\$, and I'd like to test whether it's in some fixed subset \$S \subset [a, b]\$ with as few bytes as possible.
One trick that sometimes works in a language where nonzero integers are truthy is finding small integers \$n\$ and \$k\$ such that \$x \in S\$ holds precisely when \$x + k\$ doesn't divide \$n\$, because then my test can be just n%(x+k).
In this challenge your task is to compute the minimal \$n\$ and \$k\$ from the fixed data.
The task
Your inputs are a number \$b\$ and a set \$S\$ of integers between \$1\$ and \$b\$ inclusive (we assume \$a = 1\$ for simplicity), in any reasonable format.
You may take the complement of \$S\$ if you want.
If you take \$S\$ as a list, you can assume it's sorted and duplicate-free.
You can also assume \$b\$ is at most the number of bits in an integer and take \$S\$ as a bitmask if you want.
Your output is the lexicographically smallest pair of integers \$(n,k)\$ with \$n \geq 1\$ and \$k \geq 0\$ such that for each \$1 \leq x \leq b\$, \$k+x\$ divides \$n\$ if and only if \$x\$ is not an element of \$S\$.
This means that \$n\$ should be minimal, and then \$k\$ should be minimal for that \$n\$.
Output format is also flexible.
Note that you only have to consider \$k \leq n\$, because no \$k+x\$ can divide \$n\$ when \$k \geq n\$.
The lowest byte count in each language wins.
Example
Suppose the inputs are \$b = 4\$ and \$S = [1,2,4]\$.
Let's try \$n = 5\$ (assuming all lower values have been ruled out).

The choice \$k=0\$ doesn't work because \$k+1 = 1\$ divides \$5\$ but \$1 \in S\$.
The choice \$k=1\$ doesn't work because \$k+3 = 4\$ does not divide \$5\$ but \$3 \notin S\$.
The choice \$k=2\$ works: \$k+1 = 3\$, \$k+2 = 4\$ and \$k+4 = 6\$ don't divide \$5\$, and \$k+3 = 5\$ divides \$5\$.

Test cases
b S -> n k
1 [] -> 1 0
1 [1] -> 1 1
2 [] -> 2 0
2 [1] -> 3 1
2 [2] -> 1 0
2 [1,2] -> 1 1
4 [1,2,4] -> 5 2
4 [1,3,4] -> 3 1
5 [1,5] -> 168 4
5 [2,5] -> 20 1
5 [3,4] -> 6 1
5 [2,3,4,5] -> 1 0
6 [1] -> 3960 6
8 [2,3,6,7] -> 616 3
8 [1,3,5,7,8] -> 105 1
8 [1,2,3,4,5] -> 5814 11
9 [2,3,5,7] -> 420 6
14 [3,4,6,7,8,9,10,12,13,14] -> 72 7

05AB1E, 21 20 19 18 bytes
Thanks to Kevin Cruijssen for -1 byte!
-1 byte inspired by xash's Brachylog answer!
[¼¾ƒ²L¾ÑN-K¹Qi¾N‚q

Try it online!
or
Try most test cases! (based on the test-suite by FryAmTheEggman for this answer.)
            # see below for the remainder of the code
²L          # push [1 .. b]
  ¾Ñ        # push the divisors of n
    N-      # subtract k from each
            # this is now a list of all x in [-k+1 .. n-k] with n%(x+k)==0
      K     # remove this from [1 .. b]
       ¹Q   # is this equal to S?

05AB1E, 24 23 bytes
First line of input is the set \$S\$, second one \$b\$.
[¼¾ƒ¾¹²L‚N+Ö_O¹gªËi¾N‚q

Try it online!
This iterates through all possible pairs in lexicographical order and checks for each pair:
\begin{align*}
\left|S\right| &=\left|\left\{ x \in [1 .. b] \mid x \;\text{does not divide}\; n  \right\}\right| \\&= \left|\left\{ x \in S \mid x \;\text{does not divide}\; n  \right\}\right|
\end{align*}
Commented:
[                # infinite loop
 ¼¾              # increment and push the counter (n)
   ƒ             # for N(=k) in [0 .. n]:
¾                #   push n
 ¹               #   push the first input (S)
  ²L             #   push [1 .. second input (b)]
    ‚            #   pair these two lists up
     N+          #   add current k to both lists
       Ö_        #   do they not divide n (vectorizes)
         O       #   sum both lists
          ¹g     #   push the length of S
            ª    #   append this to the list
             Ë   #   are all equal?
i                #   if this is true:
 ¾               #     push n
  N              #     push k
   ‚             #     pair n and k
    q            #     quit the program (implicit output)


Print a Variable's Name Write a function (not a full program), so that if the function is called with a single global variable (or your language's closest equivalent) as its argument, it outputs (i.e. prints or returns) the name of that variable. If the argument is not a variable, output a falsey value instead. (You don't have to handle the case where the argument is a variable, but not global.)

There must not be a compile-time connection between the function call and function definition (notably, the function definition cannot be a macro or similar construct that receives arguments in the form of a literal fragment of source code, neither in text nor abstract syntax tree form). That is: in languages which support separate compilation, the program must work even if the function call is compiled first (with no knowledge of the function definition but possibly a type signature or equivalent), then the function definition is compiled afterwards. If the language doesn't have separate compilation, you must nonetheless aim for a similar separation between the call and definition.

If using a compiled language, you may read the compiled form of the complete program from disk, and may assume that the program was compiled with debug information. (Thus, solutions that work by attaching a debugger from a program to itself are allowed.)

Note that this task may not be possible in every language.

Examples:

var apple = "Hello"
p(apple) // apple

var nil = "Nothing"
p(nil) // nil

var SOMETHING = 69
p(SOMETHING) // SOMETHING

function foo(){}
p(foo) // foo

p(3.14159) // false

p(function foo(){}) // false

Java

String getParamName(String param) throws Exception {
    StackTraceElement[] strace = new Exception().getStackTrace();
    String methodName = strace[0].getMethodName();
    int lineNum = strace[1].getLineNumber();

    String className = strace[1].getClassName().replaceAll(".{5}$", "");
    String classPath = Class.forName(className).getProtectionDomain().getCodeSource().getLocation().getPath() + className + ".class";

    StringWriter javapOut = new StringWriter();
    com.sun.tools.javap.Main.run(new String[] {"-l", "-c", classPath}, new PrintWriter(javapOut));
    List<String> javapLines = Arrays.asList(javapOut.toString().split("\\r?\\n"));
    int byteCodeStart = -1;
    Map<Integer, Integer> byteCodePointerToJavaPLine = new HashMap<Integer, Integer>();
    Pattern byteCodeIndexPattern = Pattern.compile("^\\s*(\\d+): ");
    for (int n = 0;n < javapLines.size();n++) {
        String javapLine = javapLines.get(n);
        if (byteCodeStart > -1 && (javapLine == null || "".equals(javapLine))) {
            break;
        }
        Matcher byteCodeIndexMatcher = byteCodeIndexPattern.matcher(javapLine);
        if (byteCodeIndexMatcher.find()) {
            byteCodePointerToJavaPLine.put(Integer.parseInt(byteCodeIndexMatcher.group(1)), n);
        } else if (javapLine.contains("line " + lineNum + ":")) {
            byteCodeStart = Integer.parseInt(javapLine.substring(javapLine.indexOf(": ") + 2));
        }
    }

    int varLoadIndex = -1;
    int varTableIndex = -1;
    for (int i = byteCodePointerToJavaPLine.get(byteCodeStart) + 1;i < javapLines.size();i++) {
        if (varLoadIndex < 0 && javapLines.get(i).contains("Method " + methodName + ":")) {
            varLoadIndex = i;
            continue;
        }

        if (varLoadIndex > -1 && javapLines.get(i).contains("LocalVariableTable:")) {
            varTableIndex = i;
            break;
        }
    }

    String loadLine = javapLines.get(varLoadIndex - 1).trim();
    int varNumber;
    try {
        varNumber = Integer.parseInt(loadLine.substring(loadLine.indexOf("aload") + 6).trim());
    } catch (NumberFormatException e) {
        return null;
    }
    int j = varTableIndex + 2;
    while(!"".equals(javapLines.get(j))) {
        Matcher varName = Pattern.compile("\\s*" + varNumber + "\\s*([a-zA-Z_][a-zA-Z0-9_]*)").matcher(javapLines.get(j));
        if (varName.find()) {
            return varName.group(1);
        }
        j++;
    }
    return null;
}

This currently works with a few gotchas:

If you use an IDE to compile this it might not work unless it is run as Admin (depending on where the temporary class files are saved)
You must compile using javac with the -g flag. This generates all debugging information including local variable names in the compiled class file.
This uses an internal Java API com.sun.tools.javap which parses the bytecode of a classfile and produces a human readable result. This API is only accessible in the JDK libraries so you must either use the JDK java runtime or add tools.jar to your classpath.

This should now work even if the method is called multiple times in the program. Unfortunately it does not yet work if you have multiple invocations on a single line. (For one that does, see below)

Try it online!

Explanation

StackTraceElement[] strace = new Exception().getStackTrace();
String methodName = strace[0].getMethodName();
int lineNum = strace[1].getLineNumber();

String className = strace[1].getClassName().replaceAll(".{5}$", "");
String classPath = Class.forName(className).getProtectionDomain().getCodeSource().getLocation().getPath() + className + ".class";

This first part gets some general information about what class we're in and what the name of the function is. This is accomplished by creating an exception and parsing the first 2 entries of the stack trace.

java.lang.Exception
    at E.getParamName(E.java:28)
    at E.main(E.java:17)

The first entry is the line that the exception is thrown on which we can grab the methodName from and the second entry is where the function was called from.

StringWriter javapOut = new StringWriter();
com.sun.tools.javap.Main.run(new String[] {"-l", "-c", classPath}, new PrintWriter(javapOut));

In this line we are executing the javap executable that comes with the JDK. This program parses the class file (bytecode) and presents a human-readable result. We'll use this for rudimentary "parsing".

List<String> javapLines = Arrays.asList(javapOut.toString().split("\\r?\\n"));
int byteCodeStart = -1;
Map<Integer, Integer> byteCodePointerToJavaPLine = new HashMap<Integer, Integer>();
Pattern byteCodeIndexPattern = Pattern.compile("^\\s*(\\d+): ");
for (int n = 0;n < javapLines.size();n++) {
    String javapLine = javapLines.get(n);
    if (byteCodeStart > -1 && (javapLine == null || "".equals(javapLine))) {
        break;
    }
    Matcher byteCodeIndexMatcher = byteCodeIndexPattern.matcher(javapLine);
    if (byteCodeIndexMatcher.find()) {
        byteCodePointerToJavaPLine.put(Integer.parseInt(byteCodeIndexMatcher.group(1)), n);
    } else if (javapLine.contains("line " + lineNum + ":")) {
        byteCodeStart = Integer.parseInt(javapLine.substring(javapLine.indexOf(": ") + 2));
    }
}

We're doing a couple different things here. First, we are reading the javap output line by line into a list. Second we are creating a map of bytecode line indexes to javap line indexes. This helps us later to determine which method invocation we want to analyze. Finally we are using the known line number from the stack trace to determine which bytecode line index we want to be looking at.

int varLoadIndex = -1;
int varTableIndex = -1;
for (int i = byteCodePointerToJavaPLine.get(byteCodeStart) + 1;i < javapLines.size();i++) {
    if (varLoadIndex < 0 && javapLines.get(i).contains("Method " + methodName + ":")) {
        varLoadIndex = i;
        continue;
    }

    if (varLoadIndex > -1 && javapLines.get(i).contains("LocalVariableTable:")) {
        varTableIndex = i;
        break;
    }
}

Here we are iterating over the javap lines one more time in order to find the spot where our method is being invoked and where the Local Variable Table starts. We need the line where the method is invoked because the line before it contains the call to load the variable and identifies which variable (by index) to load. The Local Variable Table helps us actually look up the name of the variable based on the index we grabbed.

String loadLine = javapLines.get(varLoadIndex - 1).trim();
int varNumber;
try {
    varNumber = Integer.parseInt(loadLine.substring(loadLine.indexOf("aload") + 6).trim());
} catch (NumberFormatException e) {
    return null;
}

This part is actually parsing the load call to get the variable index. This can throw an exception if the function isn't actually called with a variable so we can return null here.

int j = varTableIndex + 2;
while(!"".equals(javapLines.get(j))) {
    Matcher varName = Pattern.compile("\\s*" + varNumber + "\\s*([a-zA-Z_][a-zA-Z0-9_]*)").matcher(javapLines.get(j));
    if (varName.find()) {
        return varName.group(1);
    }
    j++;
}
return null;

Finally we parse out the name of the variable from the line in the Local Variable Table. Return null if it isn't found although I've seen no reason why this should happen.

Putting it all together

 public static void main(java.lang.String[]);
    Code:
...
      18: getstatic     #19                 // Field java/lang/System.out:Ljava/io/PrintStream;
      21: aload_1
      22: aload_2
      23: invokevirtual #25                 // Method getParamName:(Ljava/lang/String;)Ljava/lang/String;
...
    LineNumberTable:
...
      line 17: 18
      line 18: 29
      line 19: 40
...
    LocalVariableTable:
      Start  Length  Slot  Name   Signature
          0      83     0  args   [Ljava/lang/String;
          8      75     1     e   LE;
         11      72     2   str   Ljava/lang/String;
         14      69     3  str2   Ljava/lang/String;
         18      65     4  str4   Ljava/lang/String;
         77       5     5    e1   Ljava/lang/Exception;

This is basically what we're looking at. In the example code the first invocation is line 17. line 17 in the LineNumberTable shows that the beginning of that line is bytecode line index 18. That is the System.out load. Then we have aload_2 right before the method call so we look for the variable in slot 2 of the LocalVariableTable which is str in this case.

For fun, here's one which handles multiple function calls on the same line. This causes the function to not be idempotent but that's kind of the point. Try it online!