Is the question undeleted? Challenge
Given a positive integer, determine whether that number is currently being used to represent a question on PPCG.
The question must not have been removed, but may be open or closed.
The number is the one being used in the URL of the question, such as:

https://codegolf.stackexchange.com/questions/[input]

Note that this questions is tagged stack-exchange-api, but you may not need this to complete the challenge.

Examples

1: Truthy (represents Just Another Perl Hacker)
3: Falsey (was once Solve the Tower of Hanoi, but was removed by a moderator.
127030: Falsey (was once Helping Danny to Maximize his Score, but was removed by the author.)
127147: Truthy (Fastest algorithm to take the product of all subsets)

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

bash, 52 bytes

curl -IL codegolf.stackexchange.com/q/$1|grep 2\ 200

Takes input as a command line argument, and outputs in the form of exit code: 0 or "success" (truthy) for an undeleted question, and 1 or "failure" (falsy) for a nonexistent or deleted question.

It also prints a bunch of junk to STDERR and potentially STDOUT, but this is allowed to be ignored as per meta.

As an explanation, the -I flag to curl sends an HTTP HEAD request (fetch only the headers), and -L will follow redirects (http to https, and then /q to /questions). The full output from the curl command will look something like this:

HTTP/1.1 301 Moved Permanently
Location: https://codegolf.stackexchange.com/q/127030
X-Request-Guid: 1a0b6059-057c-448c-bfc9-a96f1b373abf
Content-Length: 160
Accept-Ranges: bytes
Date: Tue, 20 Jun 2017 04:07:30 GMT
Via: 1.1 varnish
Age: 503
Connection: keep-alive
X-Served-By: cache-itm7423-ITM
X-Cache: HIT
X-Cache-Hits: 1
X-Timer: S1497931651.709631,VS0,VE0
Vary: Fastly-SSL
X-DNS-Prefetch-Control: off
Set-Cookie: prov=933ae4b0-81b0-2b37-e26e-59a0fbb6991a; domain=.stackexchange.com; expires=Fri, 01-Jan-2055 00:00:00 GMT; path=/; HttpOnly

HTTP/2 302
date: Tue, 20 Jun 2017 04:07:31 GMT
content-type: text/html; charset=utf-8
location: https://codegolf.stackexchange.com/questions/127030/helping-danny-to-maximize-his-score
x-frame-options: SAMEORIGIN
x-request-guid: fdcaf556-7ae6-4240-89a1-ace7625f8821
strict-transport-security: max-age=15552000
accept-ranges: bytes
via: 1.1 varnish
age: 0
x-served-by: cache-nrt6132-NRT
x-cache: MISS
x-cache-hits: 0
x-timer: S1497931651.085546,VS0,VE166
vary: Fastly-SSL
x-dns-prefetch-control: off
set-cookie: prov=5e314a4f-0c50-08ef-afa2-9388b37e3b7a; domain=.stackexchange.com; expires=Fri, 01-Jan-2055 00:00:00 GMT; path=/; HttpOnly
cache-control: private
content-length: 204

HTTP/2 404
date: Tue, 20 Jun 2017 04:07:31 GMT
content-type: text/html; charset=utf-8
x-frame-options: SAMEORIGIN
x-request-guid: 3f72afb7-81e8-4e69-a8ad-474534f2abe6
strict-transport-security: max-age=15552000
accept-ranges: bytes
via: 1.1 varnish
age: 0
x-served-by: cache-nrt6132-NRT
x-cache: MISS
x-cache-hits: 0
x-timer: S1497931651.323339,VS0,VE189
vary: Fastly-SSL
x-dns-prefetch-control: off
set-cookie: prov=cede4119-eba5-d799-e376-848e4e457f07; domain=.stackexchange.com; expires=Fri, 01-Jan-2055 00:00:00 GMT; path=/; HttpOnly
cache-control: private
content-length: 42158

Note that the 2\ 200 (equivalent to '2 200') will match the line HTTP/2 200 if it exists (HTTP OK), and it will not match HTTP/2 404 (Not Found) for questions that do not exist. (The inclusion of the 2 is necessary to avoid false positives if some of the other headers happen to contain the sequence 200.)


Find the best immediate move in a "match-3" game Your challenge today is to take input like this:

fbcfbee
ffcabbe
debceec
bccabbe
edcfbcd
daeaafc
eebcbeb

And output the best possible move in a Bejeweled-like game that will match three or more letters, like this (note the capital B and C):

fbcfbee
ffcabbe
deBCeec
bccabbe
edcfbcd
daeaafc
eebcbeb

Full specifications:

The input will be n lines of n lowercase letters each (where n could be any number).
The output will be the best move you could make in a match-3 game, with the two letters you want to swap capitalized.
Matches should have the following priority (in these examples, . indicates a square that doesn't matter):

Five-in-a-row

xxYxx
..X..

Broken five-in-a-row

X..
Yxx
x..
x..

or

.X.
xYx
.x.
.x.

Four-in-a-row

xYxx
.X..

Three-in-a-row

xYx
.X.

You must find the match of the highest priority and output it.
If there are multiple matches of the same priority, you can output any one of them.
There will always be at least one match (your program can break if there are no matches, or do anything you want).
I/O can be in any reasonable format (stdin/out, reading and writing files, function arguments/return values, dialog boxes, etc.) but NOT hardcoded (like x="[insert input here]").
This is code-golf so shortest code in bytes wins. If you use any network access for some reason, all bytes downloaded from the network count against your score.

Python3.4, 772

(Using tabs for indentation, instead of spaces.)

import sys,itertools as I
B=[]
for l in sys.stdin:
    l=l.rstrip()
    B.append(list(l))
Z=len(B[0])
F=T=None
R=range
N=min
X=max
P=I.product
S=0
def C(I,J,K,L):
    global F,T,S
    if K<0 or K>=Z or L<0 or L>=Z: return
    B[I][J],B[K][L]=B[K][L],B[I][J]
    h=v=1
    m=B[K][L]
    for i in R(K+1,N(Z,K+5)):
        if B[i][L]!=m:break
        v+=1
    for i in R(K-1,X(0,K-5),-1):
        if B[i][L]!=m:break
        v+=1
    for j in R(L+1,N(Z,L+5)):
        if B[K][j]!=m:break
        h+=1
    for j in R(L-1,X(0,L-5),-1):
        if B[K][j]!=m:break
        h+=1
    c=X(h,v)*2
    if N(h,v)>=3:c+=N(h,v)
    if c>S:S=c;F=I,J;T=K,L
    B[I][J],B[K][L]=B[K][L],B[I][J]
for i,j in P(reversed(R(Z)),R(Z)):
    for d,e in (1,0),(0,-1),(0,1),(-1,0):
        C(i,j,i+d,j+e)
for i,j in P(R(Z),R(Z)):
    c=B[i][j]
    if (i,j)in(F,T):c=c.upper()
    print(c,end=('',"\n")[j==Z-1])


Cheapo Enigma machine (Robbers) For cops' post, Cheapo Enigma machine (Cops)
A robber's submission consists of a program/function that accepts the output of a cop's code and returns the input for all the outputs provided by that cop's code. (In other words, you must write the inverse function)
You cannot use built-ins that have the sole purpose of hashing or encryption.
Input/Output format
8 bits (0 or 1), or a base-10 integer in range 1-256, 0-255 or -128 to 127. Can use standard I/O or file I/O. Function can also return a value as output. Input and output must belong to the same range (as in, binary, 1-256, 0-255 or -128 to 127), which must also be the same range as that used by the cop.
Scoring
Ratio of the cop's byte count to your byte count. Highest score wins.
You can submit a robber attempt against your own cop code for reference. (Of course this code isn't eligible for winning)
Notification
Please edit the corresponding cop's answer to include your new byte count and the corresponding ratio.

JavaScript by Christoph, 8/25
f=(y,x=0)=>y?f(y/2,x^y):x

(range 0-255)
Sadly, f=(y,x)=>y?f(y/2,x^y):x works for all values except 0.
Technical note
We use y/2 rather than y>>1 to save a byte. This is abusing the fact that any value of y will eventually be rounded to 0 because of arithmetic underflow.


Build a one-word search generator The word BANANA appears exactly once in this word search:

B A N A A N B B
A B A N A B A N
A N A B N N A A
N N B A A A N N
N A A N N N B A
A N N N B A N A
N A A B A N A N
B A N A N B B A

The word search above contains only one occurrence of the word BANANA looking up, down, left, right, or diagonally, but it has lot of similar words, like BANANB, BANNANA, BNANA, etc.

Your job is to build a program that will generate infuriating word searches like this one.

Your program will take as input:

One word, in all capital letters, containing from three to seven unique letters with at least four letters total.
One number, to represent the dimension of the square grid for the word search. The number must be at least the number of letters in the word.

And then, output a word search using only the letters in the word, that contains exactly one occurrence of the input word, and as many infuriators as possible.

An infuriator is defined as a string that has a Damerau-Levenshtein distance of one from the target word and begins with the same letter as the word. For BANANA, this would include words like:

BANBNA, where one of the letters was substituted.
BANNANA or BANAANA, where an extra letter was added.
BANAN, BNANA, where a letter was deleted, but not ANANA, since there's no longer a B.
BAANNA or BANAAN, where two consecutive letters were switched.

When counting infuriators on a word search grid, they may overlap, but you cannot count a large string if it completely contains a smaller string you've already counted, or vice versa. (If you have BANANB, you can't count it again if you've already counted the BANAN or the backwards BNANA inside it.) You also cannot count any strings that completely contain or are completely contained by the target word itself (you cannot count the specific BANAN that is part of BANANA, nor BANANAA or BANANAN.)

Your program will be tested on a specific word list composed of the words that fit the input word requirement (to be given later once I've generated it), on a grid size equal to double the length of the word, and will be scored on the number of infuriators present in each grid. Please post your results for the inputs BANANA 12, ELEMENT 14, and ABRACADABRA 22 for verification.

C++

I wrote this one up today. It is not the most efficient way and does not always generate the most random looking word searches but it gets the job done and it does it relatively quick.

Bonus: Supports Palindromes too!!!

It works by taking input for the word and the size of the word search. It then generates infurators by dropping letters, inserting letters, or flipping letters. It then adds those to the grid as well as the correct word. It then checks all instances of the first letter in every direction for the word. If 1 instance is not found ( 2 for palindromes ) it brute forces the cycle over. It then outputs the word search to console as well as a file.

Here it is at 213 lines of code with whitespace and comments.

#include <fstream>
#include <iostream>
#include <string>
#include <vector>

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

// Keep Track of Coordinates
struct XY {

public:
    int X;
    int Y;
};

// Just in case someone breaks the rules
std::string ToUppercase( const std::string& pWord ) {
    char *myArray = new char[ pWord.size() + 1 ];
    myArray[ pWord.size() ] = 0;
    memcpy( myArray, pWord.c_str(), pWord.size() );

    for ( unsigned int i = 0; i < pWord.size(); i++ ) {
        if ( (int) myArray[ i ] >= 97 && (int) myArray[ i ] <= 122 ) {
            myArray[ i ] = (char) ( (int) myArray[ i ] - 32 );
        }
    }

    return std::string( myArray );
}

// Random number between a max and min inclusively
int RandomBetween( int pMin, int pMax ) {
    return rand() % ( pMax - pMin + 1 ) + pMin;
}

// Find all instances of a character
std::vector<XY> FindHotspots( const std::vector<char> &pWordSearch, char pFirstChar, unsigned int pLength ) {
    std::vector<XY> myPoints;
    for ( unsigned int i = 0; i < pLength; i++ ) {
        for ( unsigned int j = 0; j < pLength; j++ ) {
            if ( pWordSearch[ i * pLength + j ] == pFirstChar ) {
                XY myXY;
                myXY.X = i;
                myXY.Y = j;
                myPoints.push_back( myXY );
            }
        }
    }
    return myPoints;
}

// Searchs each index from specific point in certain direction for word
// True if word is found
bool Found( const std::vector<char> &pWordSearch, const std::string &pWord, int pRow, int pCol, int pX, int pY, int pLength ) {
    for ( unsigned int i = 0; i < pWord.length(); i++ ) {
        if ( pRow < 0 || pCol < 0 || pRow > pLength - 1 || pCol > pLength - 1 )
            return false;
        if ( pWord[ i ] != pWordSearch[ pRow * pLength + pCol ] )
            return false;
        pRow += pX;
        pCol += pY;
    }
    return true;
}

// Goes through all the hotspots and searchs all 8 directions for the word
int FindSolution( const std::vector<char> &pWordSearch, const std::string &pWord, unsigned int pLength ) {
    std::vector<XY> myHotspots = FindHotspots( pWordSearch, pWord[ 0 ], pLength );

    int mySolutions = 0;
    for ( unsigned int i = 0; i < myHotspots.size(); i++ ) {
        if ( Found( pWordSearch, pWord, myHotspots[ i ].X, myHotspots[ i ].Y, 1, 0, pLength ) )
            mySolutions++;
        if ( Found( pWordSearch, pWord, myHotspots[ i ].X, myHotspots[ i ].Y, 1, 1, pLength ) )
            mySolutions++;
        if ( Found( pWordSearch, pWord, myHotspots[ i ].X, myHotspots[ i ].Y, 0, 1, pLength ) )
            mySolutions++;
        if ( Found( pWordSearch, pWord, myHotspots[ i ].X, myHotspots[ i ].Y, -1, 1, pLength ) )
            mySolutions++;
        if ( Found( pWordSearch, pWord, myHotspots[ i ].X, myHotspots[ i ].Y, -1, 0, pLength ) )
            mySolutions++;
        if ( Found( pWordSearch, pWord, myHotspots[ i ].X, myHotspots[ i ].Y, -1, -1, pLength ) )
            mySolutions++;
        if ( Found( pWordSearch, pWord, myHotspots[ i ].X, myHotspots[ i ].Y, 0, -1, pLength ) )
            mySolutions++;
        if ( Found( pWordSearch, pWord, myHotspots[ i ].X, myHotspots[ i ].Y, 1, -1, pLength ) )
            mySolutions++;
    }
    return mySolutions;
}

// Generate words that are similar
//
// 1. Word with last character same as first
// 2. Word with 1 character removed
// 3. Word with 1 character added
std::vector<std::string> GenerateInfurators( const std::string &pWord ) {
    std::vector<std::string> myInfurators;
    for ( unsigned int i = 0; i < pWord.size() / 2; i++ ) {
        char myReplace = '0';
        do {
            myReplace = pWord[ RandomBetween( 0, pWord.size() - 1 ) ];
        } while ( myReplace == pWord[ pWord.size() - 1 ] );
        myInfurators.push_back( pWord.substr( 0, pWord.size() - 2 ) + myReplace );
    }

    for ( unsigned int i = 1; i < pWord.size() - 2; i++ ) {
        myInfurators.push_back( pWord.substr( 0, i ) + pWord.substr( i + 1 ) );

        std::string myWord = pWord;
        myInfurators.push_back( myWord.insert( i, 1, pWord[ i - 1 ] ) );
    }

    return myInfurators;
}

// Adds word in random position in word search
void AddWordRandomly( std::vector<char> &pWordSearch, const std::string &pWord, unsigned int pLength ) {
    int myXDirec = 0;
    int myYDirec = 0;
    do {
        myXDirec = RandomBetween( -1, 1 );
        myYDirec = RandomBetween( -1, 1 );
    } while ( myXDirec == 0 && myYDirec == 0 );

    int myRow = 0;
    if ( myXDirec == 0 ) {
        myRow = RandomBetween( 0, pLength - 1 );
    } else if ( myXDirec > 0 ) {
        myRow = RandomBetween( 0, pLength - pWord.size() - 1 );
    } else {
        myRow = RandomBetween( pWord.size(), pLength - 1 );
    }

    int myCol = 0;
    if ( myYDirec == 0 ) {
        myCol = RandomBetween( 0, pLength - 1 );
    } else if ( myYDirec > 0 ) {
        myCol = RandomBetween( 0, pLength - pWord.size() - 1 );
    } else {
        myCol = RandomBetween( pWord.size(), pLength - 1 );
    }

    for ( unsigned int i = 0; i < pWord.size(); i++ ) {
        pWordSearch[ myRow * pLength + myCol ] = pWord[ i ];
        myRow += myXDirec;
        myCol += myYDirec;
    }
}

// Checks for palindromes
bool WordIsPalindrome( const std::string &pWord ) {
    for ( unsigned int i = 0; i < pWord.size(); i++ ) {
        if ( pWord[ i ] != pWord[ pWord.size() - 1 - i ] )
            return false;
    }
    return true;
}

int main() {
    // Handle all input
    std::string myWord;
    std::cin >> myWord;
    myWord = ToUppercase( myWord );

    std::string myStrLength;
    std::cin >> myStrLength;
    unsigned int mySideLength = std::stoi( myStrLength );

    // Setup variables
    // New time seed
    // Generate infurators
    // Add words
    std::vector<char> myWordSearch;
    srand( ( unsigned int ) time( 0 ) );
    std::vector<std::string> myWords = GenerateInfurators( myWord );
    myWords.push_back( myWord );

    bool myWordIsPalindrome = WordIsPalindrome( myWord );

    // Brute force words until 1 instance only
    // 2 instances for palindromes
    do {
        for ( unsigned int i = 0; i < mySideLength * mySideLength; i++ ) {
            myWordSearch.push_back( myWord[ RandomBetween( 0, myWord.size() -1 ) ] );
        }

        for ( unsigned int j = 0; j < 10; j++ ) {
            for ( unsigned int i = 0; i < myWords.size() - 1; i++ ) {
                AddWordRandomly( myWordSearch, myWords[ i ], mySideLength );
            }
        }
        AddWordRandomly( myWordSearch, myWord, mySideLength );
    } while ( ( FindSolution( myWordSearch, myWord, mySideLength ) != 1 && !myWordIsPalindrome ) ||
            ( FindSolution( myWordSearch, myWord, mySideLength ) != 2 && myWordIsPalindrome ) );

    // Output to console && text file
    std::ofstream myFile( "word_search.txt" );
    for ( unsigned int i = 0; i < mySideLength; i++ ) {
        for ( unsigned int j = 0; j < mySideLength; j++ ) {
            myFile << myWordSearch[ i * mySideLength + j ] << "";
            std::cout << myWordSearch[ i * mySideLength + j ] << " ";
        }
        myFile << "\n";
        std::cout << "\n" << std::endl;
    }
    myFile.close();

    system( "pause" );
    return 0;
}

I am far from a C++ expert so I'm sure there's places where this code could be improved but I was happy with how it ended up.

Here's the outputs.

BANANA-12:
BBBBBABANABB
BBANAAANANBB
BABAANABBABA
BNAANAAANABN
BANNNNNANBBB
AANABNNANNAA
NAANANAAAABA
ANNNBAANNNBN
ABABNAANABNA
BNNANNAAANNB
BBABAAANBBAB
BBANANNBBABB

ELEMENT-14:
MLELEMEEETNEET
EMTTELTEETELEE
EMNNELEENLNTEL
TLTNEEMEEELMTM
TLEMLNLMEEEETE
TTEEEEEENLNTLE
NETNENEEMTTMEN
ELELTETEEMNMEE
MTEEMTNEEEENEM
ELENEEEMMENNME
ELLEELELTMLETL
ETLTNEMEEELELE
EELTLLLLLMNEEE
EEEELEMNTLEEEE

ABRACADABRA-22:
ACRABAACADABBADBRRAAAA
BBABAABAARBAAAARBAABAA
RARRARBAAABRRRRAAABBRA
DABARRARABBBBABABARABR
BRBACABBAAAABAARRABDAD
ABRRCBDADRARABAACABACR
DCAAARAABCABRCAAAARAAA
AAABACCDCCRACCDARBADBA
CAARAAAAAACAAABBAACARA
ADRABCDBCARBRRRDAABAAR
RARBADAARRAADADAABAAAB
BBRRABAABAAADACACRBRAA
ARBBBDBRADCACCACARBABD
CAARARAAAACACCDARARAAA
ARABADACRARCDADABADBBA
RARAADRRABADBADAABBAAA
RAAAABBBARRDCAAAAAARRA
BABBAAACRDBABCABBBRAAR
AARARAARABRAAARBRRRAAB
BAAAARBRARARACAARAAAAA
ADCBBABRBCBDBRARAARBAA
AARBADAAAARACADABRAABB

Bonus: RACECAR-14:
RRACEARCECARAR
RRRRRRRRRCARAR
RARRAACECARAAA
CCACECRREAECAR
RECEAEEAAECEAE
RCRRREACCCCEAR
RRRARCERREERRR
CCARAAAAECCARC
ECECARRCCECCRR
CARRRACECCARAC
ACRACCAAACCCAR
ARRECRARRAAERR
RRCRACECARRCRR
RRRRACECRARRRR

I may update this to generate slightly more "random" looking word searches.


Connect 4: Spot the Fake! The bank has been broken into, and all the local mafia thugs have an unusual alibi: they were at home playing Connect 4!  In order to assist with the investigation, you are asked to write a program to validate all the Connect 4 boards that have been seized in order to check that the positions are indeed positions from a valid Connect 4 game, and have not been hastily put together as soon as the police knocked on the door.

The rules for connect 4: players R and Y take it in turns to drop tiles of their colour into columns of a 7x6 grid.  When a player drops a tile into the column, it falls down to occupy the lowest unfilled position in that column.  If a player manages to get a horizontal, vertical or diagonal run of four tiles of their colour on the board, then they win and the game ends immediately.

For example (with R starting), the following is an impossible Connect 4 position.

| | | | | | | |
| | | | | | | |
| | | | | | | |
| | |R| | | | |
| | |Y| | | | |
|R| |Y| | | | |

Your program or function must take in a Connect 4 board and return either

A falsy value, indicating that the position is impossible or
A string of numbers from 1 to 7, indicating one possible sequence of moves leading to that position (the columns are numbered 1 to 7 from left to right, and so the sequence 112, for example, indicates a red move in column 1, followed by a yellow move in column 1, followed by a red move in column 2).  You may choose a column-numbering other than 1234567 if you like, as long as you specify in your solution.  If you want to return the list in some other format; for example as an array [2, 4, 3, 1, 1, 3] then that is fine too, as long as it is easy to see what the moves are.

You can choose to read the board in in any sensible format including using letters other than R and Y for the players, but you must specify which player goes first.  You can assume that the board will always be 6x7, with two players.

You may assume that the positions you receive are at least physically possible to create on a standard Connect 4 board; i.e., that there will be no 'floating' pieces.  You can assume that the board will be non-empty.

This is code golf, so shortest answer wins.  Standard loopholes apply.

Examples

| | | | | | | |
| | | | | | | |
| | | | | | | |
| | | | | | | | --> 1234567 (one possible answer)
| | | | | | | |
|R|Y|R|Y|R|Y|R|

| | | | | | | |
| | | | | | | |
| | | | | | | |
| | |R| | | | | --> false
| | |Y| | | | |
|R| |Y| | | | |

| | | | | | | |
| | |Y| | | | |
| | |R| | | | |
| | |Y| | | | | --> 323333 (only possible answer)
| | |R| | | | |
| |Y|R| | | | |

| | | | | | | |
| | | | | | | |
| | | | | | | |
| | | | | | | | --> false (this is the position arising after
| |Y|Y|Y|Y| | |     the moves 11223344, but using those moves
| |R|R|R|R| | |     the game would have ended once R made a 4)

| | | | | | | |
| | | | | | | |
|Y| | | | | | |
|R|Y| | | | | | --> 2134231211 (among other possibilities)
|R|R|Y| | | | |
|Y|R|R|Y| | | |

| | | | | | | |
| | | | | | | |
|Y| | | | | | |
|R|Y| | | | | | --> false (for example, 21342312117 does not
|R|R|Y| | | | |     work, because Y has already made a diagonal 4)
|Y|R|R|Y| | |R|

| | | | | | | |
| | | | | | | |
| | | | | | | |
| | | | | | | | --> 112244553 or similar
|Y|Y| |Y|Y| | |
|R|R|R|R|R| | |

JavaScript (ES6),  202 194 187  183 bytes
Takes input as a matrix with \$2\$ for red, \$4\$ for yellow and \$0\$ for empty. Returns a string of 0-indexed moves (or an empty string if there's no solution). Reds start the game.

m=>(p=[...'5555555'],g=(c,s=o='')=>/2|4/.test(m)?['',0,2,4].some(n=>m.join``.match(`(1|3)(.{1${n}}\\1){3}`))?o:p.map((y,x)=>m[m[y][x]--^c||p[g(c^6,s+x,p[x]--),x]++,y][x]++)&&o:o=s)(2)

Try it online!
How?
The recursive function \$g\$ attempts to replace all \$2\$'s and \$4\$'s in the input matrix with \$1\$'s and \$3\$'s respectively.
While doing so, it makes sure that we don't have any run of four consecutive odd values until all even values have disappeared (i.e. if a side wins, it must be the last move).
The row \$y\$ of the next available slot for each column \$x\$ is stored in \$p[x]\$.
Commented
m => (                            // m[] = input matrix
  p = [...'5555555'],             // p[] = next row for each column
  g = (c,                         // g = recursive function taking c = color,
          s = o = '') =>          //     s = current solution, o = final output
    /2|4/.test(m) ?               // if the matrix still contains at least a 2 or a 4:
      ['', 0, 2, 4]               //   see if we have four consecutive 1's or 3's
      .some(n =>                  //   by testing the four possible directions
        m.join``                  //   on the joined matrix, using
        .match(                   //   a regular expression where the number of characters
          `(1|3)(.{1${n}}\\1){3}` //   between each occurrence is either 1, 10, 12 or 14
        )                         //   (horizontal, diagonal, vertical, anti-diagonal)
      ) ?                         //   if we have a match:
        o                         //     abort and just return the current value of o
      :                           //   else:
        p.map((y, x) =>           //     for each cell at (x, y = p[x]):
          m[                      //
            m[y][x]--             //       decrement the value of the cell
            ^ c ||                //       compare the original value with c
            p[                    //       if they're equal:
              g(                  //         do a recursive call with:
                c ^ 6,            //           the other color
                s + x,            //           the updated solution
                p[x]--            //           the updated row for this column
              ),                  //         end of recursive call
              x                   //         then:
            ]++,                  //         restore p[x]
            y                     //         and restore m[y][x]
          ][x]++                  //         to their initial values
        ) && o                    //     end of map(); yield o
    :                             // else:
      o = s                       //   we've found a solution: copy s to o
)(2)                              // initial call to g() with c = 2


Partitioning the grid into triangles Goal
The goal of this challenge is to produce a function of n which computes the number of ways to partition the n X 1 grid into triangles where all of the vertices of the triangles are on grid points.
Example
For example, there are 14 ways to partition the 2 x 1 grid, so f(2) = 14 via the following partitions
where the partitions have 2, 2, 2, 2, 4, and 2 distinct orientations respectively.
Scoring
This is code-golf, so shortest code wins.

Haskell, 60 55 54 52 bytes

After a drawing and programming a lot of examples, it occured to me that this is the same as the problem of the rooks:

  On a \$(n+1) \times (n+1)\$ chessboard, how many ways are there for a rook to go from \$(0,0)\$ to \$(n,n)\$ by just moving right \$+(1,0)\$ or up \$+(0,1)\$?

Basically you have the top and the bottom line of the \$1 \times n\$ grid. Now you have to fill in the non-horizontal line. Each triangle must have two non-horizontal lines. Whether one of its sides is part of the top or the bottom line corresponds to the direction and length you'd go in the rooks problem. This is OEIS A051708. As an illustration of this correspondence consider following examples. Here the top line corresponds to up-moves, while the bottom line corresponds to right-moves.

Thanks @PeterTaylor for -6 bytes and @PostLeftGarfHunter for -2 bytes!

b 0=1
b 1=2
b n=div((10*n-6)*b(n-1)-9*(n-2)*b(n-2))n

Try it online!


Vowels up, consonants down Challenge

You will be given a string that can contain lowercase letters, uppercase letters, or spaces. You have to turn the vowels (a, e, i, o, u) in the string to upper case and consonants to lower case. This applies whether or not the letter was originally upper case or lower case. Spaces remain as is. Note that "y" is a consonant.

Examples

Hello World -> hEllO wOrld
abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVXWYZ -> AbcdEfghIjklmnOpqrstUvwxyz AbcdEfghIjklmnOpqrstUvxwyz

Info

The input string can contain letters A to Z, lowercase or uppercase, and spaces.

Input

The string

Output

The formatted string (Vowels uppercase and consonants lowercase).

JavaScript (Node.js),  55 ... 46  45 bytes
Saved 1 byte thanks to @KevinCruijssen
s=>Buffer(s).map(c=>c^(c^~68174912>>c)&32)+''

Try it online!
How?
The constant \$68174912\$ is a bitmask describing the positions of the vowels:
00000100000100000100010001000000
     v     v     v   v   v
zyxwvutsrqponmlkjihgfedcba`_^]\[

As per the ECMAScript specification, the following expression:
~68174912 >> c & 32

is equivalent to:
~68174912 >> (c % 32) & 32

and therefore evaluates to \$32\$ for a consonant or \$0\$ for a vowel, no matter the case of \$c\$.
Commented
s =>                   // s = input string
  Buffer(s)            // turn s into a buffer
  .map(c =>            // for each ASCII code c:
    c ^                //   change the case if:
      ( c              //     c is not in lower case
        ^              //     XOR
        ~68174912 >> c //     c is a consonant
      ) & 32           //
  ) + ''               // end of map(); coerce back to a string


Convert a string of digits from words to an integer Convert a string containing digits as words into an integer, ignoring leading zeros.

Examples

"four two" -> 42.
"zero zero zero one" -> 1.

Assumptions

Submissions can assume that:

The input string is comprised of space-separated digit words.
All words are valid (in the range "zero".."nine") and lowercase. Behaviour for empty input is undefined.
The input string always represents an unsigned number within the range of int and is never an empty string.

Scoring

Answers will be scored in bytes with fewer bytes being better.

PHP, 74 bytes

foreach(explode(' ',$argn)as$w)$n.='793251_8640'[crc32($w)%20%11];echo+$n;

Try it online!

Tried to get a solution which doesn't copy existing answers. I get cyclic redundancy checksum polynomial of 32-bit lengths (crc32) for each word and then do a mod 20 and mod 11 on it to get mixed up unique values from 0 to 10 (missing 6) for each digit. Then using that unique value I find the actual digit.

| Word  | CRC32      | %20 | %11 | Equivalent digit |
|-------|------------|-----|-----|------------------|
| zero  | 2883514770 | 10  | 10  | 0                |
| one   | 2053932785 | 5   | 5   | 1                |
| two   | 298486374  | 14  | 3   | 2                |
| three | 1187371253 | 13  | 2   | 3                |
| four  | 2428593789 | 9   | 9   | 4                |
| five  | 1018350795 | 15  | 4   | 5                |
| six   | 1125590779 | 19  | 8   | 6                |
| seven | 2522131820 | 0   | 0   | 7                |
| eight | 1711947398 | 18  | 7   | 8                |
| nine  | 2065529981 | 1   | 1   | 9                |

Another 74 bytes CRC32 alternative using %493%10: Try it online!

Another 74 bytes CRC32 alternative using %2326%11: Try it online!

PHP, 74 bytes

foreach(explode(' ',$argn)as$w)$n.=strpos(d07bfe386c,md5($w)[21]);echo+$n;

Try it online!

Another alternative with same length, takes 22nd character in the md5 of the word (only character which gives a unique value for each word) and then uses that character to map to a digit.


Count sum of all digits This challenge is to write a program or script which counts the sum of all digits within the integers from 1 up to and including a given number.

Input, one positive integer.
Output, the sum of digits in that number and all smaller numbers.

Examples:

Input: 5
Integer Sequence: 1, 2, 3, 4, 5
Sum of Digits: 1 + 2 + 3 +4 + 5 = 15

Input: 12
Integer Sequence: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12
Sum of Digits: 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 1 + 0 + 1 + 1 + 1 + 2 = 51

To be clear, this is to count a sum of the digits - not the integers. For single-digit inputs, this will be the same. However, inputs larger than 10 will have different responses. This would be an incorrect response:

Input: 12
Output: 78

Another example, to show the difference:

Input: 10

Integer Sequence: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
Sum of Integers (INCORRECT RESPONSE): 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 = 55

Digit Sequence: 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 0
Sum of Digits (CORRECT RESPONSE): 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 1 + 0 = 46

A larger test case (CORRECT RESPONSE):

Input: 1000000
Output: 27000001

Rules & Guidelines:

Submitted code must be a complete program or script - not just a function. If the code requires includes, imports, etc., they must be included in the posted code.
The number must be input by the user - not hard-coded. Input may be received as a command-line argument, file, stdin, or any other means by which your language can take user input.
The code must be able to properly handle inputs at least up to (2^64)-1.
The code should only output the sum.
Submitted programs & scripts should be user-friendly and not wasteful of computer resources (e.g.: they should not declare insanely-large arrays to hold every character). There is no strict bonus or penalty for this, but please be good programmers.

Scoring:

Primary scoring mechanism is by code length. Lower scores are better. The following bonuses and penalties also apply:

-25 Bonus if your code can handle all positive numbers, for example: 1234567891234567891234564789087414984894900000000
-50 Bonus if your code can handle simple expressions, for example 55*96-12. To qualify for this bonus, the code should handle + - / * (addition, subtraction, division, multiplication) operators and enforce order of operations. Division is regular integer division.

The given example (55*96-12) evaluates to 5268. Your code should return the same for either of those inputs - correct answer is 81393.

-10 Bonus if your code qualifies for the -50 bonus and can handle the ^ (exponent) operator.
-100 Bonus if your code qualifies for the -50 bonus and does not use eval or similar to handle expressions.
+300 Penalty if your code relies upon any web resources.

Mathematica 30-(10+50)= -30
Shortened by 4 chars thanks to ybeltukov.
Range@n returns the numbers from 1 through n.
Integerdigits@n breaks up each of those numbers into its digits.
Total[n,2] sums the digits.  The 2 is to allow summing across different levels, i.e. lists of lists.
IntegerDigits@Range@#~Total~2&

Testing
IntegerDigits@Range@#~Total~2&[12]

51

IntegerDigits@Range@#~Total~2 &[1000000]

27000001

Expressions
IntegerDigits@Range@#~Total~2 &[55*96 - 12]

55*96 - 12

81393
5268

IntegerDigits@Range@#~Total~2 &[5268]

81393

IntegerDigits@Range@#~Total~2 &[55*96^2 - 12]
55*96^2 - 12

12396621
506868

IntegerDigits@Range@#~Total~2 &[506868]

12396621


Create a percent sign Given an integer n ≥ 1, output a 2D representation† of a percent sign of width n. The construction goes as follows:

Create an n by n matrix (or list of lists) filled with zeroes.
Insert ones in the top-left and bottom-right corners.
Place ones on the diagonal from the bottom-left to the top-right.

For input n = 4, this construction would look like:

1. 4x4 matrix of 0s
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
2. 1s in TL and BR corners
1 0 0 0
0 0 0 0
0 0 0 0
0 0 0 1
3. 1s across BL-TR diagonal
1 0 0 1
0 0 1 0
0 1 0 0
1 0 0 1

This is a code-golf, so the shortest program in bytes wins.

† I use a matrix of 1s and 0s, but it is also acceptable to use a string of any non-whitespace character and spaces. So, the example above could look like:

#  #
  #
 #
#  #

or

#     #
    #
  #
#     #

Test cases

n
output

1
1

2
1 1
1 1

3
1 0 1
0 1 0
1 0 1

4
1 0 0 1
0 0 1 0
0 1 0 0
1 0 0 1

10
1 0 0 0 0 0 0 0 0 1
0 0 0 0 0 0 0 0 1 0
0 0 0 0 0 0 0 1 0 0
0 0 0 0 0 0 1 0 0 0
0 0 0 0 0 1 0 0 0 0
0 0 0 0 1 0 0 0 0 0
0 0 0 1 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 1

Final note

Adding an explanation would be greatly appreciated.


Shortest Solution in Python 3 for Caught Speeding - CodingBat I am trying to find the shortest code in python 3, to solve this problem:

You are driving a little too fast, and a police officer stops you.

Write code to take two integer inputs, first one corresponds to speed, seconds one is either 1 or 0, corresponding to True and False respectively to indicate whether it is birthday. Then compute the result, encoded as an int value:

0=no ticket,

1=small ticket,

2=big ticket.

If speed is 60 or less, the result is 0. If speed is between 61 and 80 inclusive, the result is 1. If speed is 81 or more, the result is 2. Unless it is your birthday -- on that day, your speed can be 5 higher in all cases.

input:
60
0
Output:
0

input:
65
0
Output:
1

input:
65
1
output:
0

Here's my shortest solution (57 chars). Is there any way I can make it shorter in Python?

print(min(2,max(0,(int(input())-5*int(input())-41)//20)))

Reference: Problem inspired from this

Python 3, 32 bytes

lambda a,b:(a-b*5>60)+(a-b*5>80)

Try it online!

Python 3, 50 bytes

If io must be done with stdin and stdout

s=int(input())-5*int(input());print((s>60)+(s>80))

Try it online!


Inverse-quotes-quine The prospect of this challenge is:

If your program is run normally, all of the code in the speech marks (" - double quotes) should be printed.
If your program is wrapped in double quotes (in turn inverting the speech marks), the code that is normally not in quotes should be printed.

E.g:

Let's say you have the following code:

fancyStuff("myCode"); "I like".isGreat();

If I run it, I would expect an output of:

myCode
I like

However, if I wrapped it in quotes, I would get:

"fancyStuff("myCode"); "I like".isGreat();"

When this code is run, the expected output would be:

fancyStuff(
);
.isGreat();

Obviously, the above example is not a functional response in any language. Your job is to write the code that performs in this way.

Rules

Standard loopholes apply.
The printed values, in both quoted and unquoted forms, must be non-empty, or consist solely of whitespace. This also means that all programs must include at least one set of quotes.
However, trailing/preceeding whitespace is allowed.
No looking at your own code, required file names, etc.
Unmatched quotes are disallowed
If there are multiple strings, they can either be printed as newlines (as in the example), or in some other human-readable way - no arrays or objects
This is code-golf, so shortest answer in bytes wins.

Python 2, 20 bytes

print";print'print'"

-7 bytes thanks to tsh
Try it online!

Old answer:
Python 2, 27 bytes

'';print";print 2*"'';print

Try it online!
Train of thought behind this answer:
Begin with a simple print, because we need to print something.
print"a"

We also need to print something in the inverted case, ie. have a print inside quotes.
print"print"

The non-inverted case is pretty good at this point. Let's focus on the inverted case. We now start with the string print, which can't be followed immediately by a print statement. Let's fix this with a semicolon.
print";print"

Good stuff. Except, the inverted code doesn't actually print anything. We'll need to print the print at the start, because it ends up in quotes, but also print whatever comes after the second quote, because it ends up in quotes too. The obvious way around this is to append print and multiply the last string by 2.
print";print 2*"print

Now the inverted code works fine, though we have to be wary of the fact that the section before the first quote and the section after the second quote need to be kept the same throughout future changes. As for the non-inverted code, it throws a syntax error - once again, we need to introduce a semicolon to separate expressions.
;print";print 2*";print

Python doesn't really like the look of that lone semicolon, so we must satisfy the snake's hunger with two of the same no-op expression, inserted before the first semicolon and the last semicolon. Most expressions will work fine in the first case, but in the second case it must follow print";print 2*" in the non-inverted code without breaking anything. We can use '', which simply gets concatenated with the prior string.
'';print";print 2*"'';print


Evaluate the nth hyperoperation I do realise that this is a bit math-y, but - here goes.

  In mathematics, the hyperoperation sequence is an infinite sequence of arithmetic operations (called hyperoperations) that starts with the unary operation of successor, then continues with the binary operations of  addition, multiplication and exponentiation, after which the sequence proceeds  with further binary operations extending beyond exponentiation, using right-     associativity.

Your goal is to write a program that takes three integers x, y and n as input and outputs the result of the nth hyperoperation on x and y.

E.g.

1 1 1 outputs 2

2 4 4 outputs 65536

3 3 4 outputs 7625597484987

The program must be written in the shortest bit of code.
You may take input either from STDIN or from a file.
Library functions not allowed.
Input constraints: n will be ≥ 1.

http://en.wikipedia.org/wiki/Tetration has a good explanation in case you can't wrap your head around this.

APL, 62

{1=3⌷⍵:2⌷+\⍵⋄0=2⌷⍵:(⍵[3]⌊3)⌷⍵[1],0,1⋄∇⍵[1],(∇⍵-0 1 0),3⌷⍵-1}⎕

{...}⎕: Takes evaluated input (space-separated numbers evaluates to a numerical array) and apply function to it.

1=3⌷⍵:: If n equals 1...
2⌷+\⍵: Return sum of first 2 elements (x+y)...
⋄0=2⌷⍵:: Else if y equals 0...
(⍵[3]⌊3)⌷⍵[1],0,1: Create numerical array [x,0,1] and return index min(n,3)...
⋄∇⍵[1],(∇⍵-0 1 0),3⌷⍵-1: Else return ∇(x,∇(x,y-1,n),n-1). (∇ is self-reference)

I have got a "hyper-raiser" operator, which takes a function and return next hyperoperation

{⍺⍺/⊃⍴/⌽⍵}

For example, +{⍺⍺/⊃⍴/⌽⍵} would be the multiplication function and +{⍺⍺/⊃⍴/⌽⍵}5 3 outputs 15.

But can't get it to recurse. Maybe someone else can do it.


Is this a staircase number? Challenge :

Check if the given number forms a number staircase or not

Input :

A integer (greater than 0 and not decimal). NOTE : You can take input as string , array of digits.

Output :

a truthy / falsy value depending on whether the number forms a staircase or not

Number staircase :

A number staircase is an integer that , when read from left to right :

Starts with 1
which may be followed by 2
which may be followed by 3
and so on till n
then the number descends starting at n - 1
then n - 2
then n - 3
and so on till it reaches 1

Note :

The may be part is used to indicate that if length > is greater than 1. If it is the order must be followed as is. i.e : 12321

Example :

12321                          ---> true
12345654321                    ---> true
9                              ---> false
1                              ---> true
2                              ---> false
123421                         ---> false
112312318901323                ---> false
123456789101110987654321       ---> true

Note :

The input given will always be an integer greater than 0 and will not be a decimal. Your output must be a truthy or falsy value depending on the input

Restrictions :

This is code-golf so shortest code in bytes (for each programming language ) wins.

R, 97 bytes

function(n)"if"(n>1,{while({T=T+1;x=paste(c(1:T,T:2-1),collapse="");nchar(x)<nchar(n)})0;x==n},T)

Try it online!

Takes n as a character or an integer; using character will give correct results for integers that can't be held precisely as a 64-bit double.

Generates staircase numbers until it finds one at least as long as n is, then tests for equality.

Equivalent to:

function(n)
    if(n > 1){
        T <- T + 1
        x <- paste(c(1:T,T:2-1),collapse="")
        while(nchar(x) < nchar(n)){
            T <- T + 1
            x <- paste(c(1:T,T:2-1),collapse="")
        }
        return(x == n)
    } else
        return(TRUE)


Programming Praxis - Survive like Flavius Josephus Here's a challenge inspired by Programming Praxis:
http://programmingpraxis.com/2009/02/19/flavius-josephus/

Write a function josephus(n,m) that returns a list of n people,
numbered from 0 to n-1, in the order in which they are executed, every
mth person in turn, with the sole survivor as the last person in the
list.

Example output:

josephus(41,3)
2 5 8 11 14 17 20 23 26 29 32 35 38 0 4 9 13 18 22 27 31 36 40 6 12 19 25 33 39 7 16 28 37 10 24 1 21 3 34 15 30

The function can't leak on the global scope, and must return a list or an array.
If your language can't return an array, it is allowed to just print the list.
Shortest answer (in bytes) wins.

Python 2 (85 Bytes):

Thanks to bitpwner we have this solution:

def j(m,n):
    a,b,c=range(m),0,[]
    while a:b=(b+n-1)%len(a);c+=[a.pop(b)]
    return c

To use this in Python 3 you have to cast a to a list, this comes with the cost of another 6 bytes.

Python 3 (114 bytes):

This was my first thought, but I think this is a good but no perfect solution:

def j(m,n):
    a,b=__import__("collections").deque(range(m)),[]
    while a:a.rotate(-n);b.append(a.pop())
    return b

I was not happy with the use of the deque, but I couldn't think of any other solution. At least I could save 5 bytes with __import__.

This function works as described above, a are the people and b is the execution order. As long as there are still people left (while a:), it rotates the deque/the people by n and appends the current man (a.pop()) to the execution list.


Construct the natural numbers with sets This construction is a way of representing the Natural Numbers.

In this representation, 0 is defined as the empty set and for all other numbers, n is the union of {0} and {n-1}.

For example to construct 3 we can follow the algorithm:

3 =
{ø, 2} =
{ø, {ø, 1}} =
{ø, {ø, {ø}}}

Task

As you may have guessed your task is to take in a natural number (including zero) and output its construction.

You may output as a either a string or as a set object if your language of choice supports such objects.

If you choose to output as a string you should represent a set with curly braces ({}).  You may optionally represent the empty set as ø (otherwise it should be a set with no entries {}).  You may also choose to add commas and whitespace between and after entries in the set.

Order is not important, however you may not have any repeated elements in the sets you output (e.g. {ø,ø})

This is code-golf so the goal is to have the fewest bytes

Test cases

Here are some test cases with some example outputs.

0 -> {}
1 -> {{}}
2 -> {{}{{}}}
3 -> {{}{{}{{}}}}
4 -> {{}{{}{{}{{}}}}}

Python, 28 bytes

lambda x:"{{}"*x+x*"}"or"{}"

Try it online!

This is a pretty bland solution to the problem.  For numbers greater than zero you can get the representation with the string formula "{{}"*x+"}"*x.  However this doesn't work for zero where this is the empty string.  We can use this fact to short circuit an or to return the empty set.

I wanted to use python's builtin set objects to solve this problem but unfortunately:

TypeError: unhashable type: 'set'

You cannot put sets inside of sets in python.


Determine a string's Scrabble score and validity Your task is to determine if a given string is of proper length and can be represented with Scrabble tiles and, if so, output the sum of each letter's score.

If you don't know how to play Scrabble:, you have 100 tiles with various letters A–Z printed on them, as well as two wildcards that can represent any letter. Each letter has a certain number of points, and each tile (but not necessarily word) can only be used once. When a word is played, the point value of each tile used is added up, which becomes the score. As there are a limited number of letters available, a word can only have a certain letter as many times as that letter has tiles + any unused wildcards. The Scrabble board is 15×15 cells, so the word must be between 2 and 15 characters long.

For a list of the quantity and score of each letter in the English version, see below or http://boardgames.about.com/od/scrabble/a/tile_distribute.htm (archive).

Letter  Qty  Points        Letter  Qty  Points
-------------------        -------------------
A       9    1             O       8    1
B       2    3             P       2    3
C       2    3             Q       1    10
D       4    2             R       6    1
E       12   1             S       4    1
F       2    4             T       6    1
G       3    2             U       4    1
H       2    4             V       2    4
I       9    1             W       2    4
J       1    8             X       1    8
K       1    5             Y       2    4
L       4    1             Z       1    10
M       2    3             [wild]  2    0
N       6    1

Further rules

The program shall take a single string of input from STDIN or the like.
The input will always contain only uppercase letters.
If the string contains more copies of a letter than there are unused wildcards or tiles for that letter OR the string's length is not between 2 and 15 inclusive, the program should output Invalid.
Otherwise, the score should be added up with using data from the chart above and output.
Do not use wildcards unless necessary.
Do not worry about bonuses such as double word scores or whether the string is a real word.
The program shall output the result through STDOUT or the like.
Loopholes that are forbidden by default are not allowed.
Using an external source such as a website, as well as any libraries, APIs, functions, or the like that calculate Scrabble scores or proper quantities are not alllowed.
This is code-golf, so fewest bytes wins.

Walkthrough

Input: CODEGOLF
C -> 3, O -> 1, D -> 2, E -> 1, G -> 2, O -> 1, L -> 1, F -> 4
3 + 1 + 2 + 1 + 2 + 1 + 1 + 4 = 15
Output: 15

Testcases

Input             Output
------------------------
SCRABBLE          14
JAZZ              19
STACKEXCHANGE     32
XYWFHQYVZVJKHFW   81
PIZZAZZ           Invalid
KIXOKEJAJAX       Invalid
MISUNDERSTANDING  Invalid


It's Anagram Quine, not just Quine! The Task
In this challenge, your task is to write a program, which takes in no input, with as many anagrams that are quine of themselves as possible.
Your score will be the number of anagrams of your program's source code that are valid quines divided by the total number of anagrams possible, i.e. the percentage of the anagrams that are valid quines.
Standard Loopholes and rules of standard quines apply.
Note: Your program must have at least 3 characters (not 3 bytes).

Input
Each anagram (or permutation) of your program which is quine of itself (i.e. the anagrams which you are including in your score) must not take any input. If your language requires input as a necessity, then you can assume that your program will be given a String consisting of the lowercase letter A. However, you must not make any use of the input in any way.

Output
n number of distinct anagrams of your program's source-code must be valid quines, where n represents the number of those anagrams that you are including in your score, i.e.

Those quine-anagarams can output in any way except writing the output to a variable. Writing to file, console, screen etc. is allowed. Function return is allowed as well.

Scoring Example
Suppose your program's source code is code. And,

code outputs code.
coed outputs coed.
cdoe outputs cdoe.
cdeo outputs cdeo.
cedo outputs cedo.
ceod outputs ceod.
ocde outputs ocde.
oced outputs oced.
odce outputs odce.
odec does not output odec or produces error.
oedc does not output oedc or produces error.
oecd does not output oecd or produces error.
doce does not output doce or produces error.
doec does not output doec or produces error.
dcoe does not output dcoe or produces error.
dceo does not output deco or produces error.
deco does not output deco or produces error.
deoc does not output deoc or produces error.
eodc does not output eodc or produces error.
eocd does not output eocd or produces error.
edoc does not output edoc or produces error.
edco does not output edco or produces error.
ecdo does not output ecdo or produces error.
ecod does not output ecod or produces error.

The score of this solution will be

Winning Criterion
The solution with the highest score wins! In case of a tie, the answer with higher char-count (not byte-count) wins (hence the code-bowling)! If a tie still persists, then the solution which was posted earlier wins!


Tips for golfing in MATL MATL is a golfing language created by Luis Mendo. MATL has proven to be highly competitive, often beating submissions in other golfing languages such as Pyth, CJam and Jelly.

What are some useful tips for golfing in MATL? (As always, one tip per answer, please!)

For the record, MATL can be tested online here.
Documentation can be found on Github

Know the predefined literals
Although some of them keep information when copied to the clipboard, they all have a predefined value.

F, pushes 0 (actually False)
T, pushes 1 (actually True)
H, pushes 2 (predefined clipboard value)
I, pushes 3 (predefined clipboard value)
K, pushes 4 (predefined clipboard value)
J, pushes 0 + 1j (predefined clipboard value)

Not sure if I have covered all predefined values though.


Reverse Maths Cycles Inspired by this

In the linked challenge, we are asked to apply addition to the elements of the original and the reverse of the input array. In this challenge, we are going to make it slightly more difficult, by introducing the other basic math operations.

Given an array of integers, cycle through +, *, -, //, %, ^, where // is integer division and ^ is exponent, while applying it to the reverse of the array. Or, in other words, apply one of the above functions to each element of an array, with the second argument being the reverse of the array, with the function applied cycling through the above list. This may still be confusing, so lets work through an example.

Input:   [1, 2, 3, 4, 5, 6, 7, 8, 9]
Reverse: [9, 8, 7, 6, 5, 4, 3, 2, 1]

         [ 1,  2,  3,  4,  5,    6,  7,  8,  9]
Operand:   +   *   -   /   %     ^   +   *   -
         [ 9,  8,  7,  6,  5,    4,  3,  2,  1]

Result:  [10, 16, -4,  0,  0, 1296, 10, 16,  8]

so the output for [1, 2, 3, 4, 5, 6, 7, 8, 9] would be [10, 16, -4, 0, 0, 1296, 10, 16, 8]

To cover the corner cases, the input will never contain a 0, but may contain any other integer in the range from negative infinity to positive infinity. You may take input as a list of strings representing digits if you want.

Test cases

input => output

[1, 2, 3, 4, 5, 6, 7, 8, 9]     => [10, 16, -4, 0, 0, 1296, 10, 16, 8]
[5, 3, 6, 1, 1]                 => [6, 3, 0, 0, 1]
[2, 1, 8]                       => [10, 1, 6]
[11, 4, -17, 15, 2, 361, 5, 28] => [39, 20, -378, 7, 2, 3.32948887119979e-44, 9, 308]

This is a code-golf so shortest code (in bytes) wins!

Jelly, 10 bytes (fork)

+×_:%*6ƭ"Ṛ

I was just working on implementing a quick for this the other day, so it's quite surprising to see a use for it so soon. It still only exists as a fork, so you cannot try it online.

Sample output

$ ./jelly eun '+×_:%*6ƭ"Ṛ' '[1,2,3,4,5,6,7,8,9]'
[10, 16, -4, 0, 0, 1296, 10, 16, 8]
$ ./jelly eun '+×_:%*6ƭ"Ṛ' '[5,3,6,1,1]'
[6, 3, 0, 0, 1]
$ ./jelly eun '+×_:%*6ƭ"Ṛ' '[2,1,8]'
[10, 1, 6]
$ ./jelly eun '+×_:%*6ƭ"Ṛ' '[11,4,-17,15,2,361,5,28]'
[39, 20, -378, 7, 2, 3.32948887119979e-44, 9, 308]

Explanation

+×_:%*6ƭ"Ṛ  Input: array
      6ƭ    Tie 6 dyads
+             Addition
 ×            Multiplication
  _           Subtraction
   :          Integer division
    %         Modulo
     *        Power
        "   Vectorize with
         Ṛ  Reverse


The Work Day Countdown I just had a genius idea for making the work-life easier - a countdown to a specific date which only counts workdays.

The basic task is to create a countdown to a specific date which only includes the workdays in the countdown.

As workday counts Monday, Tuesday, Wednesday, Thursday and Friday.

The Input should be a specific date in the "unofficial" European standard format dd.MM.yyyy and must be today or a day in the future.

The Output should only be the number of days left.

As it's code-golf the shortest code wins.

Test case:

  Today    |   Input    | Output
10.12.2018 | 17.12.2018 |    5
02.10.2018 | 16.10.2018 |   10

If I missed a few things in the question, please forgive me - it's my first question :)

EDIT:

You can use false as output instead of 0 <- but it's not beautiful
No need for respecting DST

05AB1E, 130 128 133 131 124 123 122 121 bytes
žežfžg)V0[Y`UD3‹©12*+>₂*T÷®Xα©т%D4÷®т÷©4÷®·()ćsO7%2@+Y`т‰0Kθ4ÖUD2Qi\28X+ë<7%É31α}‹iY¬>0ëY1¾ǝDÅsD12‹i>1ë\1Dǝ¤>2}}ǝVYI'.¡Q#

I'm out of my mind..
For the golfing language 05AB1E it doesn't matter at all whether the input is with . or -. However, 05AB1E doesn't have any builtins for Date objects or calculations. The only builtin regarding dates it has is today's year/month/day/hours/minutes/seconds/microseconds.
So because of that, almost all of the code you see are manual calculations to go to the next day, and calculating the day of the week.
+5 bytes due to a part I forgot in Zeller's formula (year-1 for months January and February)..
-1 byte thanks to @Grimmy, by changing \$\left\lfloor{\frac{13(m+1)}{5}}\right\rfloor\$ to \$\left\lfloor{\frac{26(m+1)}{10}}\right\rfloor\$ in the code, since 05AB1E has single-byte builtins for both 26 and 10 (being ₂ and T respectively), as opposed to the 3 bytes of 13 and 5.
Try it online or Try it online with an emulated self-specified date of 'today'.
Explanation:
Wall of text incoming.
In general, the code follows the following pseudo-code:
1   Date currentDate = today;
2   Integer counter = 0;
3   Start an infinite loop:
4*    If(currentDate is NOT a Saturday and currentDate is NOT a Sunday):
5       Counter += 1;
6*    currentDate += 1; // Set currentDate to the next day in line
7     If(currentDate == parsed input-string):
8       Stop the infinite loop, and output the counter

1) Date currentDate = today; is this part of the 05AB1E program:

že          # Push today's day
  žf        # Push today's month
    žg      # Push today's year
      )     # Wrap them into a single list
       V    # Pop and store this list in variable `Y`

2) Integer counter = 0; and 3) Start an infinite loop: are straight-forward in the 05AB1E program:

0     # Push 0 to the stack
 [    # Start an infinite loop

4) If(currentDate is NOT a Saturday and currentDate is NOT a Sunday): is the first hard part with manual calculations. Since 05AB1E has no Date builtins, we'll have to calculate the Day of the Week manually.
The general formula to do this is:
$${\displaystyle h=\left(q+\left\lfloor{\frac{13(m+1)}{5}}\right\rfloor+K+\left\lfloor{\frac{K}{4}}\right\rfloor+\left\lfloor{\frac{J}{4}}\right\rfloor-2J\right){\bmod{7}}}$$
Where for the months March through December:

\$q\$ is the \$day\$ of the month ([1, 31])
\$m\$ is the 1-indexed \$month\$ ([3, 12])
\$K\$ is the year of the century (\$year \bmod 100\$)
\$J\$ is the 0-indexed century (\$\left\lfloor {\frac {year}{100}}\right\rfloor\$)

And for the months January and February:

\$q\$ is the \$day\$ of the month ([1, 31])
\$m\$ is the 1-indexed \$month + 12\$ ([13, 14])
\$K\$ is the year of the century for the previous year (\$(year - 1) \bmod 100\$)
\$J\$ is the 0-indexed century for the previous year (\$\left\lfloor {\frac {year-1}{100}}\right\rfloor\$)

Resulting in in the day of the week \$h\$, where 0 = Saturday, 1 = Sunday, ..., 6 = Friday.
Source: Zeller's congruence
We can see this in this part of the 05AB1E program:

Y             # Push variable `Y`
 `            # Push the day, month, and year to the stack
  U           # Pop and save the year in variable `X`
   D          # Duplicate the month
    3‹        # Check if the month is below 3 (Jan. / Feb.),
              # resulting in 1 or 0 for truthy/falsey respectively
      ©       # Store this in variable `®` (without popping)
       12*    # Multiply it by 12 (either 0 or 12)
          +   # And add it to the month
              # This first part was to make Jan. / Feb. 13 and 14

>             # Month + 1
 ₂*           # Multiplied by 26
   T÷         # Integer-divided by 10
®             # Push month<3 from variable `®` again
 Xα           # Take the absolute difference with the year
   ©          # Store this potentially modified year as new `®` (without popping)
    т%        # mYear modulo-100
D4÷           # mYear modulo-100, integer-divided by 4
®т÷©4÷        # mYear integer-divided by 100, and then integer-divided by 4
®·(           # mYear integer-divided by 100, doubled, and then made negative
)             # Wrap the entire stack into a list
 ć            # Extract the head (the counter variable that was also on the stack)
  s           # Swap so the calculated values above are as list at the top
   O          # Take the sum of this entire list
    7%        # And then take modulo-7 to complete the formula,
              # resulting in 0 for Saturday, 1 for Sunday, and [2, 6] for [Monday, Friday]

2@            # Check if the day is greater than or equal to 2 (so a working day)

5) Counter += 1; is straight-forward again:

     # The >=2 check with `2@` results in either 1 for truthy and 0 for falsey
+    # So just adding it to the counter variable is enough

6) currentDate += 1; // Set currentDate to the next day in line is again more complex, because we have to do it manually. So this will be expanded to the following pseudo-code:
a   Integer isLeapYear = ...;
b   Integer daysInCurrentMonth = currentDate.month == 2 ?
c                                 28 + isLeapYear
d                                :
e                                 31 - (currentDate.month - 1) % 7 % 2;
f   If(currentDate.day < daysInCurrentMonth):
g     nextDate.day += 1;
h   Else:
i     nextDate.day = 1;
j     If(currentDate.month < 12):
k       nextDate.month += 1;
l     Else:
m       nextDate.month = 1;
n       nextDate.year += 1;

Sources:
Algorithm for determining if a year is a leap year. (EDIT: No longer relevant, since I use an alternative method to check leap years which saved 7 bytes.)
Algorithm for determining the number of days in a month.
6a) Integer isLeapYear = ...; is done like this in the 05AB1E program:

Y             # Push variable `Y`
 `            # Push the days, month and year to the stack
  т‰          # Divmod the year by 100
    0K        # Remove all items "00" (or 0 when the year is below 100)
      θ       # Pop the list, and leave the last item
       4Ö     # Check if this number is visible by 4
         U    # Pop and save the result in variable `X`

Also used in this 05AB1E answer of mine, so there some example years are added to illustrate the steps.

6b) currentDate.month == 2 ? and 6c) 28 + isLeapYear are done like this:

D            # Duplicate the month that is now the top of the stack
 2Q          # Check if it's equal to 2
   i         # And if it is:
    \        #  Remove the duplicated month from the top of the stack
     28X+    #  Add 28 and variable `X` (the isLeapYear) together

6d) : and 6e) 31 - (currentDate.month - 1) % 7 % 2; are done like this:

ë           # Else:
 <          #  Month - 1
  7%        #  Modulo-7
    É       #  Is odd (shortcut for %2)
     31     #  Push 31
       α    #  Absolute difference between both
}           # Close the if-else

6f) If(currentDate.day < daysInCurrentMonth): is done like this:

‹     # Check if the day that is still on the stack is smaller than the value calculated
 i    # And if it is:

6g) nextDate.day += 1; is done like this:

Y       # Push variable `Y`
 ¬      # Push its head, the days (without popping the list `Y`)
  >     # Day + 1
   0    # Push index 0

        # (This part is done after the if-else clauses to save bytes)
}}      # Close the if-else clauses
  ǝ     # Insert the day + 1 at index 0 in the list `Y`
   V    # Pop and store the updated list in variable `Y` again

6h) Else: and 6i) nextDate.day = 1; are then done like this:

ë        # Else:
 Y       #  Push variable `Y`
  1      #  Push a 1
   ¾     #  Push index 0
    ǝ    #  Insert 1 at index 0 (days part) in the list `Y`

6j) If(currentDate.month < 12)::

D           # Duplicate the list `Y`
 Ås         # Pop and push its middle (the month)
   D12‹     # Check if the month is below 12
       i    # And if it is:

6k) nextDate.month += 1;:

>       # Month + 1
 1      # Push index 1

        # (This part is done after the if-else clauses to save bytes)
}}      # Close the if-else clauses
  ǝ     # Insert the month + 1 at index 1 in the list `Y`
   V    # Pop and store the updated list in variable `Y` again

6l) Else:, 6m) nextDate.month = 1; and 6n) nextDate.year += 1; are then done like this:

ë        # Else:
 \       #  Delete the top item on the stack (the duplicated month)
  1      #  Push 1
   D     #  Push index 1 (with a Duplicate)
    ǝ    #  Insert 1 at index 1 (month part) in the list `Y`

 ¤       #  Push its tail, the year (without popping the list `Y`)
  >      #  Year + 1
   2     #  Index 2

         # (This part is done after the if-else clauses to save bytes)
}}       # Close the if-else clauses
  ǝ      # Insert the year + 1 at index 2 in the list `Y`
   V     # Pop and store the updated list in variable `Y` again

And finally at 7) If(currentDate == parsed input-string): and 8) Stop the infinite loop, and output the counter:

Y          # Push variable `Y`
 I         # Push the input
  '.¡     '# Split it on dots
     Q     # Check if the two lists are equal
      #    # And if they are equal: stop the infinite loop
           # (And output the top of the stack (the counter) implicitly)


Probability to win a hand of poker (Texas hold 'em) Challenge:

In the last stage of a two players Texas hold 'em, given a two-card hand and five cards on table, determine your probability to win versus an opponent by the standard ranking of poker hands.

Input:

Seven cards (sdtin or arguments). The first two cards are your hand while the last five are on the table. Each card will be a two letter string of the form RS where R is rank and S is suit. The ranks range from 2-9, T for ten, and J, Q, K, and A for Jack, Queen, King, and Ace respectively. The suits are H, D, C, S for Hearts, Diamonds, Clubs, and Spades respectively.

Output:

The probability to win (stdout or return): from '0.00' to '1.00'.

Input to Output Examples:

AH 7C  KH QH JH TH 6C -> 1.00

Explanation: You have a royal flush, 100% winning chances.

9H 7C  KH QH JH TH 6C -> 0.96

Explanation: You have a straight flush, your opponent can only win with an AH, 95.6% winning chances.

Rules and Clarifications:

There are 52 different cards. You can refer to Texas hold 'em to get the idea.
Your opponent has 2 unknown cards (out of 45 left). That's 990 possibilities with equal probability.
You are free to decide if Ties count or don't count in the calculation of the probability.
As this is code golf, the shortest answer wins.

Python (not golfed)

import itertools as t

values = '23456789TJQKA'
suits = 'HDCS'

def value(c):
    return values.find(c[0])

def suit(c):
    return c[1]

def amounts(h):
    vals = map(value, h)
    return [vals.count(v) for v in set(vals)]

def score(h):
    vals = sorted(map(value, h))
    return sum(len(values)**i * v for i, v in enumerate(vals))

def straightFlush(h):
    return straight(h) and flush(h)

def fourOfAKind(h):
    return 4 in amounts(h)

def fullHouse(h):
    return 3 in amounts(h) and 2 in amounts(h)

def flush(h):
    return len(set(map(suit, h))) == 1

def straight(h):
    vals = sorted(map(value, h))
    if vals[0] == 0 and vals[-1] == len(values) - 1: #if there's a two and an ace
        vals = vals[:-1] #then remove the ace
    return map(lambda x: x + 1, vals[:-1]) == vals[1:]

def threeOfAKind(h):
    return 3 in amounts(h)

def twoPair(h):
    return amounts(h).count(2) == 2

def pair(h):
    return 2 in amounts(h)

def highCard(h):
    return True

def compare(h1, h2): #return True if h1 wins, False otherwise
    funcs = [straightFlush, fourOfAKind, fullHouse, flush, straight, threeOfAKind, twoPair, pair, highCard]
    for f in funcs:
        r1, r2 = f(h1), f(h2)
        if r1 and not r2:
            return True
        elif r2 and not r1:
            return False
        elif r1 and r2:
            s1, s2 = score(h1), score(h2)
            if s1 > s2:
                return True
            elif s2 > s1:
                return False
    return False #tie case

def bestHand(cards):
    hands = list(t.combinations(cards, 5))
    bestHand = hands[0]
    for h in hands:
        if compare(h, bestHand):
            bestHand = h
    return bestHand

visible = input().split()
table = tuple(visible[2:])
visible = set(visible)
deck = set([c[0] + c[1] for c in t.product(values, suits)]) - visible

hand = bestHand(visible)

wins = 0
total = 0
for c1 in deck:
    for c2 in deck:
        if c1 == c2:
            break
        otherHand = bestHand(table + (c1, c2))
        if compare(hand, otherHand):
            wins += 1
        total += 1

print '%.2f' % (float(wins) / total)

#use examples
# input "AH 7C  KH QH JH TH 6C" --> 1.00
# input "9H 7C  KH QH JH TH 6C" --> 0.96

Could obviously be immensely shorter but there's not much competition yet. I prefer it this way; simple and readable. It counts ties as losses.


Weapons of Math Instruction Last time when I tried to come up with something easy that wasn't a duplicate, it ended up being way too hard.. So hopefully this time it's indeed something newcomers can try as well.

Input:

An array/list with integers/decimals. (Or a string representing an array with integers/decimals.)

Output:

Loop through the numbers and apply the following five mathematical operands in this order:

Addition (+);
Subtraction (−);
Multiplication (* or × or ·);
Real / Calculator Division (/ or ÷);
Exponentiation (^ or **).

(NOTE: The symbols between parenthesis are just added as clarification. If your programming language uses a completely different symbol for the mathematical operation than the examples, then that is of course completely acceptable.)

Keep continuing until you've reached the end of the list, and then give the result of the sum.

Challenge rules:

Exponentiation by 0 (n ^ 0) should result in 1 (this also applies to 0 ^ 0 = 1).
There are no test cases for division by 0 (n / 0), so you don't have to worry about that edge-case.
If the array contains just a single number, we return that as the result.

General rules:

This is code-golf, so shortest answer in bytes wins.
Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.
Standard rules apply for your answer, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters, full programs. Your call.
Default Loopholes are forbidden.
If possible, please add a link with a test for your code.

Test cases:

[1,2,3,4,5] -> 0
-> 1 + 2 = 3
  -> 3 - 3 = 0
    -> 0 * 4 = 0
      -> 0 / 5 = 0

[5,12,23,2,4,4,2,6,7] -> 539
-> 5 + 12 = 17
  -> 17 - 23 = -6
    -> -6 * 2 = -12
      -> -12 / 4 = -3
        -> -3 ^ 4 = 81
          -> 81 + 2 = 83
            -> 83 - 6 = 77
              -> 77 * 7 -> 539

[-8,50,3,3,-123,4,17,99,13] -> -1055.356...
-> -8 + 50 = 42
  -> 42 - 3 = 39
    -> 39 * 3 = 117
      -> 117 / -123 = -0.9512...
        -> -0.9512... ^ 4 = 0.818...
          -> 0.818... + 17 = 17.818...
            -> 17.818... - 99 -> -81.181...
              -> -81.181... * 13 = -1055.356...

[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2] -> 256
-> 2 + 2 = 4
  -> 4 - 2 = 2
    -> 2 * 2 = 4
      -> 4 / 2 = 2
        -> 2 ^ 2 = 4
          -> 4 + 2 = 6
            -> 6 - 2 = 4
              -> 4 * 2 = 8
                -> 8 / 2 = 4
                  -> 4 ^ 2 = 16
                    -> 16 + 2 = 18
                      -> 18 - 2 = 16
                        -> 16 * 2 = 32
                          -> 32 / 2 = 16
                            -> 16 ^ 2 = 256

[1,0,1,0,1,0] -> 1
-> 1 + 0 = 1
  -> 1 - 1 = 0
    -> 0 * 0 = 0
      -> 0 / 1 = 0
        -> 0 ^ 0 = 1

[-9,-8,-1] -> -16
  -> -9 + -8 = -17
    -> -17 - -1 = -16

[0,-3] -> -3
  -> 0 + -3 = -3

[-99] -> -99

Javascript ES7 49 bytes
a=>a.reduce((c,d,e)=>[c**d,c+d,c-d,c*d,c/d][e%5])

Saved 9 bytes thanks to Dom Hastings, saved another 6 thanks to Leaky Nun
Uses the new exponentiation operator.


Decode a variable-length quantity A variable-length quantity (also referred to as VLQ or uintvar) is a way to encode up to a 28 bit integer value using only as many bytes as necessary. This was used in MIDI file format as a way to minimize the size of certain event data.

The way it works is fairly simple.  As a big-endian series of bytes, the most significant bit (MSB) of each byte is a 1 to indicate that another VLQ byte follows. The remaining 7 bits of each byte make up the decoded value.

Example (from Wikipedia):

[ 0x86, 0xc3, 0x17 ] => 106903

Additional references: Wikipedia, Some Guy.

Challenge:

Given a variable-length quantity, convert it to it's integer value.

Input:

A list of one to four bytes or a 32-bit value type representing a valid VLQ of an integer.

Output:

The integer value of the VLQ input.

Rules and scoring:

This is code-golf, so shortest answer in bytes for each language wins.
Standard rules and default I/O rules apply.
Loopholes forbidden (of course).
Please provide link with a test for your code (TIO.run, etc).
A clear explanation for your answer is highly recommended.
Built-ins that handle this conversion are not banned, however not using them is a lot more interesting.

Test cases:

Input (VLQ)                   Output (int)

[                   0x00 ] => 0
[                   0x07 ] => 7
[                   0x7f ] => 127
[             0x81, 0x00 ] => 128
[             0xC0, 0x00 ] => 8192
[             0xff, 0x7f ] => 16383
[       0x81, 0x80, 0x00 ] => 16384
[       0x86, 0xc3, 0x17 ] => 106903
[       0xbd, 0x84, 0x40 ] => 1000000
[       0xff, 0xff, 0x7f ] => 2097151
[ 0xC0, 0x80, 0x80, 0x00 ] => 134217728
[ 0xFF, 0xFF, 0xFF, 0x7F ] => 268435455

Note: you are not required to use hex literals to represent a byte as your input or output. You may use decimal literal ([ 129, 128, 0 ]), integer (0x80818000) or any other reasonable byte/octet representation if better suited to your platform.  Format is flexible as long as it represents 1-4 byte/octets.

Golf away!

APL (dzaima/APL), 8 bytes

128(⊣⊥|)

Try it online!
How:
128(⊣⊥|) ⍝ Anonymous function
128   |  ⍝ Input modulo 128
    ⊣⊥   ⍝ Decoded from base 128


What time is it again? The Inspiration
The Challenge
I'm tired of seeing the same old-same old clock in my top-right-hand corner of my screen. It's time for a new clock. While the clock clock sated my lack of interesting clock for a little while, it simply will do no longer. Your job: make a better, more interesting clock.
The Rules
Make a clock, provided that:

Output is either graphical or directed to STDOUT or equivalent.
You do not use ASCII numbers as the output (don't just print out the time).
It must run continuously until stopped by closing the window or by CTRL-C or equivalent.
It may NOT print out an infinite amount of lines (if using STDOUT).
It must be human-readable, in any way.
It must be accurate to 1/10th of a second to the system clock, and update with any changes to the system clock (so if I change system settings, it will update to my system clock).
Your program cannot exceed 1024 bytes.

Pop-con Objectives
The voters should keep in mind the following:

Creativity should be valued above all.

The better the explanation, the greater the up-votes.

Bash

watch -tn.1 date +%T\|figlet

Yeah, yeah, I know it's not golf (28 bytes!), but I do like the minimalism:

watch is a tool provided by the procps package that repeatedly runs a command every <specified interval of time> and outputs the updated results. (An example of where this is handy: watch -n.1 ls -lh ~/downloads/foo to view the progress of a download.)

The -t flag for watch represents --no-title, as otherwise it would look like this:

The -n 0.1 flag simply means "update every 0.1 seconds."

Then comes the command that we're watching over. First, date +%T prints the date in the desired format (date comes from coreutils):

       %T     time; same as %H:%M:%S

Then this is piped to figlet (unsurprisingly provided by the figlet package), which converts STDIN to ASCII art.

(|  |  _            _   _,            _|   _
 |  | / \_|  |     /   / |  /|/|     / |  / \_
  \/|/\_/  \/|_/   \__/\/|_/ | |_/   \/|_/\_/
   (|

             _/  _/                                      _/
    _/_/_/  _/  _/        _/_/_/    _/_/    _/  _/_/  _/_/_/_/    _/_/_/
 _/    _/  _/  _/      _/_/      _/    _/  _/_/        _/      _/_/
_/    _/  _/  _/          _/_/  _/    _/  _/          _/          _/_/
 _/_/_/  _/  _/      _/_/_/      _/_/    _/            _/_/  _/_/_/

        _|                   |    |   |    _)
  _ \  |    __ \   _ \  _` | __|  __| __ \  | __ \   _` |  __|
 (   | __|  |   |  __/ (   | |    |   | | | | |   | (   |\__ \
\___/ _|   _|  _|\___|\__,_|\__| \__|_| |_|_|_|  _|\__, |____/
                                                   |___/
                       _
    o_|_|_  _|_|_  _  |_o _ | __|_ ._ .__  _ .__.._ _
\/\/| |_| |  |_| |(/_ | |(_||(/_|_ |_)|(_)(_||(_|| | |o
                          _|       |       _|


Build an analog clock Write a program which displays the current system time as an analog clock, using ASCII graphics. The clock must show at least the hour and minute pointers, and must have enough resolution of at least 5 minutes.

The display can be as small and as ugly as you wish, but the shown time should be easily recognizable.

The program has to run continuously and update its status. If your system can clear the screen, use it, otherwise it's enough to repaint the clock when its state changes.

You get a -20% bonus on the character count if the clock has at least a 1 minute resolution.

Javascript 370 - 74 = 296

http://jsfiddle.net/wBKQ6/7/

(This only works in Chrome because I'm abusing the fact that element IDs are added to the global scope).

(function loop(){
    M=Math;p=M.PI/2;z=M.pow;q=M.sqrt;d=new Date();h=(d.getHours()%12/3*p+p)%(p*4);m=(d.getMinutes()/15*p+p)%(p*4);s=(d.getSeconds()/15*p+p)%(p*4);e=49;o='';

    for(r=0;r<99;r++){
        for(c=0;c<99;c++){
            d=q(z(r-e,2)+z(c-e,2));
            a=(M.atan2(e-r,e-c)+p*4)%(p*4);
            E=(d<e*.8&&M.abs(m-a)*d<.5) || (d<e*.5&&M.abs(h-a)*d<.5) || (d<e*1&&M.abs(s-a)*d<.5);
            o+=d-e>0||d<1||E||(e-d<5&&a%p==0)?'●':'○';
            //■□●○
        }
        o+='\n';
    }
    O.innerText=o
    setTimeout(loop,1000);
})()

Golfed (370):

!function L(){p=M.PI/2;q=p*4;P=M.pow;d=new Date();s=(d.getSeconds(S=d.getMinutes(e=40))/15*p+p)%q;m=(S/15*p+p)%q;h=(d.getHours(A=M.abs)%12/3*p+S/180*p+p)%q;for(r=o='';r<81;r++,o+='\n')for(c=0;c<81;){d=M.sqrt(P(r-e,2)+P(c-e,2));a=(M.atan2(e-r,e-c++)+q)%q;o+='○●'[d-e>0|d<e*.8&A(m-a)*d<1|d<e/2&A(h-a)*d<1|d<e&A(s-a)*d<1|e-d<5&a%p==0]}O.innerText=o;setTimeout(L,9)}(M=Math)

Sample Output (much more condensed in demo):

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
●●●●●●●●●●●●●●○○○○○○●○○○○○○●●●●●●●●●●●●●●
●●●●●●●●●●●●○○○○○○○○●○○○○○○○○●●●●●●●●●●●●
●●●●●●●●●●○○○○○○○○○○●○○○○○○○○○○●●●●●●●●●●
●●●●●●●●○○○○○○○○○○○○●○○○○○○○○○○○○●●●●●●●●
●●●●●●●○○○○○○○○○○○○○○○○○○○○○○○○○○○●●●●●●●
●●●●●●○○○○○○○○○○○○○○○○○○○○○○○○○○○○○●●●●●●
●●●●●○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○●●●●●
●●●●○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○●●●●
●●●●○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○●●●●
●●●○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○●●●
●●●○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○●●●
●●○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○●●
●●○○○○○○○○○○○○○○○○○○○○○○○○○●○○○○○○○○○○○●●
●○○○○○○○○○○○○○○○○○○○○○○○○○●●○○○○○○○○○○○○●
●○○○○○○○○○○○○○○○○○○○○○○○○●●○○○○○○○○○○○○○●
●○○○○○○○○○○○○○○○○○○○○○○○●●○○○○○○○○○○○○○○●
●○○○○○○○○○○○○○○○○○○○○○○●●○○○○○○○○○○○○○○○●
●○○○○○○○○○○○○○○○○○○○○○●○○○○○○○○○○○○○○○○○●
●○○○○○○○○○○○○○○○○○○○○●○○○○○○○○○○○○○○○○○○●
●●●●●○○○○○○○○○○○○○○○●○○○○○○○○○○○○○○○●●●●●
●○○○○○○○○○○○○○○○○○○●○●○○○○○○○○○○○○○○○○○○●
●○○○○○○○○○○○○○○○○○○●○○●○○○○○○○○○○○○○○○○○●
●○○○○○○○○○○○○○○○○○●○○○○●●○○○○○○○○○○○○○○○●
●○○○○○○○○○○○○○○○○○●○○○○○●●○○○○○○○○○○○○○○●
●○○○○○○○○○○○○○○○○●○○○○○○○●●○○○○○○○○○○○○○●
●○○○○○○○○○○○○○○○●●○○○○○○○○●●○○○○○○○○○○○○●
●●○○○○○○○○○○○○○○●○○○○○○○○○○○●○○○○○○○○○○●●
●●○○○○○○○○○○○○○●○○○○○○○○○○○○○●○○○○○○○○○●●
●●●○○○○○○○○○○○○●○○○○○○○○○○○○○○●○○○○○○○●●●
●●●○○○○○○○○○○○●○○○○○○○○○○○○○○○○●○○○○○○●●●
●●●●○○○○○○○○○○●○○○○○○○○○○○○○○○○○●○○○○●●●●
●●●●○○○○○○○○○●○○○○○○○○○○○○○○○○○○○●●○○●●●●
●●●●●○○○○○○○●●○○○○○○○○○○○○○○○○○○○○●●●●●●●
●●●●●●○○○○○○○○○○○○○○○○○○○○○○○○○○○○○●●●●●●
●●●●●●●○○○○○○○○○○○○○○○○○○○○○○○○○○○●●●●●●●
●●●●●●●●○○○○○○○○○○○○●○○○○○○○○○○○○●●●●●●●●
●●●●●●●●●●○○○○○○○○○○●○○○○○○○○○○●●●●●●●●●●
●●●●●●●●●●●●○○○○○○○○●○○○○○○○○●●●●●●●●●●●●
●●●●●●●●●●●●●●○○○○○○●○○○○○○●●●●●●●●●●●●●●
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●


math with bitwise operators objective

write a program that can perform addition, subtraction, multiplication, and division, using only bit-wise operators, by bit-wise operators i mean the equivalent of JavaScript &, |, ^, ~, << ,>> ,>>>. (AND, OR, XOR, NOT, and SHIFTs)

rules

you can use other operators, just not for the actual operation/output. (i.e. loop-indentation is ok).
it need not actually take input, just be technically functional. (i.e. functions that take arguments).
any output is OK, you can even return a object with the sum, difference, etc.
you need not return floats for division ints are ok as well, you can round anyway you like.
as short as you can.

JavaScript, 124 119

a=(x,y)=>y?a(x^y,(x&y)<<1):x
s=(x,y)=>a(x,a(1,~y))
m=(x,y)=>x?a(y,m(s(x,1),y)):0
d=(x,y)=>(x=s(x,y))>>31?0:a(1,d(x,y))

Addition and Subtraction work for any signed numbers, multiplication and division only for unsigned (this hasn't been specified).

The input is assumed to be 32 bit.

I've been very strict and not even used comparison operators, except testing for equality with zero. It could probably be written a bit shorter otherwise.


Let us create a sonnet quine! There are programs that will output its source code to standard output and do nothing else. They also access no external output. This type of program is known as a quine, and is a common code challenge.

There are poems that have the rhyme scheme a-b-a-b, c-d-c-d, e-f-e-f, g-g. They have 14 lines. They are usually recited in iambic pentameter. They are called sonnets.

You are to write a program/poem that is both a quine and a sonnet.

When saying lines, it is recommended that you only say all characters except for: whitespace and ,()[]_"'. This is flexible depending on the language though.
Iambic Pentameter means 10 syllables, starting unstressed, and then alternating between stressed and unstressed. This is optional, but will mean more votes.
Comments are discouraged, especially to complete rhymes (although comments are very much encouraged if they can be incorporated with the code in the poem in a way that produces dramatic effect.)
Cruft is discouraged.

Voters, use the four above guidelines when voting. This is a popularity contest, so the program with the most votes wins.

Ruby

s = [[/t{1}he_way/,'to_a'],[/\*j{1}ewel/,'*rule']].to_a
puts <<'-'.*(2).tap { |code| s.each { |rule| code.sub! *rule } }, '-'
s = [[/t{1}he_way/,'to_a'],[/\*j{1}ewel/,'*rule']].the_way
puts <<'-'.*(2).tap { |code| s.each { |rule| code.sub! *jewel } }, '-'
-
s = [[/t{1}he_curse/,'reverse'],[/\*c{1}raze/,'*phrase']].reverse
puts <<'-'.*(2).tap { |code| s.each { |phrase| code.sub! *phrase } }, '-'
s = [[/t{1}he_curse/,'reverse'],[/\*c{1}raze/,'*phrase']].the_curse
puts <<'-'.*(2).tap { |code| s.each { |phrase| code.sub! *craze } }, '-'
-
s = [[/r{1}eject/,'collect'],[/\*b{1}ird/,'*word']].collect
puts <<'-'.*(2).tap { |code| s.each { |word| code.sub! *word } }, '-'
s = [[/r{1}eject/,'collect'],[/\*b{1}ird/,'*word']].reject
puts <<'-'.*(2).tap { |code| s.each { |word| code.sub! *bird } }, '-'
-
puts <<'-'.*(2).tap { |code| [[/\*l{1}augh/,'*half']].each { |half| code.sub! *half } }, '-'
puts <<'-'.*(2).tap { |code| [[/\*l{1}augh/,'*half']].each { |half| code.sub! *laugh } }, '-'
-

Don't pronounce the dashes, they're just there to delimit stanzas. Scansion's not perfect but decent.


Make something tasty! Your challenge is to write a Chef program that works well as a recipe and also as a program. Its utility as a recipe is strictly required (I don't want a recipe for grapeleaves in chocolate-mustard sauce); its utility as a program is a looser requirement, so that it is enough to print something interesting (the first few integers, for example, or "just another chef", or "just another Chef hacker", or "hello world") or do some helpful calculation (printing the sum of two numbers, for example). Votes should take this into account, and the winner is the program with the most net upvotes after some time.

(Code length is not important here.)

I wrote this program for another challenge, but I decided to try and make it a valid answer for this one too:

Shirred Eggs.

This recipe prints the number 2 and, in doing so, yields two delicious
shirred eggs.

Ingredients.
2 eggs

Cooking time: 12 minutes.

Pre-heat oven to 175 degrees Celsius.

Method.
Put eggs into mixing bowl. Pour contents of the mixing bowl into the
baking dish. Shirr the eggs. Bake the eggs until shirred.

Serves 1.

As I mentioned in the other answer, it seems pretty hard to write anything in Chef that involves something more complicated than mixing stuff in a bowl and baking it, and still have it work both as a program and as a recipe.

Edit: Changed the recipe from fried to shirred eggs — thanks to Blazer for the suggestion!  The cooking time and temperature should be considered advisory only; I haven't actually tried the recipe yet myself, so I can't vouch for their accuracy.


Use a genetic algorithm to recreate a string AKA: the most complex way to return a string I could think of.

Requirements:

*Edit: * @Griffin, You are correct, the goal is to use crossover/mutation of characters in a string to eventually come up with the same as input, although, "Hello World" was simply an example. Really, I just like to see what the others on the site can come up with.

Golf. Try to keep it short.
Have fun, dag nabbit!

Preferences (not required):
-Using a fixed seed on a random number generator would help others reproduce your results.
-Bonus if you test for 'properties' of the string, such as the number of L's in "Hello World", instead of only correct characters (like mine).

Shortest code, or highest voted, wins.
One exception: if you manage to create a working version in BrainF***, you win.

My take using Java:

import static java.lang.Math.*;import java.util.Arrays;import static java.lang.System.out;import java.util.Random;class G{static char[]c;static Random r;public static void main(String[]a){c=a[0].toCharArray();r=new Random(6);P w=new P(9);int n=0;while(!w.f){w.s();if(w.f)out.println(w.g[w.p].x()+"@gen "+n);n++;}}static class P{boolean f=false;int p=0;M[]g=null;P(int s){if(s>=9)g=new M[s];else g=new M[9];for(int i=0;i<g.length;i++)g[i]=new M(c.length);}void s(){f();if(!f){h();j();}}void f(){for(int i=0;i<g.length;i++){g[i].f(c);if(g[i].l==0){f=true;p=i;}}}void h(){Arrays.sort(g);}void j(){M[]b=new M[g.length];for(int i=0;i<g.length-1;i++){float k=r.nextInt(100);if(k<40)b[i]=new M(g[0],g[1]);else if((k<60)&&(k>40))b[i]=new M(g[0],g[2]);else if((k<80)&&(k>60))b[i]=new M(g[1],g[2]);else if((k<90)&&(k>80))b[i]=new M(g[2],g[3]);else if((k<95)&&(k>90))b[i]=new M(g[2],g[4]);else if((k<99)&&(k>95))b[i]=new M(g[0],g[r.nextInt(g.length)]);else b[i]=new M(g[0],new M(c.length));b[g.length-1]=g[0];}g=b;}}static class M implements Comparable {char[]a=null;int l=0;int q=0;int u=8;int o=20;public int compareTo(Object o){M t=(M)o;if(this.l<t.l)return-1;else if(this.l>t.l)return 1;return 0;}M(int s){a=new char[s];for(int i=0;i<a.length;i++)a[i]=(char)r.nextInt(255);}M(M m,M p){a=new char[m.a.length];for(int i=0;i<m.a.length;i++){a[i]=(r.nextInt(100)>2)?m.a[i]:p.a[i];int z=r.nextInt(100);if(z<u)a[i]=(char)r.nextInt(255);else if(z<o){int b=r.nextInt(6);a[i]=(char)(a[i]^(1<<b));}}}void f(char[]v){l=0;for(int i=0;i<a.length;i++){int d=abs(a[i]-v[i]);l+=d;}}String x(){return new String(a);}}}

Example output from my code:

Hello World!@gen 3352

APL (98)

L←⍴T←⎕UCS'Hello World!'⋄F←{+/2*⍨⍵-T}⋄0{0=F ⍵:⍺,⎕UCS⍵⋄(⍺+1)∇{(F⍵)≤F⊢C←⍵+(2-?3)×(⍳L)=?⍴⍵:⍵⋄C}⍵}L?255

Can be shortened, at the expense of easy configurability and of result, I'll do so when this one is beaten.

Output:

5940 Hello World!

(or another number between ~4000-~9000).

Credit for the algorithm: http://www.electricmonk.nl/log/2011/09/28/evolutionary-algorithm-evolving-hello-world/

Explanation:

L←⍴T←⎕UCS'Hello World!': The target is the ASCII values (⎕UCS) of 'Hello World'. (You can change the string.) L is its length.
F←{+/2*⍨⍵-T}: F measures the 'distance' between a candidate and a target. This is the sum of the squares of the difference between each character.
0{0=F ⍵:⍺,⎕UCS⍵⋄(⍺+1)∇...⍵}L?255: Starting with a random string (L?255), if the distance between the target and the candidate is 0 (i.e. we have it) (0=F ⍵:), then output the generation and the string (⍺,⎕UCS⍵). Otherwise, mutate the candidate and proceed to the next generation.
(F⍵)≤F⊢C←⍵+(2-?3)×(⍳L)=?⍴⍵:⍵⋄C: Generate a new candidate by selecting a random position and mutating it by one. If the distance to the target is less than the old candidate, return the new candidate, otherwise keep the old candidate.


Score a game of Yahtzee For each of the 13 rows of a Yahtzee scoresheet you are given (from stdin)
a space separated list of 5 numbers (dice).
Your task is to calculate the score for each line and output the Grand Total of the game.

Example

Input and how to interpret it:

Input       Box              Score
6 1 4 1 3   Aces              2
3 2 2 1 2   Twos              6
6 3 2 3 3   Threes            9
4 2 3 6 5   Fours             4
6 3 5 5 1   Fives            10
1 5 6 5 6   Sixes            12
            Bonus             -
4 2 4 4 1   3 of a kind      15
2 2 3 2 4   4 of a kind       -
3 2 2 2 3   Full house       25
1 3 1 6 1   Small straight    -
2 5 4 6 3   Large straight   40
2 2 2 2 2   Yahtzee          50
5 5 4 5 2   Chance           21
            Grand Total     194

We will disregard the Yahtzee Bonus and Joker rules, and only sum up the scores from the Upper and Lower Section and the Bonus in the Upper Section. If in doubt, refer to these rules.

May the shortest code win!

R - 264

S=sum;
P=prod;
T=function(i)table(x[i,]);
Z=function(i,...)any(sapply(list(...),function(y)all(y%in%x[i,])))
S((x[1:6,]==(R=row(x[1:6,])))*R)+ # Upper section
S(x[7,])*any(T(7)>2)+             # 3 of a kind
S(x[8,])*any(T(8)>3)+             # 4 of a kind
25*(P(T(9))%in%5:6)+              # Full house
30*Z(10,1:4,2:5,3:6)+             # Small straight
40*Z(11,1:5,2:6)+                 # Large straight
50*(P(T(12))==5)+                 # Yahtzee
S(x[13,])                         # Chance

(264 characters when excluding the comments)

With the input

x <- as.matrix(read.table("http://pastebin.com/raw.php?i=ZRMC9B4x"))

Output

[1] 194


Print a Singing Angel Keeping with a festive theme, print a carol singing angel with the shortest possible code. The angel is raising money for the homeless, so must be able to sing all three of the below songs available at request. To illustrate she can sing them, the title of the song must be placed within the speech bubble. This song title will be input by the user. Examples include:

Mother Mary
Jingle Bells
Silent Night

Input:

Title: 1 of the 3 songs.

Output:

                  ____________
(\   ___   /)    /            \
( \ (‘o‘) / )   /              \
(           )  <
 (  ‘> <’  )    \              /
    /    \       \____________/
   /      \
  ‘ – “ - ‘

Please paste the result of your singing angel along with the song: "Silent Night".

Speech Bubble Rules:

The speech bubble must always have a frame of 12 underscore lines long.

The title of the song must always start on the second line.

The title of the song must always start 3 underscore spaces inside the bubble.

                  123456789...
(\   ___   /)    /            \
( \ (‘o‘) / )   /    Song      \
(           )  <     Title
 (  ‘> <’  )    \              /
    /    \       \____________/
   /      \
  ‘ – “ - ‘

Examples below:

                  ____________
(\   ___   /)    /            \
( \ (‘o‘) / )   /    Mother    \
(           )  <     Mary
 (  ‘> <’  )    \              /
    /    \       \____________/
   /      \
  ‘ – “ - ‘

                  ____________
(\   ___   /)    /            \
( \ (‘o‘) / )   /    Jingle    \
(           )  <     Bells
 (  ‘> <’  )    \              /
    /    \       \____________/
   /      \
  ‘ – “ - ‘

                  ____________
(\   ___   /)    /            \
( \ (‘o‘) / )   /    Silent    \
(           )  <     Night
 (  ‘> <’  )    \              /
    /    \       \____________/
   /      \
  ‘ – “ - ‘


Greater Average Submatrix Objective

Write a program in any language that reads a matrix from stdin in which all columns are space delimited and all rows are newline delimited. The program must output a sub matrix so as that there is no other sub matrix with greater average, this sub matrix' average value, as well as the starting and ending coordinates. Each sub matrix must be at least 2x2. The initial matrix can be an m x n matrix where 2 < m < 256 and 2 < n < 512. For each element e, you know that -1000000 < e < 1000000

Example Inputs

A)

1 2 3 4 5 6
7 8 9 10 11 12
13 14 15 16 17 18

B)

1 1 1
1 1 1
1 1 1

Example Output

A)

Sub Matrix:
11 12
17 18
Average of all values:
14.5
Starting Coordinates:
[4,0]
Ending Coordinates:
[5,1]

B)

Sub Matrix:
1 1
1 1
Average of all values:
1
Starting Coordinates:
[0,0]
Ending Coordinates:
[1,1]

Rules

You may not use any matrix related library provided for your language but you may use lists, arrays, tables, dictionaries and all the operations that can be performed without including / importing anything in your language.

Scoring

You get one point for every additional byte of code.
You get one point for every variable you use (even if it's a list).
You get one point for every function / method (including lambda / anonymous) you use.
The winner is the solution with the fewest points.

MATLAB, 332 + 9 + 7 = 348
The code:
v=str2num(input(''));s=size(v);d=[];e={};for m=1:s(1)-1 for n=1:s(2)-1 for o=1:s(1)-m for p=1:s(2)-n q=v(o:m+o,p:n+p);e=[e {q}];d=[d;mean(q(:)) o p o+m p+n];end;end;end;end;[~,m]=max(d(:,1));disp('Sub Matrix:');disp(e{m});fprintf('Average of all values:\n%f\nStarting Coordinates:\n[%d,%d]\nEnding Coordinates:\n[%d,%d]\n',d(m,1:5))

And an explanation
%Functions used (7):
%    input str2num size mean max disp fprintf
%Variables used (9):
%    v s d e m n o p q

v=str2num(input('')); %Convert to matrix (new lines and spaces are correctly handled by str2num to form dimensions)
s=size(v); %Dimensions of n.
d=[];
e={};
for m=1:s(1)-1
    %Loop through all widths from 2 up to the width of the matrix (-1 to save doing that later)
    for n=1:s(2)-1
        %Loop through all heights from 2 up the the width of the matrix (-1 to save doing that later)
        for o=1:s(1)-m
            for p=1:s(2)-n
                %Extract the sub array
                q=v(o:m+o,p:n+p);
                %Store the sub array in a cell array so we don't have to extract it later.
                e=[e {q}];
                %Append to the list the details (mean and indicies) of this sub array.
                d=[d;mean(q(:)) o p o+m p+n];
            end
        end
    end
end
%Find the index of the sub array with the largest mean
[~,m]=max(d(:,1));
%And print the output
disp('Sub Matrix:');
disp(e{m});
fprintf('Average of all values:\n%f\nStarting Coordinates:\n[%d,%d]\nEnding Coordinates:\n[%d,%d]\n',d(m,1:5))

input asks for you to enter the matrix. Because MATLAB struggles with new lines, you need to type something like ['1 2 3 4' 10 '5 6 7 8'] Note that the 10 is the new line character. This basically just forms the array exactly as your string would be (the ' and [] are not passed in to the code)


Recreate a 'Snake' game in a console/terminal Games are fun

this codegolf here was so fun I had to make a version for other classic games similar in complexity. Shortest Way of creating a basic Space Invaders Game in Python

This time, however, try to recreate the classic 'Snake' game, in which you start out as a small shape, constantly moving to collecting pieces to increase your score. When you collect a piece, your 'tail' grows, which follows the path you have made. The objective is to last the longest without crashing into your own tail, or into the walls

Qualifications:

You, the characters that make up the tail, the walls, and the pieces you collect should all be different characters
show an HUD with the score. The score increases by 1 point for each piece you collect
The player loses when they collide with their own tail or the wall
a piece spawns in a random area immediately after a piece is collected, not to mention at the start of the game
Speed of the game doesn't matter, as long as it is consistent
The 'cells' should be 2x1 characters, since the height of block characters is ~twice the width Can be 1x1, because 2x1 is just ugly and I didnt really think of that
The keys for changing the direction should be awsd, left, up, down, right respectively
the starting direction should always be up
You must show the edges of the wall. The score may overlap the wall

Shortest code that meets the above criteria wins. Imaginary Bonus Points for creativity

JavaScript (553 512 bytes)

Link to playable version

c=0;a=b=d=-1;e=[f=[20,7],[20,8]];i=Math.random;~function n(){if(c&&(87==a||83==a
))c=0,d=87==a?-1:1;if(d&&(65==a||68==a))d=0,c=65==a?-1:1;p([j=e[0][0]+c,k=e[0][1
]+d])||!j||39==j||!k||10==k?b+=" | GAME OVER":(e.unshift([j,k]),p(f)?(f=[1+38*i(
)|0,1+9*i()|0],b++):e.pop());for(m=h="";11>h;h++){for(g=0;40>g;g++)l=g+","+h,m+=
!g||39==g||!h||10==h?"X":e[0]==l?"O":p(l)?"*":f==l?"%":" ";m+="\n"}x.innerHTML=m
+b;!b.sup&&setTimeout(n,99)}();onkeydown=function(o){a=o.keyCode};function p(o){
return e.join(p).indexOf(p+o)+1}

I tried to make it output to the real console at first (with console.log and console.clear), but it was flickering too much, so I put it into console-like HTML. It will work with this:

<pre id=x>

Also I implemented it with 2x1 cells first, but it just looked worse than 1x1. That would be a minor change though.

Uses awsd keys on keyboard.

Update:

I was able to cut it down to 512 (exactly 0x200) bytes by improving the tail search and doing some more magic.

You now get 2 points when a piece spawns in your tail (it's a feature). I also fixed the overlapping when the snake bites itself.