Create a programming language that only appears to be unusable Robbers' challenge thread is here.

Cops' challenge: Design a programming language that appears to be unusable for programming, but admits computation (or at least completion of the task) through some non-obvious mechanism.

You should design a simple programming language that reads code from an input file and then does ... something. You must prepare a solution program that finds the 3rd-largest number in the input when run in your interpreter. You need to make it as hard as possible for robbers to find a solution program. Note that robbers can post any solution that accomplishes the task, not just the one you had in mind.

This is a popularity contest. The cops' goal is to get as many votes as possible while surviving 8 days after posting the interpreter without being cracked. To this end, the following practices should help:

Accurately explaining your language's semantics
Writing readable code

The following tactics are strongly discouraged:

Using encryption, hashes, or other cryptographic methods. If you see a language that employs RSA encryption, or refuses to execute a program unless its SHA-3 hash is equal to 0x1936206392306, please do not hesitate to downvote.

Robbers' challenge: Write a program that finds the third-largest integer in the input when run in the cops' interpreter.

This one is relatively straightforward. In order to crack a cop answer, you must create a program that completes the task when run in its interpreter. When you crack an answer, post a comment saying "Cracked" on the cop's answer linking to your post. Whoever cracks the most cops wins the robbers' thread.

I/O Rules

Interpreters should take a filename on the command line for the program, and use standard input and output when running it.
Input will be given in unary and consist only of the characters 0 and 1 (48 and 49 in ASCII). A number N is encoded as N 1s followed by a 0. There is an additional 0 before end of file. Example: For the sequence (3, 3, 1, 14), the input is 11101110101111111111111100.
Input is guaranteed to have at least 3 numbers. All numbers are positive integers.
Output will be judged by the number of 1s printed before the program halts. Other characters are ignored.

In the following examples, the first line is the input in decimal format; the second is the actual program input; the third is a sample output.

1, 1, 3
101011100
1

15, 18, 7, 2, 15, 12, 3, 1, 7, 17, 2, 13, 6, 8, 17, 7, 15, 11, 17, 2
111111111111111011111111111111111101111111011011111111111111101111111111110111010111111101111111111111111101101111111111111011111101111111101111111111111111101111111011111111111111101111111111101111111111111111101100
111111,ir23j11111111111u

247, 367, 863, 773, 808, 614, 2
<omitted>
<contains 773 1's>

Boring rules for cop answers:

To prevent security through obscurity, the interpreter should be written in a language in the top 100 of this TIOBE index and have a freely available compiler/interpreter.
The interpreter must not interpret a language which was published before this challenge.
Interpreter should fit into your post and not be hosted externally.
Interpreter should be deterministic
Interpreter should be portable and follow the standard of its own language; don't use undefined behavior or bugs
If the solution program is too long to fit into the answer, you must post a program that generates it.
Solution program should consist only of printable ASCII and newlines.
You must execute your solution program in less than 1 hour on your own computer for each of the example inputs above.
The program should work for any integers less than 106, and any number of integers less than 106 (not necessarily in under an hour), provided that the total input length is less than 109.
To become safe, a cop must edit the solution program into the answer after 8 days have passed.

Scoring

The cop who becomes safe with the highest score, and a positive score, wins this question.

Shuffle (written in C++), Cracked! by Martin

Edit Martin cracked it. To see his solution, click the link. My solution has also been added.

Edit Fixed print-d command to be able to handle both registers and stacks. As this is a debugging command which is not permitted in a solution, this should not affect anyone using the previous version of the interpreter

I'm still new to this, so if there is something wrong with my answer or my interpreter, please let me know. Please ask for clarification if something is not clear.

I don't imagine that this will be too terribly difficult, but hopefully it will provide some sort of challenge. What makes shuffle fairly unusable is that it will only print when things are in their proper place.

-->Basics:

There are 24 Stacks, we call them stack1, ... stack24. These stacks live in a list. At the beginning of any program, these stacks have zero pushed and they start in their proper place, i.e. stacki in the ith position in the list (Note that we will index beginning from 1, unlike C++). During a course of a program, the order of the stacks within the list will shift. This is important for reasons that will be explained when I discuss the commands.

There are 5 registers available for use. They are named Alberto, Gertrude, Hans, Leopold, ShabbySam. Each of these is set to zero at the beginning of a program.

So, at the onset of any program, there are 24 stacks, each has its number matching its index in the stack list. Every stack has exactly one zero on top. Each of the five registers is initialized to zero.

-->Commands and Syntax:

There are 13 commands (+1 debugging command) that are available in Shuffle. They are as follows

cinpush this command takes no arguments. It waits for command line input in the fashion described in the question (other input will lead to unspecified/undefined results). It then splits the input string into integers, e.g. 101011100 --> 1,1,3. For each input received, it does the following: (1) permutes the list of stacks based on the value. Let the integer value in question be called a. If a is less than 10 it does permutation u. If a is between 9 and 30 (noninclusive) it does permutation d. Otherwise it does permutation r. (2) It then pushes a onto the the stack which is first in the list. Note that I do not mean stack1 (although it may be the case that stack1 is first in the list). The permutations are defined below.  Since cinpush is the only way to get user input, it must appear in any solution.
mov value register The mov command is basically variable assignment. It assigns value to register. value can take several forms: it can be (1) an integer, e.g. 47 (2) the name of a different register, e.g. Hans (3) the index of a stack followed by 's', e.g. 4s. Note that this is the index in the list, not the number of the stack. As such, the number should not exceed 24.

Some mov examples:

mov 4s Hans
mov Hans ShabbySam
mov 9999 Gertrude

movfs index register This stands for 'move from stack'. It is similar to the mov command. It exists so that you may access a stack indexed by a register. For example, if earlier you set Hans equal to 4 ( mov 4 Hans) Then you may use movfs Hans Gertrude to set Gertrude equal to the top of stack 4. This type of behavior is not accessible simply using mov.
inc register increases register value by 1.
dec register decreases register value by 1.
compg value value register This stands for 'compare greater'. It sets the register equal to the greater of the two values. value can be an integer, a register, or a stack index followed by 's', as above.
compl value value register 'compare lesser' same as above, except takes the smaller value.
gte value1 value2 register Checks if value1 >= value2 then puts the Boolean value (as 1 or 0 ) into register.
POP!! index pops off the top of the stack indexed by index in the stack list.
jmp label jumps unconditionally to the label label. This is a good time to talk about labels. A label is word followed by ':'. The interpreter pre-parses for labels, so you are able to jump forward to labels as well as back.
jz value label jumps to label if value is zero.
jnz value label jumps to label if value is nonzero.

Examples of labels and jumping:

this_is_my_label:
     jmp this_is_my_label

mov 10 Hans
jnz Hans infinite_loop

infinite_loop:
     jmp infinite_loop

"shuffle" permutation Here is the shuffle command. This allows you to permute the list of stacks. There are three valid permutations that can be used as arguments, l, f, and b.
print register This checks if all the stacks are in their initial positions, i.e stacki is at index i in the stack list. If this is the case, it prints the value at register in unary. Otherwise, it prints a nasty error. As you can see, to output anything, the stacks must all be in the correct places.
done! this tells the program to quit with no error. If the program ends without done!, it will print to the console the number on top of each stack followed by the stack's number. The order that the stacks are printed is the order they appear in the stack list. If a stack is empty, it will be omitted. This behavior is for debugging purposes and may not be used in a solution.
print-d value this prints the value of the stack, register, or integer given (to access stack i, pass is as argument, as explained above). This is a debugging tool and not part of the language, as such it is not permitted in an solution.

--> Here is the interpreter code

All the parsing happens in the main function. This is where you will find it parsing for specific commands.

#include<fstream>
#include<iostream>
#include<string>
#include<stack>
#include<cmath>

using namespace std;

class superStack: public stack<long> {
    private:
        int m_place;
    public:
        static int s_index;

        superStack() {
            m_place = s_index;
            s_index++;
        }

        int place() {
            return m_place;
        }
};
int superStack::s_index=1;

superStack  stack1,stack2,stack3,stack4,stack5,stack6,stack7,stack8,stack9,stack10,stack11, \
            stack12,stack13,stack14,stack15,stack16,stack17,stack18,stack19,stack20,stack21,stack22,stack23,stack24;

superStack* stackptrs[]=    { \
                        &stack1,&stack2,&stack3,&stack4,&stack5,&stack6,&stack7,&stack8,&stack9,&stack10,&stack11, \
                        &stack12,&stack13,&stack14,&stack15,&stack16,&stack17,&stack18,&stack19,&stack20,&stack21,&stack22,&stack23,&stack24 \
                        };

long Gertrude=0;
long Hans=0;
long Alberto=0;
long ShabbySam=0;
long Leopold=0;

void SWAP( int i, int j) {    // 0 < i,j < 25

    i--;
    j--;

    superStack* tempptr = stackptrs[i];
    stackptrs[i]=stackptrs[j];
    stackptrs[j] = tempptr;

}

void u() {
    int list[3][4] = {
                        {1,9,6,13},
                        {2,10,5,14},
                        {17,19,20,18},
                    };

    for(int i=0;i<3;i++) {
        for(int j=1;j<4;j++) {
            SWAP( list[i][0], list[i][j] );
        }
    }
}
void d() {
    int list[3][4] = {
                        {3,11,8,15},
                        {4,12,7,16},
                        {22,24,23,21},
                    };

    for(int i=0;i<3;i++) {
        for(int j=1;j<4;j++) {
            SWAP( list[i][0], list[i][j] );
        }
    }
}
void r() {
    int list[3][4] = {
                        {2,17,8,24},
                        {4,18,6,23},
                        {9,10,12,11},
                    };

    for(int i=0;i<3;i++) {
        for(int j=1;j<4;j++) {
            SWAP( list[i][0], list[i][j] );
        }
    }
}
void l() {
    int list[3][4] = {
                        {1,19,7,22},
                        {3,20,5,21},
                        {14,13,15,16},
                    };

    for(int i=0;i<3;i++) {
        for(int j=1;j<4;j++) {
            SWAP( list[i][0], list[i][j] );
        }
    }
}
void f() {
    int list[3][4] = {
                        {20,9,24,16},
                        {18,11,22,14},
                        {1,2,4,3},
                    };

    for(int i=0;i<3;i++) {
        for(int j=1;j<4;j++) {
            SWAP( list[i][0], list[i][j] );
        }
    }
}
void b() {
    int list[3][4] = {
                        {19,10,23,15},
                        {17,12,21,13},
                        {5,6,8,7},
                    };

    for(int i=0;i<3;i++) {
        for(int j=1;j<4;j++) {
            SWAP( list[i][0], list[i][j] );
        }
    }
}

void splitpush(string input) {
    long value=0;

    for(long i=0;i<input.size();i++) {

        if(input[i]=='1'){
            value++;
        }
        else if(input[i]=='0' && value!=0 ) {
            if(value<10) {
                u();
            }
            else if (value<30) {
                d();

            }
            else {
                r();
            }
            (*stackptrs[0]).push(value);
            value=0;

        }
        else {
            break;
        }

    }

}

long strToInt(string str) { // IF STRING HAS NON DIGITS, YOU WILL GET GARBAGE, BUT NO ERROR
    long j=str.size()-1;
    long value = 0;
    for(long i=0;i<str.size();i++) {
        long x = str[i]-48;

        value+=x*floor( pow(10,j) );
        j--;
    }
    return value;
}

bool isEmpty(superStack stk) {
    if( stk.size()>0){return false; }
    else {return true;}

}

long getValue(string str) {
    if(str=="ShabbySam") {
        return ShabbySam;
    }
    else if(str=="Hans") {
        return Hans;
    }
    else if(str=="Gertrude") {
        return Gertrude;
    }
    else if(str=="Alberto") {
        return Alberto;
    }
    else if(str=="Leopold") {
        return Leopold;
    }
    else if(str[ str.size()-1 ]=='s'){
        str.pop_back();

        long index = strToInt(str)-1;

        if( !isEmpty( (*stackptrs[index]) ) ) {
            return (*stackptrs[index]).top();
        }
        else {
            cerr<<"Bad Expression or Empty Stack";

        }
    }
    else {
        return strToInt(str);
    }

}

void printUnary(long i) {
    while(i>0) {
        cout<<1;
        i--;
    }
}

int main(int argc, char**argv) {

    if(argc<2){std::cerr<<"No input file given"; return 1;}
    ifstream inf(argv[1]);
    if(!inf){std::cerr<<"File open failed";return 1;}

    for(int i=0;i<24;i++) {
        (*stackptrs[i]).push(0);         // Pre push a zero on every stack
    }

    string labels[20];
    unsigned labelPoints[20];
    int index=0;

    string str;
    while(inf) { //  parse for labels
        inf>>str;
        //cout<<inf.tellg()<<" ";
        if(inf) {
            if(str[str.size()-1]==':') {
                str.pop_back();
                bool alreadyExists = false;
                for(int i=0; i<index;i++){
                    if(labels[i] == str ) { alreadyExists=true;}
                }
                if(!alreadyExists) {
                    labels[index]=str;
                    labelPoints[index]= inf.tellg();
                    index++;
                }
            }

        }

    }
    inf.clear();
    inf.seekg(0,inf.beg);

    while(inf) { // parse for other commands
        inf>>str;

        if(inf) {

            if(str=="cinpush") {
                string input;
                cin>>input;
                splitpush(input);
            }

            else if(str=="mov") {
                inf>>str;
                long value = getValue(str);

                inf>>str;
                if(str=="Gertrude"){Gertrude=value;}
                else if(str=="Hans"){Hans=value;}
                else if(str=="ShabbySam"){ShabbySam=value;}
                else if(str=="Alberto"){Alberto=value;}
                else if(str=="Leopold"){Leopold=value;}
                else {cerr<<"Bad register name. ";}

            }

            else if(str=="movfs") {
                inf>>str;
                long index = getValue(str);
                if(!isEmpty( *stackptrs[index-1] )) {
                    inf>>str;
                    long value = (*stackptrs[index-1]).top();
                    if(str=="Gertrude"){Gertrude=value;}
                    else if(str=="Hans"){Hans=value;}
                    else if(str=="ShabbySam"){ShabbySam=value;}
                    else if(str=="Alberto"){Alberto=value;}
                    else if(str=="Leopold"){Leopold=value;}
                    else {cerr<<"Bad register name.";}
                }
                else {
                    cerr<<"Empty Stack";
                }

            }

            else if(str=="inc") {
                inf>>str;
                if(str=="Gertrude"){Gertrude++;}
                else if(str=="Hans"){Hans++;}
                else if(str=="ShabbySam"){ShabbySam++;}
                else if(str=="Alberto"){Alberto++;}
                else if(str=="Leopold"){Leopold++;}
                else {cerr<<"Bad register name. ";}
            }
            else if(str=="dec") {
                inf>>str;
                if(str=="Gertrude"){Gertrude--;}
                else if(str=="Hans"){Hans--;}
                else if(str=="ShabbySam"){ShabbySam--;}
                else if(str=="Alberto"){Alberto--;}
                else if(str=="Leopold"){Leopold--;}
                else {cerr<<"Bad register name. ";}
            }

            else if(str=="compg") {
                inf>>str;
                long value1 = getValue(str);
                inf>>str;
                long value2 = getValue(str);
                inf>>str;
                long larger;
                if(value1>value2){larger = value1;}
                else {larger = value2;}

                if(str=="Gertrude"){Gertrude=larger;}
                else if(str=="Hans"){Hans=larger;}
                else if(str=="ShabbySam"){ShabbySam=larger;}
                else if(str=="Alberto"){Alberto=larger;}
                else if(str=="Leopold"){Leopold=larger;}
                else {cerr<<"Bad register name. ";}

            }
            else if(str=="compl") {
                inf>>str;
                long value1 = getValue(str);
                inf>>str;
                long value2 = getValue(str);
                inf>>str;
                long larger; //LARGER IS REALLY SMALLER HERE
                if(value1>value2){larger = value2;}
                else {larger = value1;}

                if(str=="Gertrude"){Gertrude=larger;}
                else if(str=="Hans"){Hans=larger;}
                else if(str=="ShabbySam"){ShabbySam=larger;}
                else if(str=="Alberto"){Alberto=larger;}
                else if(str=="Leopold"){Leopold=larger;}
                else {cerr<<"Bad register name. ";}

            }

            else if(str=="gte") {
                inf>>str;
                long value1= getValue(str);
                inf>>str;
                long value2= getValue(str);
                inf>>str;
                bool torf = value1 >= value2;

                if(str=="Gertrude"){Gertrude=torf;}
                else if(str=="Hans"){Hans=torf;}
                else if(str=="ShabbySam"){ShabbySam=torf;}
                else if(str=="Alberto"){Alberto=torf;}
                else if(str=="Leopold"){Leopold=torf;}
                else {cerr<<"Bad register name. ";}

            }

            else if(str=="lte") {
                inf>>str;
                long value1= getValue(str);
                inf>>str;
                long value2= getValue(str);
                inf>>str;
                bool torf = value1 <= value2;

                if(str=="Gertrude"){Gertrude=torf;}
                else if(str=="Hans"){Hans=torf;}
                else if(str=="ShabbySam"){ShabbySam=torf;}
                else if(str=="Alberto"){Alberto=torf;}
                else if(str=="Leopold"){Leopold=torf;}
                else {cerr<<"Bad register name. ";}

            }

            else if(str=="POP!!") {
                inf>>str;
                long index = getValue(str);
                index--; //because we (C++ and this interpreter) index differently
                if(!isEmpty( *stackptrs[index] )) {
                    (*stackptrs[index]).pop();
                }
                else {cerr<<"Can't POP!! from empty stack";}

            }

            else if(str=="push"){cerr<<" You can't. ";}

            /*
            else if(str[str.size()-1]==':') {
                str.pop_back();
                bool alreadyExists = false;
                for(int i=0; i<index;i++){
                    if(labels[i] == str ) { alreadyExists=true;}
                }
                if(!alreadyExists) {
                    labels[index]=str;
                    labelPoints[index]= inf.tellg();
                    index++;
                }
            }*/

            else if(str=="jmp") {
                inf>>str;
                for(int i=0;i<index;i++) {
                    if( labels[i]==str) {
                        inf.seekg( labelPoints[i], ios::beg);
                    }
                }
            }
            else if(str=="jz") {
                inf>>str;
                long value = getValue(str);

                if(value==0) {
                    inf>>str;
                    for(int i=0;i<index;i++) {
                        if( labels[i]==str) {
                            inf.seekg( labelPoints[i], ios::beg);
                        }
                    }
                }
            }

            else if(str=="jnz") {
                inf>>str;
                long value = getValue(str);

                if(value!=0) {
                    inf>>str;
                    for(int i=0;i<index;i++) {
                        if( labels[i]==str) {
                            inf.seekg( labelPoints[i], ios::beg);
                        }
                    }
                }
            }

            else if(str== "\"shuffle\"") {
                inf>>str;
                if(str=="l"){ l(); }
                else if(str=="f"){ f(); }
                else if(str=="b"){ b(); }
                else {cerr<<"Bad shuffle parameter";}

            }

            else if(str=="print") {

                for(int i=0;i<24;i++) {

                    if( (i+1) != (*stackptrs[i]).place() ) {
                        cerr<< "Sorry, your stacks are in the wrong place! You can't print unless you put them back! Exiting. ";
                        return 1;
                    }

                }
                inf>>str;
                if(str=="Gertrude"){printUnary(Gertrude);}
                else if(str=="Hans"){printUnary(Hans);}
                else if(str=="ShabbySam"){printUnary(ShabbySam);}
                else if(str=="Alberto"){printUnary(Alberto);}
                else if(str=="Leopold"){printUnary(Leopold);}
                else {cerr<<"Bad register name. ";}

            }

            else if(str=="done!") {return 0;}

            else if(str=="print-d" ){
                inf>>str;
                long value = getValue(str);
                cout<<str;
              }
        }

    }

    /*for(int i=1;i<25;i++) {
        (*(stackptrs[i-1])).push(i);
    }

    u();d();r();l();f();b();
    */

    cout<<"\n";
    for(int i=1;i<25;i++) {
        if( (*(stackptrs[i-1])).size()>0 ) {
            cout<<(*(stackptrs[i-1])).top()<<" "<<(*(stackptrs[i-1])).place()<<"\n";
            (*(stackptrs[i-1])).pop();
        }
    }
    /*
    for (int i=0;i<index;i++) {
        cout<<labels[i]<<": "<<labelPoints[i]<<"\n";
    }*/

    return 1;
}

-->Permutations
The permutations permute the elements of the stack list in the following fashion:

Where  means that

(These also appear in the interpreter code. If there is a discrepancy, the interpreter is correct.)

-->Simple Example

These two simple programs print the numbers from 24 to 1 (in unary) with no whitespace.

mov 24 Hans
start:
    print Hans
    dec Hans
    jnz Hans start
done!

or

mov 24 Hans start: print Hans dec Hans jnz Hans start done!

They are the same program.

Explanation and Solution:

Martin has a good explanation in his answer as well.

As Martin figured out, this language was inspired by the pocket cube (aka 2x2 Rubik's cube). The 24 stacks are like the 24 individual squares on the cube. The permutations are the basic moves allowed: up, down, right, left, front, back.

The main struggle here is that when values are pushed, only three moves are used: up, down, and right. However, you do not have access to these moves when "shuffling" the stacks. You have only the other three moves.

As it turns out, both sets of three moves actually span the entire group (i.e. are generators), so the problem is solvable. This means that you can actually solve any 2x2 Rubik's cube only using 3 of the moves.

All that is left to do is figure out how to undo the up, down, and right moves using the other three. To this end, I employed a computer algebra system called GAP.

After undoing the permutations, finding the third largest number is fairly trivial.

cinpush
main:
    mov 1s ShabbySam
    POP!! 1
    jmp compare
    continue:
        gte 0 ShabbySam Leopold
        jnz Leopold end
        gte ShabbySam 9 Leopold
        jz Leopold uinverse
        gte ShabbySam 29 Leopold
        jz Leopold dinverse
        jnz Leopold rinverse
compare:
    gte ShabbySam Alberto Leopold
    jz Leopold skip
    mov Gertrude Hans
    mov Alberto Gertrude
    mov ShabbySam Alberto
    jmp continue
    skip:
        gte ShabbySam Gertrude Leopold
        jz Leopold skip_2
        mov Gertrude Hans
        mov ShabbySam Gertrude
        jmp continue
    skip_2:
        gte ShabbySam Hans Leopold
        jz Leopold continue
        mov ShabbySam Hans
        jmp continue
uinverse:
    "shuffle" f
    "shuffle" f
    "shuffle" f
    "shuffle" l
    "shuffle" b
    "shuffle" l
    "shuffle" b
    "shuffle" b
    "shuffle" b
    "shuffle" l
    "shuffle" l
    "shuffle" l
    "shuffle" b
    "shuffle" b
    "shuffle" b
    "shuffle" l
    "shuffle" l
    "shuffle" l
    "shuffle" f
    jmp main
dinverse:
    "shuffle" f
    "shuffle" b
    "shuffle" l
    "shuffle" b
    "shuffle" b
    "shuffle" b
    "shuffle" f
    "shuffle" f
    "shuffle" f
    jmp main
rinverse:
    "shuffle" b "shuffle" l "shuffle" f "shuffle" l "shuffle" b
    "shuffle" f "shuffle" f "shuffle" f "shuffle" b
    "shuffle" l "shuffle" l "shuffle" l
    "shuffle" b "shuffle" b "shuffle" b
    "shuffle" f "shuffle" f "shuffle" f
    "shuffle" l "shuffle" f "shuffle" l "shuffle" f
    "shuffle" l "shuffle" f "shuffle" f "shuffle" f
    "shuffle" l "shuffle" l "shuffle" l
    "shuffle" f "shuffle" l "shuffle" l
    "shuffle" f "shuffle" f "shuffle" f
    "shuffle" l "shuffle" l "shuffle" l
    "shuffle" l "shuffle" l "shuffle" l "shuffle" f
    "shuffle" l "shuffle" l "shuffle" l
    "shuffle" f "shuffle" f "shuffle" f
    "shuffle" l "shuffle" l "shuffle" l
    "shuffle" f "shuffle" f "shuffle" f
    "shuffle" l "shuffle" l "shuffle" l
    "shuffle" f "shuffle" f "shuffle" f
    "shuffle" l "shuffle" l "shuffle" l
    "shuffle" f "shuffle" f "shuffle" f
    "shuffle" l "shuffle" f "shuffle" l "shuffle" f "shuffle" l "shuffle" f
    "shuffle" l "shuffle" l "shuffle" l
    jmp main
end:
    print Hans
    done!


Advent Challenge 1: Help Santa unlock his present vault! Next >>

Descriptive Keywords (for searching): Make Two Matrices Equivalent, Overlap, Array, Find

Challenge

Santa has had a history of elves stealing presents from his vault in the past, so this year he designed a lock that is very hard to crack, and it seems to have kept the elves out this year. Unfortunately, he has lost the combination and he can't figure out how to open it either! Fortunately, he has hired you to write a program to find the combination. It doesn't need to be the shortest one, but he needs to find it as fast as possible!

He has a very strict schedule and he can't afford to wait for very long. Your score will be the total run-time of your program multiplied by the number of steps your program outputs for the scoring input. Lowest score wins.

Specifications

The lock is a square matrix of 1s and 0s. It is set to a random arrangement of 1s and 0s and needs to be set to a specified code. Fortunately, Santa remembers the required code.

There are a few steps he can perform. Each step can be performed on any contiguous sub-matrix (that is, you must select a sub-matrix that is entirely bounded by a top-left and bottom-right corner) (it can be a non-square sub-matrix):

Rotate right 90 degrees*
Rotate left 90 degrees*
Rotate 180 degrees
Cycle each row n elements right or left (wraps)
Cycle each column m elements up or down (wraps)
Flip Horizontally
Flip Vertically
Flip on the Main Diagonal*
Flip on the Main Anti-diagonal*

*only if the sub-matrix is square

Of course, he can also perform these steps on the entire matrix. Since 1s and 0s can only be swapped on the matrix but the value of a square cannot be directly changed, the number of 1s and 0s is the same for the start and end configuration.

Formatting Specifications + Rules

You will be given the input as two square matrices (starting position and ending position) in any reasonable format you want. The output should be a sequence of these steps in any readable format. Since this isn't code-golf, please make it an easily verifiable format, but that's not a strict requirement. You can choose to take the side-length of the matrices in the input if you want.

Your program will be run on my computer (Linux Mint, exact version details available upon request if anyone cares :P) and I will time it based on the amount of time between the time I press "enter" on the command line and when the command exits.

Test Cases

1 0 0 1    0 0 0 0
0 1 1 0 -> 0 0 0 0
0 1 1 0 -> 1 1 1 1
1 0 0 1    1 1 1 1

Take the entire matrix. Cycle each column up 1.
Take the middle two columns as a sub-matrix. Cycle each column down 2.

1 0 1 0 1    0 1 0 1 0
0 1 0 1 0    1 0 1 0 1
1 0 1 0 1 -> 0 1 1 1 0
0 1 0 1 0    1 0 1 0 1
1 0 1 0 1    0 1 0 1 0

Take the entire matrix. Cycle each column down 1.
Take the middle column. Cycle it down 2.
Take the top 2 rows. Flip it vertically.
Take the top row's rightmost 2 elements. Swap them (rotate right/left 1, flip horizontally).
Take the top row's leftmost 2 elements. Swap them.

There might be more efficient methods, but that doesn't matter. Feel free to point them out in the comments if you find one though :)

Judging Test Case

This test case will be used to judge your submission. If I believe that an answer is specializing for the test case too much, I have the right to repick a random input and rejudge all answers with the new case. The test case can be found here where the top is the start and the bottom is the desired configuration.

If I believe answers are specializing too much, the MD5 of the next test case is 3c1007ebd4ea7f0a2a1f0254af204eed. (This is written here right now to liberate myself from accusations of cheating :P)

Standard Loopholes Apply. No answer will be accepted. Happy coding!

Note: I drew inspiration for this challenge series from Advent Of Code. I have no affiliation with this site

You can see a list of all challenges in the series by looking at the 'Linked' section of the first challenge here.

Java

import java.util.Arrays;

public class SantaMatrix4 {

	public static void flipV(int[][] matrix, int row1, int col1, int row2, int col2) {
		for (int row = row1; row <= (row2 - row1) / 2 + row1; row++) {
			for (int col = col1; col <= col2; col++) {
				int tmp = matrix[row][col];
				matrix[row][col] = matrix[row2 - row + row1][col];
				matrix[row2 - row + row1][col] = tmp;
			}
		}
	}

	public static void flipH(int[][] matrix, int row1, int col1, int row2, int col2) {
		for (int row = row1; row <= row2; row++) {
			for (int col = col1; col <= (col2 - col1) / 2 + col1; col++) {
				int tmp = matrix[row][col];
				matrix[row][col] = matrix[row][col2 - col + col1];
				matrix[row][col2 - col + col1] = tmp;
			}
		}
	}

	public static void main(String[] args) {
		int counter = 0;
		int n = Integer.parseInt(args[counter++]);
		int[][] matrix1 = new int[n][n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				matrix1[i][j] = Integer.parseInt(args[counter++]);
			}
		}

		int[][] matrix2 = new int[n][n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				matrix2[i][j] = Integer.parseInt(args[counter++]);
			}
		}

		int[] ops = new int[5 * matrix1.length * matrix1.length * 2];
		int numOps = 0;
		int opsI = 0;

		for (int row = 0; row < n; row++) {
			for (int col = 0; col < n; col++) {
				int goal = matrix2[row][col];
				boolean gotIt = false;

				//Look for required number to the right
				for (int i = row; i < n && !gotIt; i++) {
					for (int j = col; j < n && !gotIt; j++) {
						if (i == row && j == col) continue;
						if (matrix1[i][j] == goal) {
							flipH(matrix1, row, col, i, j);
							flipV(matrix1, row, col, i, j);
							ops[opsI++] = 1;
							ops[opsI++] = row;
							ops[opsI++] = col;
							ops[opsI++] = i;
							ops[opsI++] = j;
							numOps++;

							gotIt = true;
						}
					}
				}

				//Look for required number below and to the left
				for (int i = row + 1; i < n && !gotIt; i++) {
					for (int j = 0; j < col && !gotIt; j++) {
						if (matrix1[i][j] == goal) {
							flipH(matrix1, i, j, i, col);
							ops[opsI++] = 2;
							ops[opsI++] = i;
							ops[opsI++] = j;
							ops[opsI++] = i;
							ops[opsI++] = col;

							flipV(matrix1, row, col, i, col);
							ops[opsI++] = 3;
							ops[opsI++] = row;
							ops[opsI++] = col;
							ops[opsI++] = i;
							ops[opsI++] = col;

							numOps += 2;
							gotIt = true;
						}
					}
				}

			}
		}

		System.out.println(Arrays.toString(ops));
		System.out.println(numOps);
	}
}

Slightly faster hard-coded version: Try it online!

Input is space separated integers via the command line. The first integer is the width of the two matrices. The remaining integers are their elements, row-by-row.

Every permutation of a matrix can be obtained with just the horizontal flip and vertical flip operators, so I ignored the rest except for replacing a consecutive vFlip and hFlip in the same region with a rotation by 180 degrees.

The program scans through each element. Whenever we encounter an element that has the wrong bit, it looks further ahead through the array to find a spot that has the correct bit. I've divided the search region in two: those with an equal or larger column coordinate, and those with a smaller column coordinate. Note that the latter must have a larger row coordinate based on the way we're traversing the array. If we find a correct bit in the first search region, we can just rotate by 180 degrees the sub-matrix spanning the two elements for a total of one operation. If it's in the second region, we can use a horizontal flip to move the correct bit to the same column as the wrong bit and then vertically flip the sub-matrix spanning the two for a total of two operations.

The output of the program is an array that should be mentally split into groups of five. Each group is (i, row1, col1, row2, col2) where i is 0 for a no-op, 1 for a rotation by 180 degrees, 2 for a horizontal flip, and 3 for a vertical flip. The remaining 4 components describe the region over which the operation runs. I am not sure if this is a readable format.

For the given test case, I get 258 operations and two to three milliseconds on my computer.


Output a program that outputs a program ... that outputs PPCG Challenge:

Write a code that, when executed will output the source code of a second program that can be executed in another language. The second program should output the source code of a third program that can be executed in a third language and so on. The last program should output PPCG with an optional single trailing newline.

The winner will be the submission with the most languages. Code length of the first program will be the tie breaker.

Important rules:

No programs can be identical
Each language must only work on one of the source codes. It should be impossible to use the same language two places in the chain without breaking it(see examples).

A shortened chain is not a broken chain. If you can use a language in a different place than intended and the end result is still PPCG then it's invalid

All versions of a language count as unique languages (but keep in mind rule number 2)

Examples:

An invalid submission:

print("""print'disp("PPCG")'""")

Python 3: print("""print'disp("PPCG")'""") prints print'disp("PPCG")'
Python 2: print'disp("PPCG")' prints disp("PPCG")
Octave  : disp("PPCG") prints PPCG

This works properly, but: you can run both the first and the second code in Python 2 without breaking the chain, so this violates rule number 2.

A valid submission with score 3:

print("""print'disp("PPCG")'""")

Python 3: print("""print'disp("PPCG")'""") prints print'disp("PPCG")'
Perl    : print'disp("PPCG")' prints disp("PPCG")
Octave  : disp("PPCG") prints PPCG

This is the exact same code as the invalid example. The difference is, we have chosen languages that adhere to rule number 2: You can't run the first code in Perl/Octave, the second code in Python 3/Octave nor the last code in Python 3/Perl. This is valid even though Python 2 can run the two first programs, because we haven't used Python 2 as one of the languages.

12 languages, 64 bytes
Charcoal -> tinylisp -> Python 3 -> /// -> Python 2 -> Perl -> QBasic -> Pip -> V -> Retina -> Pyth -> GolfScript
Charcoal
Ｐ(q(print('/x/print/x"""x q<?"`i.*":?CHR$(34)+"\'PPCG\'`">"""'*1

Any run of printable ASCII is a string literal in Charcoal. Ｐ can be used for multidirectional printing, but in this case it simply prints the string going rightward.
tinylisp
(q(print('/x/print/x"""x q<?"`i.*":?CHR$(34)+"\'PPCG\'`">"""'*1

The only reserved characters in tinylisp (as of this writing) are parentheses and whitespace. Any other run of characters is a token, even something like +"\'PPCG\'`">"""'*1. Parentheses define lists. The q (quote) builtin returns its argument unevaluated--in this case, the nested list (print ('/x/print/x"""x q<?"`i.*":?CHR$ (34) +"\'PPCG\'`">"""'*1)). (Missing parentheses at the end are autocompleted.)
Python 3
(print ('/x/print/x"""x q<?"`i.*":?CHR$ (34) +"\'PPCG\'`">"""'*1))

Since print is a function in Python 3, we can wrap it in parentheses with no problem. In Python 2, where it's a statement, this is a syntax error. Unfortunately, Perl is fine with the parentheses, so we also do *1 (string repetition in Python, cast to int and multiply in Perl).
///
/x/print/x"""x q<?"`i.*":?CHR$ (34) +"'PPCG'`">"""

/x/print/ changes x to print in the rest of the program, which has no slashes and therefore is output with no further changes.
Python 2
print"""print q<?"`i.*":?CHR$ (34) +"'PPCG'`">"""

No parentheses after print, doesn't work in Python 3. Perl doesn't like the triple quotes.
Perl
print q<?"`i.*":?CHR$ (34) +"'PPCG'`">

Perl's various ways of quoting a string are helpful, and distinct from other languages. Here we use q<...>.
QBasic
?"`i.*":?CHR$ (34) +"'PPCG'`"

A couple of print statements (abbreviated as ?), using CHR$(34) to get a double quote.
Pip
`i.*
"'PPCG'`

A single Pattern (regex) literal in backticks.
V
i.*
"'PPCG'

Switch to insert mode, add some text.
Retina
.*
"'PPCG'

Match anything and replace it with the second line.
Pyth
"'PPCG'

Pyth quotes don't need to be matched (which makes this not a valid program in Pip).
GolfScript
'PPCG'


DVORAK Keyboard layout Here's an interesting challenge...
I want you to golf code that when executed will allow your input to be converted to mimic output as though you were typing on a DVORAK keyboard layout.
The aim is to mimic the US Simplified Dvorak Keyboard (US:SDK)

In comparison, here is the standard US QWERTY layout:

The keyboard emulation must work for both uppercase and lower case letters as well as shifted keys, for example, if I tapped the q (unshifted) key on my keyboard, the Dvorak code should pop out a ' character on the screen. If I were to tap the c (unshifted) button I should get a j (also unshifted) in response, C (shifted) would get J (shifted) and so on...
I am only concentrating of course on the white keys in the diagram above. Tabs, Caps and the other grey keys should work as per normal...
Any questions? Not for now? Good...
I will not allow external resources that already have the layout encoded already, I will not have any files brought in that can encode the layout. The code MUST be QWERTY INPUT -> (DVORAK RE-CODING) -> DVORAK OUTPUT in nature. No silly Esolangs that are theoretical or just say something like "This program will take QWERTY input and recode it in DVORAK. This is the program." or crap like that... Take this challenge seriously... So Brainfuck coders, I welcome you.
Please note, this is NOT a string conversion program. For every QWERTY key you press, the corresponding DVORAK character must be outputted...
Shortest code wins...

C - 144 characters

main(c){putch((c=getch())>33?c:"_#$%&-()*}w[vz0123456789SsW]VZ@AXJE>UIDCHTNMBRL\"POYGK<QF:/\\
=^{`axje.uidchtnmbrl'poygk,qf?|+~"[c-34]);main(0);}


Count the number of possible squares In a 9 by 9 grid some points have been marked. The task is it to
make a program that counts all distinct squares that can be made
using four marked points. Note that squares can also be placed
diagonally (any angle).
Input can be one of the following:

A character string of length 81 containing two distinct characters
for marked and unmarked points.
A one dimensional array (length 81) containing two distinct values.
A two dimensional array (9 by 9) with containing distinct values.

Output: The number of possible squares
You can write a full program or a function. This is code-golf. I am interested in the shortest code in every language. Standard loopholes are forbidden.
Examples:
Input:  ooo......oooooo...oooooo....oo.oo....oooooo...oooooo......ooo....................
Output: 62

Looks like:

o o o
o o o o o o
o o o o o o
  o o   o o
  o o o o o o
  o o o o o o
        o o o

Input:  ...ooo......ooo......ooo...ooo...oooooo.o.oooooo...ooo...ooo......ooo......ooo...
Output: 65

Input:  ...........o..o..o....................o..o..o....................o..o..o.........
Output: 6

Input:  ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
Output: 540

Input:  ...........o..o.......................o.....o....................o...o...........
Output: 0

Jelly, 18 bytes
ŒṪÆịœc4ṗ2ạ/€QLƲ€ċ3

Try it online!
Input is a two-dimensional list of 0 and 1 (or any other falsy and truthy value).
Explanation
The idea is that for every four distinct points, we calculate the distance between each pair and if there are exactly three distinct distances (including 0), it's a square. (There are other shapes with this property, but they don't fit on a square grid; see @aPaulT's comment.)
ŒṪÆịœc4ṗ2ạ/€QLƲ€ċ3   Main monadic link
ŒṪ                   Get the coordinates of truthy points
  Æị                 Convert to complex numbers
    œc4              Get all combinations of size 4
               €     For each
              Ʋ      (
       ṗ2              Cartesian square
         ạ/            Absolute difference
           €             of each pair
            Q          Find unique items
             L         Length
              Ʋ      )
                ċ3   Count the occurences of 3


Solve a System of Linear Equations Write a program to solve a series of linear equations as short as possible. It must solve arbitrary number of equations problems. They can inputted however you like, coefficients of augmented matrix is probably the easiest. The program doesn't have to handle non-integer coefficients or solutions. No degenerate or invalid cases will be tested. The program must output the value of each variable or reduced row echelon form.

No equation solving libraries, matrix functions, or any way to automatically solve is allowed. You can simulate matrices with arrays or lists.

Example input (or equivalent):

m={{2,1,-1,8},{-3,-1,2,-11},{-2,1,2,-3}}

This represents 2x+y-z=8, -3x-y+2z=-11, -2x+y+2z=-3

Example output (or equivalent):

{2,3,-1}

This represents x=2, y=3, z=-1

APL, 1 char

I know it doesn't fit the (revised) requirements, but it's too good not to post:

⌹

Symbol "domino" ⌹ (division ÷ inside a rectangle) performs matrix division, therefore it can solve any system of linear equations. You just have to put it between the constant term vector and the matrix with the other terms:

      8 ¯11 ¯3 ⌹ ⊃(2 1 ¯1)(¯3 ¯1 2)(¯2 1 2)
2 3 ¯1

(if you want to try it on TryApl, ⊃ is ↑)


Transpile these ES6 arrow functions! The ECMAScript 6 standard added many new features to the JavaScript language, including a new arrow function notation.

Your task is to write a basic ES6-to-ES5 transpiler. Given only an ES6 arrow function as input, output its ES5-compatible counterpart.

It's code-golf! May the shortest program in bytes win!

The Basics

An arrow function looks like this:

(a, b, c) => { return a + b - c }

And its equivalent ES5 function expression looks like this:

function(a, b, c) { return a + b - c }

In general, you can copy the body of the function (everything between the curly braces) verbatim.

Implicit Return Statement

Instead of a body with curly braces, a single expression can be used; the result of this expression is then returned.

(a, b, c) => a + b - c

function(a, b, c) { return a + b - c }

Another example:

(a, b, c) => (a + 1, b - 2 * c / 3)

function(a, b, c) { return (a + 1, b - 2 * c / 3) }

Again, you may simply copy the expression verbatim - BUT take care that you do not output a line break between it and the return keyword to avoid automatic semicolon insertion!

One Argument

Parentheses are optional if one argument is provided.

foo => { return foo + 'bar' }

function(foo) { return foo + 'bar' }

Whitespace

Finally, you must be able to account for any number of whitespace characters (space, tab, newline) before or after parentheses, variables, commas, curly braces, and the arrow*.

 ( o   ,  O
     , _    )=>{

    return                                     "Please don't write code like this."
}

Whether or not you choose to preserve whitespace in the output is up to you. Keep 'em, remove 'em, or add your own - just make sure it's valid code!

*It's technically illegal for an arrow to come immediately after a line break, but I doubt this fact would help you. :)

A quick way to validate your output:

Enter var foo = <your output>; foo() into your browser console. If it doesn't complain, you're probably on the right track.

More rules for the wizards:

Input is a syntactically valid ES6 arrow function.
Assume the body of the function is ES5-compatible (and doesn't reference this, super, arguments, etc). This also means that the function will never contain another arrow function (but you may not assume that "=>" will never occur within the body).
Variable names will only consist of basic Latin letters, $ and _.
You need not transpile ES6 features that aren't listed above (default parameters, rest operator, destructuring, etc).
The space after a return statement is optional if followed by (, [, or {.
It isn't strictly necessary to match my test cases exactly - you can modify the code as much as you need if it'll help lower your byte count. Really, as long as you produce a syntactically valid, functionally equivalent ES5 function expression, you're golden!

JavaScript (ES6), 123 110 100 97 bytes

Saved 3 bytes thanks to @Neil

s=>s.replace(/\(?(.*?)\)?\s*=>\s*([^]*)/,(_,a,b)=>`function(${a})${b[0]=='{'?b:`{return ${b}}`}`)

Assumes the input is a syntactically valid arrow function and nothing else. Correctly handles the case a =>\na, though not handling is not any shorter as far as I can tell.

Output when the code is run through itself:

function(s){return s.replace(/\(?(.*?)\)?\s*=>\s*([^]*)/,(_,a,b)=>`function(${a})${b[0]=='{'?b:`{return ${b}}`}`)}

I can save 9 bytes with a possibly invalid format:

s=>s.replace(/\(?(.*?)\)?\s*=>\s*({?)([^]*?)}?$/,(_,a,z,b)=>Function(a,z?b:'return '+b))

Output for itself:

function anonymous(s) {
return s.replace(/\(?([^=)]*)\)?\s*=>\s*({?)([^]*?)}?$/,(_,a,z,b)=>Function(a,z?b:'return '+b))
}

(Specifically, the function anonymous is what I'm worried about.)


Optimize ASCII test-tubes You are given a bunch of ASCII test-tubes, your task is to reduce number of test-tubes used.

Each test tube looks like this:

|  |
|  |
|  |
|~~|
|  |
|  |
|  |
|  |
|__|

Obviously, ~~ is the water level. Test-tube can be also empty, in which case there are no ~~ characters inside. Single tube can contain up to 8 water level units.

You are given finite number of test tubes with different water levels inside. You have to pour the water in least amount of test-tubes possible, and output the result.

|  | |  | |  | |  |         |~~| |  |
|  | |  | |  | |  |         |  | |  |
|  | |~~| |  | |  |         |  | |  |
|~~| |  | |  | |  |         |  | |~~|
|  | |  | |  | |  | ------> |  | |  |
|  | |  | |  | |  |         |  | |  |
|  | |  | |~~| |  |         |  | |  |
|  | |  | |  | |  |         |  | |  |
|__| |__| |__| |__|         |__| |__|

 05 + 06 + 02 + 00  ------>  08 + 05

As you can see, test-tubes are separated with single space. Empty tubes should not be shown in output.
This is code golf, so code with least number of bytes wins.

Test cases: http://pastebin.com/BC0C0uii

Happy golfing!

Pyth, 48 45 44 bytes
jCssm+_B,*9\|_X+\_*8;ld\~*9;cUs*L/%2w\~_S8 8

Try it online.
Prints a single trailing space on every line.


Converting ISBN-13 to ISBN-10 Introduction

In this challenge your task is to generate the ISBN-10 code for books given its ISBN-13 code, assuming that such a code exists. Such an ISBN-13 code consists of several parts separated by -:

978-GG-PPPP-TTT-C

The letters G (group), P (publisher), T (title) and C (checksum) all stand for one digit. For the purpose of this challenge the grouping and the computation of C (see this challenge) are not interesting and we'll drop all hyphens to make this task simpler.

An ISBN-10 number has a very similar layout:

GG-PPPP-TTT-c

The letters G,P and T are the same as for the 13 digits ISBN, however c is different (and is computed using a different algorithm). The digit c is chosen in a way such that the following equivalence holds (digits in order):

10*G + 9*G + 8*P + … + 3*T + 2*T + 1*c = 0 (mod 11)

Example

Let us consider the ISBN number 9780345391803: To get its corresponding ISBN-10 code we simply drop the leading 978 and the checksum 3 yielding 034539180.

Next we need to compute the new checksum:

10*0 + 9*3 + 8*4 + 7*5 + 6*3 + 5*9 + 4*1 + 3*8 + 2*0 = 185

The next number divisible by 11 is 187, so the new checksum is 2 and thus the resulting ISBN-10 code 0345391802.

Rules

Your input will always have a corresponding ISBN-10 number (ie. it is exactly 13 digits long and starts with 978)
The input doesn't necessarily have to be a valid ISBN-13 (eg. 9780000000002)
You're guaranteed that the resulting ISBN won't end with X
You may take input as an integer or string (with or without hyphens) however a precomputed list of digits are not allowed
Your output must be a valid ISBN-10 number (with or without hyphens)
Your output may be an integer or string (again no lists of digits)

Testcases

9780000000002 -> 0000000000
9780201882957 -> 0201882957
9781420951301 -> 1420951300
9780452284234 -> 0452284236
9781292101767 -> 1292101768
9780345391803 -> 0345391802

Note the leading zeroes!

Retina,  44  39 28 bytes

>,L3,-2`.+
.
$.>`**
_{11}

_

Try it online!

Explanation

Time to show off some new Retina features. :)

>,L3,-2`.+

We match the entire input with .+, return that match L, but select only the characters 3 (zero-based) to -2 (penultimate), inclusive. We also print the result without a trailing linefeed (>).

Now, subtracting things in Retina is a bit annoying. But luckily, we're working modulo 11, so we can just invert the coefficients of the linear combination (mod 11) and add everything up. In other words, if the constraint is:

10*G + 9*G + 8*P + … + 3*T + 2*T + 1*c = 0 (mod 11)

then we get:

c = 1*G + 2*G + 3*P + … + 8*T + 9*T (mod 11)

That simplifies things a lot here:

.
$.>`**

We replace each character with that thing at the bottom. * is Retina's repetition operator. It's right-associative and it has implicit operands $& on the left and _ on the right, so the substitution is actually short for $.>`*$&*_. $&*_ creates a string of d underscores, where d is the digit we're currently replacing. Then $.>` is the length of the string up to and including the match.1 Hence, the entire expression results in a unary representation of the nth term of our linear combination.

_{11}

Doing the actual modulo is trivial in unary: we just drop all complete sets of 11 underscores.

_

Finally, we count how many underscores remain and print the result, which completes the ISBN-10.

1 How does $.>` give the length of the string up to and including the match? You might be familiar with $` in regex substitutions, which gives you the string up to (but excluding) the match. By inserting a >, we can shift the context of the $` to the separator between the current match and the next (which is an empty string between the current digit and the next). That separator's $` will include the current match. So $>` is a shorter way to write $`$&. Finally, for all $x-type substitution elements, Retina lets you insert a . after the $ to get its length.


Shortest Uniquely Identifying Substrings Given a list of strings, replace each string by one of its non-empty substrings which is not a substring of any of the other strings in the list and as short as possible.
Example
Given the list ["hello","hallo","hola"], "hello" should be replaced by just "e" as this substring is not contained in "hallo" and "hola" and it is as short as possible. "hallo" could be replaced by either "ha" or "al" and "hola" by any of "ho", "ol" or "la".
Rules

You can assume that the strings will be non-empty and only contain alphabetical characters of the same case.
You can assume that such a substring exists for each string in the list, i.e. no string in the list will be a substring of any of the other strings.
Input and output can be in any reasonable format.
This is code-golf, so try to use as few bytes as possible in the language of your choice.

Test Cases
Only one possible output is given for most cases.
["ppcg"] -> ["p"] (or ["c"] or ["g"])
["hello","hallo","hola"] -> ["e","ha","ho"]
["abc","bca","bac"] -> ["ab","ca","ba"]
["abc","abd","dbc"] -> ["abc","bd","db"]
["lorem","ipsum","dolor","sit","amet"] -> ["re","p","d","si","a"]
["abc","acb","bac","bca","cab","cba"] -> ["abc","acb","bac","bca","cab","cba"]

Related: Shortest Identifying Substring - similar idea, but more involved rules and cumbersome format.

Jelly,  12  9 bytes

Ẇ€ŒpẇþÞ⁸Ḣ

Try it online! Or see the test-suite (takes ~35s)


Make me a fake loader Make a fake loader just like this :

Parameters :

Display loading (space) one of these cyclically-\|/ (space) (percentage counter from 0-100) then a %.
The percentage counter is supposed to increment by 1 every time the display changes.
The time taken by counter to jump to next iteration is random. Any kind of random will do as long as the function/method is capable of generating all random integers having probability > 0 in range 1<= ms <=750 here ms being time in milliseconds.
Start at loading - 0 %.
End at loading - 100 %.
NO INPUT is required.
submit a full program or function or whatever similar.

The code that I used :

C++

#include<stdio.h>
#include<time.h>
#include<windows.h>

int main()
{
    srand(time(NULL));
    char a[15],b[]="-\\|/";
    int i=0,j=0,ms;
    while(j<101)
    {
        (i<3)?i++:i=0;
        wsprintf(a,"loading %c %d ",b[i],j++);
        printf(a);puts("%");
            //This part is to make the output look cool
        switch(rand()%9)
        {
            case 0:ms=1;break;
            case 1:ms=2;break;
            case 2:ms=5;break;
            case 3:ms=10;break;
            case 4:ms=15;break;
            case 5:ms=20;break;
            case 6:ms=25;break;
            case 7:ms=50;break;
            case 8:ms=500;
        }
        Sleep(ms);  //Otherwise this is supposed to be random
        if(j<101)   //like this Sleep(rand()%750+1);
        system("cls");
    }
}

Winner

the code with least bytes wins.

Powershell, 71 68 65 Bytes

Similar to https://codegolf.stackexchange.com/a/101357/59735

Saved 3 bytes by not being an idiot (left the ... on loading)

-3 thanks to VisualMelon

changed 750 -> 751 to make sure 750 is included.

0..100|%{cls;"loading $("|/-\"[$_%4]) $_ %";sleep -m(random 751)}

Explanation:

0..100|%{                                  #For range 0-100...
    cls                                    #Clear Display
    "loading $("|/-\"[$_%4]) $_ %"    #Display the current string
    sleep -m(random 750)                  #Sleep random ms up to 750
}

Updated gif


Triangular Square Numbers Square numbers are those that take the form of \$n^2\$ where \$n\$ is an integer. These are also called perfect squares, because when you take their square root you get an integer.
The first 10 square numbers are: (OEIS)
0, 1, 4, 9, 16, 25, 36, 49, 64, 81

Triangular numbers are numbers that can form an equilateral triangle. The n-th triangle number is equal to the sum of all natural numbers from 1 to n.
The first 10 triangular numbers are: (OEIS)
0, 1, 3, 6, 10, 15, 21, 28, 36, 45

Square triangular numbers are numbers that are both square and triangular.
The first 10 square triangular numbers are: (OEIS)
0, 1, 36, 1225, 41616, 1413721, 48024900, 1631432881, 55420693056, 1882672131025, 63955431761796

There is an infinite number of square numbers, triangle numbers, and square triangular numbers.
Write a program or named function that given an input (parameter or stdin) number \$n\$, calculates the \$n\$th square triangular number and outputs/returns it, where n is a positive nonzero number. (For \$n=1\$ return 0)
For the program/function to be a valid submission it should be able to return at least all square triangle numbers smaller than \$2^{31}-1\$.
Bonus
-4 bytes for being able to output all square triangular numbers less than 2^63-1
-4 bytes for being able to theoretically output square triangular numbers of any size.
+8 byte penalty for solutions that take nonpolynomial time.
Bonuses stack.
This is code-golf challenge, so the answer with the fewest bytes wins.

Python 2, 45 - 4 - 4 = 37

a=1;b=0
exec"a,b=b,34*b-a+2;"*input()
print a

Iterates using the reccurence

f(0) = 1
f(1) = 0
f(k) = 34*f(k-1)-f(k-2)+2

In theory, this supports numbers of any size, but runs in exponential time, so it shouldn't qualify for the bonuses. Should work for numbers of any size. For example, for 100, gives

1185827220993342542557325920096705939276583904852110550753333094088280194260929920844987597980616456388639477930416411849864965254621398934978872054025

A recursive solution uses 41 chars, but shouldn't qualify because it takes exponential time.

f=lambda k:k>2and 34*f(k-1)-f(k-2)+2or~-k


Black Box Trigonometry Write a program or function that can distinguish the following 12 trigonometric functions:  sin,
cos,
tan,
asin,
acos,
atan,
sinh,
cosh,
tanh,
asinh,
acosh,
atanh.

Your program is given one of the above functions as black box and should output the function's name either as given above or the way it is named in your language.

This is code-golf, so the shortest answer in each language wins. You should show that your code works correctly by including test cases with all 12 possible inputs. If the language of your choice does not include build-ins for all of the above functions, you have to provide your own sensible implementations of the missing ones.

Further Clarifications

Using complex numbers to query the black box is allowed if the underlying build-ins can handle them.
As \$ dom\ acosh \cap dom\ atanh = \emptyset \$ when using only real numbers, queries to the black box function can give domain errors. In this case you should assume that the black box only communicates the existence of an error, but not from which function it originates.
If instead of an error some other value, e.g. NaN or null, is returned, then your submission should be able to handle them.

Thanks for the helpful sandbox feedback!

Python 3.6.4 on Linux, 99 bytes

Bit of a silly answer, but:

lambda f:"asinh acos cos cosh atan atanh tan sin asin tanh sinh acosh".split()[hash(f(.029))%19%12]

Requires the trigonometric functions to be one out of the built-in cmath module for complex in/output.


Discrete Baker's Map Introduction

The Baker's map is an important dynamical system that exhibits chaotic behavior.
It is a function from the unit square to itself defined intuitively as follows.

Cut the square vertically in half, resulting in two rectangles of size 0.5×1.
Stack the right half on top of the left, resulting in one rectangle of size 0.5×2
Compress the rectangle back into a 1×1 square.

In this challenge, you'll implement a discrete version of this transformation.

Input and Output

Your input is a 2D array of printable ASCII characters and whitespace of size 2m×2n for some m, n > 0.
Your output is a similar array obtained as follows, using the 6×4 array

ABCDEF
GHIJKL
MNOPQR
STUVWX

as an example.
First, stack the right half of the array on top of the left half:

DEF
JKL
PQR
VWX
ABC
GHI
MNO
STU

Then, split the columns into pairs of characters, and independently turn each pair 90 degrees clockwise, "compressing" the tall rectangle back to the original shape:

JDKELF
VPWQXR
GAHBIC
SMTNUO

This is the correct output for the above array.

Rules

The input and output formats are flexible.
You can use newline-delimited strings, lists of strings, or 2D arrays of characters.
However, the input and output must have the exact same format: you must be able to iterate your submission an arbitrary number of times on any valid input.

You can write either a full program or a function.
The lowest byte count wins, and standard loopholes are disallowed.

Test Cases

Input:
12
34

Output:
42
31

Input:
Hell
!  o
d  -
lroW

Output:
 lol
o W-
!H e
ldr

Input:
ABCDEF
GHIJKL
MNOPQR
STUVWX

Output:
JDKELF
VPWQXR
GAHBIC
SMTNUO

Input:
*___  ___  o
o|__) |__) *
*|    |    o
o __   __  *
*|    | _  o
o|__  |__| *

Output:
|_____)   *o
 |_ _     *o
||_ __|   *o
o*|_____)
o* |_ _
o*||_ _

Pyth, 25 19 18 bytes

msC_dcs_Cmck/lk2Q2

Online demonstration. It uses an 2D-array of chars.

Array of strings is one char longer (19 bytes). Online demonstration

Explanation:

         m      Q    map each string k in input:
            /lk2        calculate half the line-length: len(k)/2
          ck/lk2        chop k into pieces of length len(k)/2
                        results in two pieces
        C            zip the resulting list
                     results in a tuple ([first half of strings], [second half of strings])
       _             invert the order ([second half of strings], [first half of strings])
      s              sum (combine the two lists to a big one
     c           2   chop them into tuples
m                          for each tuple of strings:
 sC_d                        invert, zip, and sum

The last part is a bit confusing at first. Let's assume we have the tuple ['DEF', 'JKL'] (I use the example from the OP).

    d  (('D', 'E', 'F'), ('J', 'K', 'L'))   just the pair of strings
   _d  (('J', 'K', 'L'), ('D', 'E', 'F'))   invert the order
  C_d  [('J', 'D'), ('K', 'E'), ('L', 'F')] zipped
 sC_d  ('J', 'D', 'K', 'E', 'L', 'F')       sum (combine tuples)


Bridges are metaphors for everything in ASCII Art (with apologies to Jim West for the title, and randomly inspired by Cisco's textual representation of their logo: .:|:.:|:. for the concept)

Given an input integer 1 <= n <= 255, output an ASCII art representation of a suspension bridge of distance n following the below construction rules:

The start and end of the bridge (not counted in the n distance) are always -| and |-, so the bridge can appropriately connect to the highways next to it.
The bridge doesn't extend downward (the roadway level, composed of the - row, is the bottom row).
There can be at most two roadway pieces -- in a row, any longer span requires suspension cables for support.
The suspension cables \ extend from the roadway up to the towers | in straight lines.
The towers | must be tall enough to support the adjacent suspension cables, but no taller.
The bridge must be balanced left-to-right about the middle point, favoring the center sections whenever possible.
All of the above should result in a minimization of the cables, but just to be clear, the number of suspension cables must be minimized while still following the above rules.

To provide a visual representation, here are the expected outputs for n = 1, 2, 3, ... 15 --

1
-|-|-

2
-|--|-

3
-|\-/|-

4
-|\--/|-

5
 |\   /|
-|-\-/-|-

6
 |\    /|
-|-\--/-|-

7
 |\     /|
 | \   / |
-|--\-/--|-

8
 |\      /|
 | \    / |
-|--\--/--|-

9
 |\       /|
 | \     / |
 |  \   /  |
-|\--\-/--/|-

10
 |\        /|
 | \      / |
 |  \    /  |
-|\--\--/--/|-

11
 |\         /|
 | \       / |
 |  \     /  |
 |\  \   /  /|
-|-\--\-/--/-|-

12
 |\          /|
 | \        / |
 |  \      /  |
 |\  \    /  /|
-|-\--\--/--/-|-

13
 |\           /|
 | \         / |
 |  \       /  |
 |\  \     /  /|
 | \  \   /  / |
-|--\--\-/--/--|-

14
 |\            /|
 | \          / |
 |  \        /  |
 |\  \      /  /|
 | \  \    /  / |
-|--\--\--/--/--|-

15
 |\             /|
 | \           / |
 |  \         /  |
 |\  \       /  /|
 | \  \     /  / |
 |  \  \   /  /  |
-|\--\--\-/--/--/|-

Input

A single positive integer in any convenient format, n > 9.

Output

The ASCII-art bridge following the above construction technique.

Rules

Leading or trailing newlines or whitespace are all optional, so long as the bridge characters themselves line up correctly.
Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
If possible, please include a link to an online testing environment so people can try out your code!
Standard loopholes are forbidden.
This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.

Python 2 , 173 bytes

i=input()
f=lambda b:'-|'+b[::-1].replace('/','\\')+-~(~i%2)*'-'+b+'|-'
b=(i*'/--')[:~-i/2]
for x in range(1,~-i/2):print f((len(b)-x)*'-'+b[:x]).replace('-',' ')
print f(b)

Mirror the value of b and add the central "-"
f=lambda b:'-|'+b[::-1].replace('/','\\')+-~(~i%2)*'-'+b+'|-'
Base pattern (right half of the bottom line)
b=(i*'/--')[:~-i/2]
Loop for non-bottom layers
for x in range(1,~-i/2):
Get the first x characters of the base pattern and complete with "-"
(len(b)-x)*'-'+b[:x]
Replace all - with spaces to print all the layers (except bottom)
print f().replace('-',' ')
Print bottom layer
print f(b)


Tips for golfing in Delphi Code-golfing is incredibly fun to do, trying to solve the given problem is one thing but the real challenge is getting your code as short as possible.

Some languages are perfect for golfing because of their short commands, sadly Delphi isn't one of them.

I'm looking for tips that are useful for golfing in Delphi.
Tips like "Use 1 letter variables" don't really count in my opinion since that is pretty obvious.

Tips I learned working with Delphi or found in other peoples answers so far are:

Semicolon isn't always required (Example 1)
Use int8 or int16 as datatype rather than integer (saves 3 or 2 characters)
Combine string manipulations(Example 2)

Example 1:

Procedure Example1(i:int16);
var x:int16;
begin
  for x:=0to 99do
    if i=1then
      inc(i)//Semicolon not allowed because of "else"
    else
     i:=i+3//No semicolon required
end;//Semicolon required

Example 2

function WrongExample2(myString:string):string;
const
  f:string='The result of your manipulation is: %s';
begin
  myString:= StringReplace(s,'x', '_', [RfReplaceAll]);
  Result := Format(f,[myString])
end;

function CorrectExample2(myString:string):string;
const
  f:string='The result of your manipulation is: %s';
begin
  Result := Format(f,[StringReplace(s,'x', '_', [RfReplaceAll])])
end;

Group definitions by keyword

This will save you from having to retype the keyword.

type WD=(Su,M,Tu,W,Th,F,Sa);M=(Ja,F,Mr,Ap,My,Jn,Jl,Ag,S,O,N,D);
const A=1;B=2;
var X,Y,Z:string;

Use function name instead of Result for holding function return value

Functions' return value can be referenced by the function name. Unless the function is required to be a particular name it will usually be shorter than Result.

function F:Int8;
begin
  F:=1
end;

Using the Exit short hand (Delphi 2009 or newer) is shorter than assigning to Result also:

function F:Int8;
begin
  Exit(1)
end;

Use comma-separated variable declarations

procedure Z(A,B,C: string);
var A,B,C:string;

Constants usually require fewer characters than variable declarations

With the exception of the above mentioned comma separated variable declarations constant declarations use fewer characters than variable declarations when initialization is taken into consideration.

const A=1; // True constant = 10 chars
const A:Int8=1; // Typed constant = 15 chars
var A:Int8; // Variable = 11 chars
begin
  A:=1; // + 5 chars for initialization = 16 chars

Use set data types and their operators

If ordering isn't important, then use sets instead of arrays or lists for more concise statements. Unfortunately you are limited to a maximum of 256 elements in a set

+  The union of two sets
*  The intersection of two sets
-  The difference of two sets
=  Tests for identical sets
<> Tests for non-identical sets
>= Is one set a subset of another
<= Is one set a superset of another
in Test for set membership of a single element

The in operator is particularly useful when testing if a variable equals any one of possible values. Silly example using in and .. (the range operator):

// expensive:
if ( A = 1 ) or ( A = 2 ) or ( A = 3 ) or ( A = 6 ) then ...;
if ( A > 0 ) and ( A < 4 ) or ( A = 6 ) then ...;

// better:
if A in [ 1 .. 3, 6 ] then ...;


Shantae Dance Matching In the original Shantae game, there are transformation dances that you have to input in time using the D-Pad, A, and B. If you complete a predefined sequence while dancing, you will transform into the corresponding form (or teleport or heal). Your task is to output the corresponding effect when given an input. The catch is that you may get extraneous dance moves in the input, both before and after, and there may not even be a dance in the input.

The Dances

Using UDLRAB for dance moves:

Monkey: DR
Elephant: DL
Spider: DA
Harpy: DB
Tinkerbat: DUU
Heal: DUA
Scuttle Town: DULR
Water Town: DURLAB
Oasis Town: DURRBA
Zombie Caravan: DULLBA
Bandit Town: DUBLBR

Coding

Input: a sequence of dance moves. This can contain Up, Down, Left, Right, B, A, and Wait values. Use any convenient encoding.

Output: a value corresponding to the first matching dance in the sequence or a distinct value if there is no match. You can encode this in any convenient way.

Examples

Using . for waiting:

DR → Monkey
UUU.DLUAB → Elephant
L.DDBALL → Harpy
LRLRDURURLAB → No match
DUBLBR → Bandit Town
DURLBA → No match
DDUDR → Monkey
RLAB → No match
.DUUBBB → Tinkerbat
DADRDL → Spider
.DURRBADR → Oasis Town
DURR.BA → No match

Other Rules/Notes

Standard rules on loopholes and IO methods apply
Describe your encoding for dance moves and matching dances.
There may be more than one dance in the input. If that is the case, match only the first one that appears in the input.
Waiting interrupts dances.

JavaScript (ES6),  92 88 61  59 bytes
Saved 2 bytes thanks to a suggestion from @tsh
Expects UdLRAB for the dance moves and . for waiting. Outputs either undefined if there's no match, or the sequence of the matching dance (e.g. dR for Monkey or dURLAB for Water Town).

s=>(/d([A-R]|U(U|A|LR|RLAB|RRBA|LLBA|BLBR))/.exec(s)||0)[0]

Try it online!
or Try it with enhanced output


Programming Less-Than, Greater-Than and Equal-To functions using Restricted Source I'm currently working with a branchless language which does not have native Less-Than, Greater-Than or Equal-To functions. I do however have min, max and abs functions and standard arithmetic (+, -, / and *) available to me.
I'd like to create these three functions (as L(a, b), G(a, b) and E(a, b) respectively, which will output 0 for false and 1 for true. So, for example, L(3, 7) would return 1 for true whereas G(3, 7) would return 0 for false, and E(3, 7) would also return 0, etc.
The min and max functions only allow you to pass two parameters, a and b, and then spits out the respective minimum or maximum of the two parameters. The abs function takes the one parameter and returns the absolute value.
I've postulated that given that the min(a, b) is equivalent to:
L(a,b) * a + (1 - L(a,b)) * b
It would stand to reason that:
L(a,b) = (min(a,b) - b) / (a - b)
and similarly:
max(a,b) = G(a,b) * a + (1 - G(a,b)) * b
therefore:
G(a,b) = (max(a,b) - b) / (a - b)
But this is where I get stumped because, I'm not sure how to account for the possibility of a-b equalling 0 in both instances, which as a result stumps me on how to approach the E(a, b) function.
So my question is this... Given that I only currently have access to basic arithmetic functions as well as min(a,b), max(a,b) and abs(a), and because of the language being branchless (therefore no loops), is there a way to programmatically account for the a-b divide-by-zero issue such that if I do have a scenario where a == b that these functions can return zero for either L() or G(), otherwise output the original equations I have derived, and also be able to provide code for E(a, b)?
Given that this is fairly generic (hey, I've written it in psuedocode!) I'd appreciate some insight on how to proceed. In this case, the solution needs to work with both integers as well as floats.
Context: This is research for a personal project I'm working on relating to binary registers, thus the need for 1's and 0's for output and I'm kinda stuck at this point.

Integers and round-to-zero integer division
// 1 if x >= y, 0 otherwise
GE(x, y) = (x - y + 1) / (abs(x - y) + 1)
LE(x, y) = GE(y, x)
E(x, y) = GE(x, y) * LE(x, y)
L(x, y) = LE(x, y) - E(x, y) = 1 - GE(x, y)
G(x, y) = GE(x, y) - E(x, y) = 1 - LE(x, y)

If x - y is negative, x - y + 1 has smaller magnitude than abs(x - y) + 1, so the division rounds to 0.
If x - y is zero or higher, x - y + 1 is the same as abs(x - y) + 1, so the result is 1.
Integers and floored integer division
GE(x, y) = (x - y + abs(x - y) + 1) / (abs(x - y) * 2 + 1)

If x - y is negative, the numerator is fixed at 1, but the denominator is at least 3. Therefore the result is zero.
If x - y is zero or positive, the numerator and the denominator are the same, so the result is 1.
Floating-point numbers
MarcMush pointed out a possible use of eps, the smallest representable number greater than 0. GE can be implemented for floating-point numbers using it:
GE(x, y) = (max(x - y, -eps) + eps)/(abs(x - y) + eps)

I haven't found any way without eps or the floor function. (If floor is available, flooring the second solution works for floats.) tsh pointed out that we can't get a (true) discontinuous function from a bunch of continuous functions, so I'm pretty sure it is impossible without eps or an additional built-in that provides discontinuity.
Assuming an IEEE floating-point representation, the solution above is expected to give exact results (exactly 0 or exactly 1) for all non-NaN, non-infinite floating-point values of x and y.


Was it Really Canada Day? July 1st is Canada day (yay Canada)! Or is it?  It seems that the Wikipedia page for this day has a lot of Canada related content, but is there another day which is more Canadian?

Your task is to write a program or function which takes a date (month and day) as input and returns or outputs the number of mentions of "Canada" on the Wikipedia page for the inputed date.
Some rules:

Dates may be input in any reasonable format of your choice
Your submission must pull data from the url en.wikipedia.org/wiki/Month_Day.
Only "Canada" must be searched for and counted included substrings, and only in title case. "Canadian" does not count, however "Canada's" does count. As long as the exact, case-senstitive text "Canada" exists within a string, it is a match
Contents of the page are considered anything within the corresponding .html file (i.e. what shows up if you download as page as a .html and open it in Notepad)
Result may be output to STDOUT, returned, or displayed in any other reasonable manner

Test Cases:

July 1 => 34
May 14 => 1
Oct 31 => 2
July 4 => 2

This is code golf, so shortest submission wins

(As an unrewarded bonus, I'm interested to see what the day with the highest count is)

Bash, 43 42 40 bytes

curl -L enwp.org/$@|grep -o Canada|wc -l

Uses curl, grep, and wc to count occurrences of "Canada" in specified webpage. Like the other answers, input is given in the format July_1. This is my first time posting on the Code Golf SE and I'm not quite familiar with all of the rules. Any feedback would be most welcome.

Didn't realize that output to STDERR is traditionally ignored. Thanks for the 3 bytes, Dennis!


Can I Sp|Lit this wo|Rd? Note that this is similar to my other challenge, but it is widened to be similar to most challenges (input -> truthy/falsey), instead of asking you all to brute force something. If this makes it a dupe, let me know, but I posted it on Sandbox and asked on chat, and didn't get any negative responses.

Input

Input will be a "word" consisting of a-z, A-Z, -, and '. The case is important. Instead of my previous challenge, where you run through all permutations, in this challenge, you will be given a permutation. Your program's response on invalid input does not matter. Input can be taken in reasonable text input formats, and can contain a trailing newline if required.

Output

Output will be a standard truthy/falsey values on if the permutation can be split in half. A permutation can be split in half if the width values (see below) of one half of the word equal the point values of the other half, or if the same is true if the middle word is removed. Trailing newlines allowed if required.

Please note that "half" does not mean that you have moved halfway into the string. "Half" means that the points on both sides are equal.

Examples:

W is 5 points. i is 1 point. Splitting the permutation Wiiiii in half will result in W | iiiii, with 5 points on each side of the |.

T is 3 points. Splitting the permutation TTTT in half will result in TT | TT, with 6 points on each side of the |.

w is 4 points. a is 3 points. Splitting the permutation waw in half will result in w (a) w, with 5.5 points on each side. The points from a are distributed to both sides, as a is split in half.

See the test cases for more clarification.

Letter Scores

Width  Characters
1      i l I '
2      f j r t -
3      a b c d e g h k n o p q s u v x y z
4      m w A B C D E F G H J K L N O P Q R S T U V X Y Z
5      M W

Test Cases

( ) indicate that the permutation can be split if the character inside the parantheses is cut in half. | indicates that the permutation can be split in between those two letters.

Input : Output : Visualization

a : truthy : (a)
ab : truthy : a|b
Ab : falsey
AB : truthy : A|B
r- : truthy : r|-
iiiiw : truthy : iiii|w
iiiiiiW : truthy : iiiii(i)W
STEPHEN : truthy : STE(P)HEN
STEphen : truthy : STE|phen
STEpheN : falsey
splitwoRdS : truthy : splitw|oRdS

And here's a visualization for splitwoRdS:

s p l i t w | o R d S
3 3 1 1 2 4   3 4 3 4

Jelly, 79 bytes

“¡-Ị’b26
“µııẈḟ(µ⁹\fy¦°Ẓ=ȮH@Q0Ẋƈẏ9Ė=ẹṬɗƇ’ðœ?øØa;ØA;⁾'-ð,ø5Rx¢
¢yHx2+\©ð_ø®ṪHµẠ¬

Try it online!


Scramble a Megaminx! Scramble a Megaminx!
A megaminx is a dodecahedral version of the familiar Rubik's cube. Since 2008, the World Cube Association uses Stefan Pochmann's megaminx scrambler. The scrambles look like this:
R-- D++ R++ D-- R++ D-- R++ D++ R-- D-- U'
R++ D-- R++ D-- R-- D++ R-- D-- R-- D-- U'
R++ D++ R-- D++ R++ D++ R++ D++ R-- D++ U
R-- D-- R++ D++ R++ D++ R-- D++ R++ D++ U
R-- D++ R++ D-- R++ D-- R++ D++ R++ D++ U
R++ D++ R++ D++ R-- D-- R-- D-- R-- D-- U'
R-- D++ R-- D++ R++ D++ R++ D++ R++ D++ U

A scramble has seven lines. Each line has 10 R and D moves, starting with R and alternating R and D moves. Following each letter is randomly chosen direction ++ or -- with equal probability. At the end of the line is randomly chosen with equal probability U (trailing space form U  allowed) or U'. A trailing newline at the end of the output is permitted.
Your code must take no input and must produce a random scramble.

Ruby, 73 71 bytes
Saved two bytes thanks to @vrintle (one directly and another with further golfing)

77.times{|i|$><<(~i%11>0?:RD[i%2]+'+-'[rand 2]*2+' ':?U+?'*rand(2)+$/)}

Try it online!
$/ is the input record separator, which is a newline by default.

In Ruby 2.7 (newer than the version on TIO), we get 70 bytes using numbered block parameters:
77.times{$><<(~_1%11>0?:RD[_1%2]+'+-'[rand 2]*2+' ':?U+?'*rand(2)+$/)}


Show off your tree analysing toolbox As a programmer or computer scientist one might encounter quite a lot of trees - of course not the woody growing-in-the-wrong-direction kind, but the nice, pure mathematical kind:

  *<- root (also a node)
 /|\<- edge
* * *<- inner node
|  / \
* *   *<- leaf (also a node)
  |
  *

Naturally over time we all have put together our own small handy toolbox to analyse such trees as we encounter them, right?
Now is the time to show it off!

Task

The toolbox must include the following functions:

size: The number of nodes in the tree.
depth: The number of edges on the longest path from the root to any leaf.
breadth: The number of leaves.
degree: The maximum number of child nodes for any node.

You have to submit a program or function for each of the tools, however they might share subroutines (e.g. parsing) which then have to be submitted only once. Note that those subroutines need to be full programs or functions too.

Input Format

The trees can be given in any reasonable format capturing the structure, e.g. the tree

  *
 / \
*   *

could be represented through parentheses (()()), lists of lists [[],[]], or data structures with a constructor T[T[],T[]].
However not through linearisation [2,0,0] or a format like (size, depth, breath, degree, whatever-else-is-needed-to-make-this-format-unique-for-every-tree).
Generally speaking, your tree format should not contain numbers.

Output Format

A natural number for each of the properties described above.

Scoring

Lowest code in bytes for the 4 functions in every language wins, thus I will not accept an answer.

Feel free to provide additional tree tools like fold, isBinaryTree, preLinearise, postLinearize, or whatever you like. Of course those don't have to be included in the byte count.

Examples

First the tree is given in the sample formats from above, then the results of the functions as (size, depth, breadth, degree).

()
[]
T[]
(1,0,1,0)

(()())
[[],[]]
T[T[],T[]]
(3,1,2,2)

((())()((())()))
[[[]],[],[[[]],[]]]
T[T[T[]],T[],T[T[T[]],T[]]]
(8,3,4,3)

((()())((())()((())()))(()())(()))
[[[],[]],[[[]],[],[[[]],[]]],[[],[]],[[]]]
T[T[T[],T[]],T[T[T[]],T[],T[T[T[]],T[]]],T[T[],T[]],T[T[]]]
(17,4,9,4)

((((((((()))))))))
[[[[[[[[[]]]]]]]]]
T[T[T[T[T[T[T[T[T[]]]]]]]]]
(9,8,1,1)

(((((((()()))((()()))))((((()()))((()()))))))((((((()()))((()()))))((((()()))((()())))))))
[[[[[[[[],[]]],[[[],[]]]]],[[[[[],[]]],[[[],[]]]]]]],[[[[[[[],[]]],[[[],[]]]]],[[[[[],[]]],[[[],[]]]]]]]]
T[T[T[T[T[T[T[T[],T[]]],T[T[T[],T[]]]]],T[T[T[T[T[],T[]]],T[T[T[],T[]]]]]]],T[T[T[T[T[T[T[],T[]]],T[T[T[],T[]]]]],T[T[T[T[T[],T[]]],T[T[T[],T[]]]]]]]]
(45,7,16,2)

Ruby, 122 110 bytes

f=->s{->t{t.to_s.scan(s).size}}
s=f[?[]
d=->t{[-1,*t.map(&d)].max+1}
b=f['[]']
g=->t{([t.size]+t.map(&g)).max}

Inspired by Neil's JavaScript solution. d and g are just translations from his JS to Ruby. For s and b I'm using string conversion tricks.

Shaved a few bytes off of s and b by adding the helper f, and a few more byte off of d and g thanks to Jordan.


Fully parenthesize expressions Today your challenge is to produce all possible full parenthesizations of an expression.

Your input is a single line of printable ASCII containing one or more terms separated by operators. The input might also contains spaces - you must ignore these. A term is [a-zA-Z0-9], an operator is [^ ()a-zA-Z0-9]. You may assume that the input is always valid.

Output all possible ways to fully parenthesize the given expression, separated by newlines with an optional trailing newline.

Do not:

Parenthesize terms - only parenthesize around operators.
Reorder the terms.
Output any spaces.

Example input/output:

N
N

a * b
(a*b)

x_x_0
(x_(x_0))
((x_x)_0)

a * b|c|d
(a*(b|(c|d)))
(a*((b|c)|d))
((a*b)|(c|d))
((a*(b|c))|d)
(((a*b)|c)|d)

Smallest code in bytes wins.

JavaScript (ES6), 208 197 bytes

s=>((q=x=>x.map((_,i)=>(a=[...x.slice(0,i*=2),p="("+x[i]+x[++i]+x[++i]+")",...x.slice(i+1)],x[i]?a[1]?q(a):r.push(p):0)))([...s.replace(/ /g,o="")],r=[]),r.map((l,i)=>r.indexOf(l)(                                  // s = input string
  (q=x=>                              // q = parenthesise array function
    x.map((_,i)=>(
      a=[                             // a = p with parenthesised pair of terms
        ...x.slice(0,i*=2),
        p="("+x[i]+x[++i]+x[++i]+")", // parenthesise and join 2 terms and an operator
        ...x.slice(i+1)
      ],
      x[i]?a[1]                       // make sure the loop is not over
        ?q(a)                         // check next level of permutations
        :r.push(p)                    // add the permutation to the results
      :0
    ))
  )([...s.replace(/ /g,               // remove spaces and parenthesise all expressions
    o="")],                           // o = output string
    r=[]),                            // r = array of result strings
  r.map(                              // filter out duplicates
    (l,i)=>r.indexOf(l)<i?0:o+=l+`
`
  ),o)                                // return o

Test

Input = <input type="text" id="input" value="a * b|c|d" /><button onclick='results.innerHTML=(

s=>((q=x=>x.map((_,i)=>(a=[...x.slice(0,i*=2),p="("+x[i]+x[++i]+x[++i]+")",...x.slice(i+1)],x[i]?a[1]?q(a):r.push(p):0)))([...s.replace(/ /g,o="")],r=[]),r.map((l,i)=>r.indexOf(l)Go</button>


Standardize the Samples (Compute the z-Score) Given a list of floating point numbers, standardize it.
Details

A list \$x_1,x_2,\ldots,x_n\$ is standardized if the mean of all values is 0, and the standard deviation is 1. One way to compute this is by first computing the mean \$\mu\$ and the standard deviation \$\sigma\$ as
$$ \mu = \frac1n\sum_{i=1}^n x_i \qquad \sigma = \sqrt{\frac{1}{n}\sum_{i=1}^n (x_i -\mu)^2} ,$$
and then computing the standardization by replacing every \$x_i\$ with \$\frac{x_i-\mu}{\sigma}\$.
You can assume that the input contains at least two distinct entries (which implies \$\sigma \neq 0\$).
Note that some implementations use the sample standard deviation, which is not equal to the population standard deviation \$\sigma\$ we are using here.
There is a CW answer for all trivial solutions.

Examples
[1,2,3] -> [-1.224744871391589,0.0,1.224744871391589]
[1,2] -> [-1,1]
[-3,1,4,1,5] -> [-1.6428571428571428,-0.21428571428571433,0.8571428571428572,-0.21428571428571433,1.2142857142857144]

(These examples have been generated with this script.)

R, 51 45 38 37 bytes

Thanks to Giuseppe and J.Doe!

function(x)scale(x)/(1-1/sum(x|1))^.5

Try it online!


Python: I wish I was PHP There's an old story about a stonecutter who was never satisfied with what he was. He wished he could become the sun, and so he was. Blocked by the clouds, he wished to be - and became - a cloud. When the wind blew, he wished himself into being the wind. Stopped by the mountain, he wished to be a mountain, and thus became one. Soon, however, he was being hacked at by a stonecutter, and wished to be a stonecutter.

Similarly, your task is to write a program which is never satisfied with the language it is in. Your program must output a set of regex replacements to turn it into a different language. And so on.

Rules

Write a program in a language of your choice.
The program should output a series of at least two segments. A segment is a bunch of text, separated by semicolons. However, if a semicolon is contained within a regex, such that breaking it up there will result in invalid syntax, it does not separate segments. See the example.
The first segment is a regex pattern to find, and the second segment is the replacement pattern. The third is another "find" pattern, and the fourth is a "replace" pattern, and so on.
Apply the regex patterns to the program. Replace the pattern on the first segment with one on the second; replace the third pattern with the one on the fourth, and so on.
The result should be a program in a different language, which, itself, follows rules 2 to 4.
The languages used must form an infinite, repeating cycle.

For example, Python -> PHP -> C++ -> Python -> PHP -> C++ -> Python -> ...

Your score is the period of the cycle. Ties are broken by shortest initial code length.

In the above example, the score is three.

In each iteration of the cycle, no language may be used more than once.
For rules 5 and 7, compatible languages (C and C++) and different versions of the same language (Python 2 and Python 3) are considered the same.
The programs themselves do not need to repeat.

In the above example, the first and fourth programs may be different.

Any version of regex is acceptable, but the same must be used for all the programs.
The total output for each program may not exceed 100 characters.
Each output must contain instructions to actually change the program. That is, no two consecutive programs in the cycle may be the same.

Example

Python -> Ruby -> Python -> ...

print "uts;Z;rint;uts;Z(?=;Z);rint"

Outputs:

uts;Z;rint;uts;Z(?=;Z);rint

The segments are:

FIND     ;    REPLACE
uts      ;    Z
rint     ;    uts
Z(?=;Z   ;    rint   (breaking the first segment in two would result in invalid syntax)

Applying the regex replacements, in order, gives us:

print "Z;Z;rint;Z;Z(?=;Z);rint"      # replace each "uts" with "Z"
puts "Z;Z;uts;Z;Z(?=;Z);uts"         # replace each "rint" with "uts"
puts "rint;Z;uts;rint;Z(?=;Z);uts"   # replace each "Z" followed by ";Z" with "rint"

Running the last line gives us the instructions to turn this back into Python code.

2 Languages: Python, Ruby; 33 29 bytes

Here is another way to do Python and Ruby, that's a bit shorter than the one in the challenge:

Python:   print'^;puts"^.*?\\42#\\73"#'
prints:   ^;puts"^.*?\42#\73"#

Ruby:     puts"^.*?\42#\73"#print'^;puts"^.*?\\42#\\73"#'
prints:   ^.*?"#;

It shouldn't be too difficult to add PHP into the mix.


Helloellolloloo Worldorldrldldd Make a program that takes the word you input, and adds that word to the back of itself minus its first letter, then repeats until all letters are gone.  For example, cat would become catatt, and hello would become helloellolloloo.

Input
Any of the 26 letters of the English alphabet.  There may be multiple words separated by spaces, and the change should be applied to every word.

Output
The word(s) inputted, with each word put after itself with its first letter missing, and then with its second letter missing, and so on until there are no more letters to add.

More examples:

ill eel outputs illlll eelell

laser bat outputs laserasersererr batatt

darth vader outputs dartharthrththh vaderaderdererr

This is code golf, so the shortest code wins.

Clarification:
You can treat the input or output as a list.  You can separate words using newline instead of space.  You can add a trailing space to the input.

brainfuck, 60 56 bytes

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

Try it online!

Requires a trailing space and prints a leading space. Both of these could be circumvented, but that ends up at 112 bytes.

Explanation

,[  Loop over each byte of input
  Tape: 32 w o r-32 d'
  >++++++++[-<----<++++>>]   Subtract 32 from the character and add 32 to the previous char
  Tape: 32 w o r d-32 0'
  <[>>]<   If the last character was a space
  Tape: 32 w o r d-32 0'
  or
  Tape: 32 w o r d' space-32
  [
    [<]>.   Move to the end of the word and print out the space
    [   Loop over each letter
      [-]    Remove the first letter (initially space)
      >[.>]  Print the rest of the word
      <[<]>  Move back to the first letter
    ]
    Tape: clear
  ]
,]  Get the next byte of input


The number of ways a number is a sum of consecutive primes Given an integer greater than 1, output the number of ways it can be expressed as the sum of one or more consecutive primes.

Order of summands doesn't matter. A sum can consist of a single number (so the output for any prime will be at least 1.)

This is code-golf. Standard rules apply.

See this OEIS wiki for related information and sequences, including the sequence itself OEIS A054845.

Test cases

2 => 1
3 => 1
4 => 0
5 => 2
6 => 0
7 => 1
8 => 1
10 => 1
36 => 2
41 => 3
42 => 1
43 => 1
44 => 0
311 => 5
1151 => 4
34421 => 6

Jelly,  6  5 bytes
-1 thanks to dylnan
ÆRẆ§ċ

A monadic link
Try it online! Or see the test-suite (note the final test case would time out at 60s at TIO).
How?
ÆRẆ§ċ - Link: integer, n
ÆR    - primes from 2 to n inclusive
  Ẇ   - all contiguous substrings
   §  - sum each
    ċ - count occurrences of n


The Swift Make-It-Compile Challenge #4 This is a challenge for the people using Swift 2.0 beta 6, it's not code golf, but it's a programming puzzle so I'm pretty sure this belongs here. The basic idea is: Make it compile. There are more details and a very nicely formatted playground at the Github project. Previous challenges are there as well, all set up to tinker. Solutions are included for the previous challenges, as they all have been solved.

Rules

You can't modify the given lines
You can't insert anything between the given lines
You can't provide custom functions for ones that are in the standard library, according to the syntax-hightlighed picture. This applies to the inverse as well.
The given lines are not allowed to produce a warning (on default warning settings). However the code you append is allowed to produce warnings.
The code may or may not crash at runtime, it only has to compile

The Code

func doIt(inout s: D) {
    if case self = isUniquelyReferenced(&s),
        self.`self` = true where self {
        self.`self` = { [unowned x = [self, 7] as Self] n in
            print(x + n)
        } as () -> ()
    }
}

The Picture

Winner

The first one posting an answer that compiles and conforms to all the rules above wins and gets an entry in the projects Hall of Fame.

EDIT: Hint

Upon submission of Chris Goldsby's 99% solution, he received the following hint:

  The syntax highlighting of

protocol P {
    typealias P
    var p : P { get }
}

I'm posting this answer on behalf of Chris Goldsby who managed to submit a
99% Solution (Gist):
typealias D = NonObjectiveCBase

func ~=(left: Any, right: Bool) -> BooleanType {
    return true
}

func +(left: Any, right: Any) -> String {
    return ""
}

protocol &#128034;: class, BooleanType, ArrayLiteralConvertible {

    var `self` : () -> () { get set }
}

extension &#128034; {

    typealias Element = Any

    internal init(arrayLiteral elements: Any...) {
        self.init()
    }

    //

    func doIt(inout s: D) {
        if case self = isUniquelyReferenced(&s),
            self.`self` = true where self {
            self.`self` = { [unowned x = [self, 7] as Self] n in
                print(x + n)
            } as () -> ()
        }
    }

    //

}

Only the snytax highlighting of D doesn't match. That's remarkable as it is!
100% Solution
EDIT: Two days later he submitted the following full solution, congrats!:
private func ~=(left: Any, right: Bool) -> BooleanType {
    return true
}

private func +(left: Any, right: Any) -> String {
    return ""
}

protocol Challenge4: class, BooleanType, ArrayLiteralConvertible {

    typealias D

    var `self` : () -> () { get set }

    func doIt(inout s: D)
}

private extension Challenge4 where D == NonObjectiveCBase {

    typealias Element = Any

    init(arrayLiteral elements: Any...) {
        self.init()
    }

    //

    func doIt(inout s: D) {
        if case self = isUniquelyReferenced(&s),
            self.`self` = true where self {
            self.`self` = { [unowned x = [self, 7] as Self] n in
                print(x + n)
            } as () -> ()
        }
    }

    //

}


Eat the Chocolate Bar I have a chocolate bar and I need help eating it so you'll be writing a program just to do that.

Explanation

The first line is the input. Examples are separated by an empty line.

7
   ____
 __|__|
|__|__|
|__|__|
|__|__|

6
_______
|__|__|
|__|__|
|__|__|

5
   ____
 __|__|
|__|__|
|__|__|

0

1
   ____
   |__|

Spec

Hopefully the examples clearly specify this challenge but to avoid any possible confusion, here's a spec:

You can have a single optional trailing/leading whitespace

An input of 0 is an empty output.

If the input is even, the top rows looks like:

_______
|__|__|

If it's odd, the top row is:

   ____
   |__|

If it's odd and greater than 1, the top rows are:

  ____
__|__|

The following rows are:

|__|__|

until the number of instances of |__| is the same as the input


Shortest code for key-logger Okay, I propose a shortest-key-logger challenge. As explained by the gentleman at "Are key-logger questions allowed?", strict rules have to be imposed in order to make this challenge valid for PPCG.

The key-logger has to run on Windows, Linux or Mac OSX (any programming language is welcome).
Upon execution, it has to show the message: "I'm gonna log you" (either in a console or using GUI).
The keys that are relevant for logging in this challenge are letters (case is not important) and numbers, all others such as symbols, control keys and whitespace are optional and can be ignored.
All relevant key presses that occur during runtime (even when the application is not in focus) have to be saved in a log file that can be read and verified using any text editor (even an esoteric one, as long as I can verify it using that text editor).

Anyone up for it? Whatdayatink?

Bash, 90 bytes

This works on Ubuntu, and requires evtest. It picks a device that is a keyboard, and saves evtest's output to the file l. If you want a more formatted output, I can do that with more bytes.

echo I\'m gonna log you
sudo evtest /dev/input/by-path/`ls /dev/input/by-path/|grep kbd`>l