text:
Too many pawns on a chess board
Given an integer 2n, find the number of possible ways in which 2n^2 black pawns and 2n^2 white pawns can be arranged on a 2n by 2n chess board such that no pawn attack another.

A black pawn can attack only a white pawn, and vice versa.
The usual chess rules of attacking follow, i.e, white pawns attack squares immediately  diagonally in front, and the black pawns attack squares immediately diagonally backward (as seen by the white observer).
All rotation, reflections count as distinct.

The program that can output all possible configurations for the highest value of 2n in 120 seconds wins.
(All programs are welcome, though)
For example, Alice's program can deal with upto n=16 within 120 seconds while Bob's can deal with upto n=20 within the same time. Bob wins.
Platform: Linux 2.7GHz @ 4 CPUs

What is the output format?

any format. Provided that you explain it and it is not a puzzle in itself. @Doorknob

Answers should be allowed to only count them and not output them as there can be far too many to print.

For test: has someone any idea of the numbers involved? I found 3 solution for 2x2 and 28 solutions for 4x4

@feersum Okay, I changed the problem statement

@edc65 the next number is a little more than 400, I think

@edc65, I make it 3, 30, 410. I've checked the 3 and 30 by an alternative method.

I had my code generate the first few: 3, 30, 410, 6148, 96120, 1526700. Although, I have no way of checking. Anyone get the same?

too bad! I have 28 and 408. Wonder what am I missing

To clarify on operator precedence, when you say 2n^2 pawns, is that (2n)^2 or 2(n^2)?

@RetoKoradi I would assume he means 2(n^2) pawns, as a 2n by 2n board can only fit 2(n^2) of each color.

@Changming Yes, that makes sense. I was only looking at the value in isolation. But in the context, that's the only real option.

I think the standard is that 2n^2 is 2*(n^2) which is what I meant. edc65's values are correct

@PeterTaylor How did you confirm 3 and 30, because according to Agnishom 30 is incorrect

3, 30 and 410 are correct.

@edc65, I would guess that you're missing the cases that all the white pawns are on the white squares, and that all the white pawns are on the black squares.

Here is an image: Link

@AgnishomChattopadhyay So clarification, because the question text is slightly contradictory. We don't have to output the solutions, but do we have to find them or just find the number of solutions? I.E feersum's solution finds the number of solutions without technically ever finding a solution, if I'm reading it correctly.

@Cain You just have to output the number of solutions

The image link in your comment above does not work anymore for me. Can you restore it? I didn't have a chance to look at it closely before it disappeared.

Java, n=87 on my machine
The result for n=87 is
62688341832480765224168252369740581641682638216282495398959252035334029997073369148728772291668336432168

import java.math.BigInteger;

public class NonattackingPawns {

    static BigInteger count(int n) {
        BigInteger[][] a0 = new BigInteger[n+1][n*n+1], a1 = new BigInteger[n+1][n*n+1], tm;

        for(int h = 0; h <= n; h++) a0[h][0] = h%2==0? BigInteger.ONE: BigInteger.ZERO;

        for(int c = 1; c <= 2*n; c++) {
            int minp = 0;
            for(int h = 0; h <= n; h++) {
                java.util.Arrays.fill(a1[h], BigInteger.ZERO);
                if(h>0) minp += c >= 2*h-c%2 ? 2*h - c%2 : c;

                int maxp = Math.min(n*(c-1)+h, n*n);
                for(int p = minp; p <= maxp; p++) {
                    BigInteger sum = a0[h][p-h];

                    if(c%2==1 && h>0)
                        sum = sum.add(a0[h-1][p-h]);
                    else if(c%2==0 && h<n)
                        sum = sum.add(a0[h+1][p-h]);

                    a1[h][p] = sum;
                }
            }
            tm=a0; a0=a1; a1=tm;
        }
        BigInteger[] s = new BigInteger[n*n+1];
        for(int p = 0; p <= n*n; p++) {
            BigInteger sum = BigInteger.ZERO;
            for(int h = 0; h <= n; h++) sum = sum.add(a0[h][p]);
            s[p] = sum;

        }

        BigInteger ans = BigInteger.ZERO;
        for(int p = 0; p < n*n; p++) ans = ans.add(s[p].multiply(s[p]));
        return ans.shiftLeft(1).add(s[n*n].multiply(s[n*n]));
    }

    public static void main(String[] args) {
        for(int n = 0;; n++) {
            System.out.println(n + " " + count(n));
        }
    }

}

This currently uses a dynamic programming scheme taking O(n^4) operations to calculate the ways to place p pawns on the squares of one color for 0 <= p <= n^2. I think it should be possible to do this much more efficiently.
Check out the results here.
Explanation
In a valid solution, the lowermost white pawns in each column must form a zigzagging line like this:

That is, the height of the line in column c must be +/- 1 from its position in column c - 1. The line can also go onto two imaginary rows above the top of the board.
We can use dynamic programming to find the number of ways to draw a line on the first c columns that includes p pawns on those columns, is at height h on the cth column, using the results for column c - 1, heights h +/- 1, and number of pawns p - h.

Can you share the number for n=87? Or at least the order of magnitude? That has to be a very large number...

I'm a little bit confused on what you are doing here, but it's very impressive!

I think I get most of your explanation, except when you say "The line can also go onto two imaginary rows above the top of the board"

@Changming, that only means that there are no pawns in that column.

@feersum I see that makes more sense, I'm going to see if I can work through the logic and see if I can find some way to implement it even faster.

Java
Currently, my code is very long and tedious, I'm working on making it faster. I use a recursive method in order to find the values. It computes the first 5 within 2 or 3 seconds, but it gets much slower afterwards. Also, I'm not sure yet if the numbers are right, but the first few seem to line up with the comments. Any suggestions are welcome.
Output
2x2:    3
4x4:    30
6x6:    410
8x8:    6148
10x10:  96120

Explanation
The basic idea is recursion. Essentially you start with an empty board, a board with all zeros. The recursive method just checks to see if it can put a black or white pawn in the next position, if it can only put one color, it puts it there and calls itself. If it can put both colors it calls itself twice, one with each color. Each time it calls itself it decreases the squares left and the appropriate color left. When it has filled the entire board it returns the the current count + 1. If it finds out that there is no way to put a black or white pawn in the next position, it returns 0, which means it's a dead path.
Code
public class Chess {
    public static void main(String[] args){
        System.out.println(solve(1));
        System.out.println(solve(2));
        System.out.println(solve(3));
        System.out.println(solve(4));
        System.out.println(solve(5));
    }
    static int solve(int n){
        int m =2*n;
        int[][] b = new int[m][m];
        for(int i = 0; i < m; i++){
            for(int j = 0; j < m; j++){
                b[i][j]=0;
            }
        }
        return count(m,m*m,m*m/2,m*m/2,0,b);
    }
    static int count(int n,int sqLeft, int bLeft, int wLeft, int count, int[][] b){
        if(sqLeft == 0){
            /*for(int i = 0; i < n; i++){
                for(int j = 0; j < n; j++){
                    System.out.print(b[i][j]);
                }
                System.out.println();
            }
            System.out.println();*/
            return count+1;
        }
        int x=(sqLeft-1)%n;
        int y=(sqLeft-1)/n;
        if(wLeft==0){
            if(y!=0){
                if ((x==0?true:b[x-1][y-1]!=1)&&(x==n-1?true:b[x+1][y-1]!= 1)) {
                    b[x][y] = 2;
                    return count(n, sqLeft-1, bLeft-1, wLeft, count, b);
                } else {
                    return 0;
                }
            } else {
                b[x][y]=2;
                return count(n,sqLeft-1,bLeft-1,wLeft,count,b);
            }
        } else if(bLeft==0){
            if(y!=n-1){
                if((x==0?true:b[x-1][y+1]!=2)&&(x==n-1?true:b[x+1][y+1]!=2)){
                    b[x][y]=1;
                    return count(n,sqLeft-1,bLeft,wLeft-1,count,b);
                } else {
                    return 0;
                }
            } else {
                b[x][y]=1;
                return count(n,sqLeft-1,bLeft,wLeft-1,count,b);
            }
        } else{
            if(y==0){
                if((x==0?true:b[x-1][y+1]!=2)&&(x==n-1?true:b[x+1][y+1]!=2)){
                    int[][] c=new int[n][n];
                    for(int i = 0; i < n; i++){
                        System.arraycopy(b[i], 0, c[i], 0, n);
                    }
                    b[x][y]=2;
                    c[x][y]=1;
                    return count(n,sqLeft-1,bLeft,wLeft-1,count,c)+count(n,sqLeft-1,bLeft-1,wLeft,count,b);
                } else {
                    b[x][y]=2;
                    return count(n,sqLeft-1,bLeft-1,wLeft,count,b);
                }
            }else if(y==n-1){
                if((x==0?true:b[x-1][y-1]!=1)&&(x==n-1?true:b[x+1][y-1]!=1)){
                    int[][] c=new int[n][n];
                    for(int i = 0; i < n; i++){
                        System.arraycopy(b[i], 0, c[i], 0, n);
                    }
                    b[x][y]=2;
                    c[x][y]=1;
                    return count(n,sqLeft-1,bLeft,wLeft-1,count,c)+count(n,sqLeft-1,bLeft-1,wLeft,count,b);
                } else {
                    b[x][y]=1;
                    return count(n,sqLeft-1,bLeft,wLeft-1,count,b);
                }
            }else{
                if(((x==0?true:b[x-1][y-1]!=1)&&(x==n-1?true:b[x+1][y-1]!=1))&&((x==0?true:b[x-1][y+1]!=2)&&(x==n-1?true:b[x+1][y+1]!=2))){
                    int[][] c=new int[n][n];
                    for(int i = 0; i < n; i++){
                        System.arraycopy(b[i], 0, c[i], 0, n);
                    }
                    b[x][y]=2;
                    c[x][y]=1;
                    return count(n,sqLeft-1,bLeft,wLeft-1,count,c)+count(n,sqLeft-1,bLeft-1,wLeft,count,b);
                } else if ((x==0?true:b[x-1][y-1]!=1)&&(x==n-1?true:b[x+1][y-1]!=1)){
                    b[x][y]=2;
                    return count(n,sqLeft-1,bLeft-1,wLeft,count,b);
                } else if ((x==0?true:b[x-1][y+1]!=2)&&(x==n-1?true:b[x+1][y+1]!=2)){
                    b[x][y]=1;
                    return count(n,sqLeft-1,bLeft,wLeft-1,count,b);
                } else {
                    return 0;
                }
            }
        }
    }
}

Try it here (Doesn't run fast enough for Ideone so the last value doesn't print, looks like my solution isn't very good!)

I concur up to 6148, and I haven't yet produced any values beyond that.

@PeterTaylor Well Agnishom says that it should be 3, 28, 408 so I doubt 6148 is right. I wonder what we are both doing wrong?

Quite faster then mine. +1 even if I don't agree on results

Hello! I never said it is 28, 408
The correct sequence is 3,30,410,...

You said, @edc65 had the right values, and his values are 28, 408?

@Changming I meant that his value of 3 and 30 were correct. Sorry for the confusion.
I believe your solution is on the right track

@AgnishomChattopadhyay Okay, cool I've been trying to figure out why I was off by 2 but that helps.

Is there a (simple) way to have your program print the solutions it finds? For side 4 there are no more than 30.

@Changming If you have some time, could you explain your solution?

@AgnishomChattopadhyay I added an explanation, let me know if it is unclear, or you think I should add anything.

@edc65 I added a commented section of the code that prints solutions, just uncomment it and it will print every solution it finds. I'm not sure if it prints it in the right orientation, but that should be an easy fix.

@Changming So, basically this is a backtrack? I had the same thing in mind.

@AgnishomChattopadhyay I don't really remember what a backtrack is, but that sounds about right.

C++ with pthreads, n = 147 156
The latest result is from running the same code as before on a beefier machine. This was now run on a desktop with a quad-core i7 (Core i7-4770), which got to n=156 in 120 seconds. The result is:

7858103688882482349696225090648142317093426691269441606893544257091315906431773702676266198643058148987365151560565922891852481847049321541347582728793175114543840164406674137410614843200

This is using a dynamic programming algorithm. I initially pondered approaches where the result would be built row by row, but I could never come up with a way to expand the solution without tracking a ton of state.
The key insights that enabled a reasonably efficient solution were:

Since pawns on black squares can only attack pawns on other black squares, and the same is true for white squares, the black and white squares are independent, and can be processed separately. And since they are equivalent, we only need to process one of the two.
The problem gets much easier when processing the board diagonal by diagonal.

If you look at one diagonal of a valid configuration, it always consists of a sequence of black pawns followed by a sequence of white pawns (where either sequence can also be empty). In other words, each diagonal can be fully characterized by its number of black pawns.
Therefore, the state tracked for each diagonal is the number of valid pawn configurations for each combination of:

Number of black pawns in the row (or in other words, the position within the diagonal that separates the black pawns from the white pawns).
Total count of black pawns used. We need to track the whole thing per pawn count because we only need the equal number of black pawns and white pawns at the very end. While processing the diagonals, the counts can be different, and still result in valid solutions in the end.

When stepping from one diagonal to the next one, there is another constraint to build valid solutions: The position that separates black pawns from white pawns can not increase. So the number of valid configurations is calculated as the sum of the valid configurations of the previous diagonal for positions that are equal or larger.
The basic DP step is then very simple. Each value in a diagonal is just a sum of values from the previous diagonal. The only somewhat painful part is calculating the indices and loop ranges correctly. Since we're working on diagonals, the length increases during the first half of the calculation, and decreases for the second half, which makes the calculation of the loop ranges more cumbersome. There's also some considerations for the values at the boundary of the board, since they only have diagonal neighbors on one side when stepping from diagonal to diagonal.
The amount of memory used is O(n^3). I keep two copies of the state data, and ping pong between them. I believe it would be possible to operate with a single instance of the state data. But you would have to be very careful that no values are updated before the old values are fully consumed. Also, it would not work well for the parallel processing I introduced.
Runtime complexity is... polynomial. There are 4 nested loops in the algorithm, so at first sight it would look like O(n^4). But you obviously need bigints at these sizes, and the numbers themselves also get longer at larger sizes. The number of digits in the result seems to increase roughly proportionally to n, which would make the whole thing O(n^5). On the other hand, I found some performance improvements, which avoids going through the full range of all loops.
So while this is still a fairly expensive algorithm, it gets much farther than the algorithms that enumerate solutions, which are all exponential.
Some notes on the implementation:

While there can be up to 2*n^2 black pawns on the black squares, I only calculate the configuration numbers up to n^2 black pawns. Since there's a symmetry between black and white pawns, the configuration count for k and 2*n^2-k are the same.
The number of solutions is calculated at the end from the configuration counts on the black squares based on a similar symmetry. The total number of solutions (which need to have 2*n^2 pawns of each color) is the number of configurations for k black pawns on one color of squares multiplied by the number of configurations for 2*n^2-k black pawns on the other color of squares, summed over all k.
In addition to just storing the configuration counts per diagonal position and pawn count, I also store the range of pawn counts that have valid configurations per position. This allows cutting down the range of the inner loop substantially. Without this, I found that a lot of zeros were being added. I got a very substantial performance improvement from this.
The algorithm parallelizes fairly well, particularly at large sizes. The diagonals have to be processes sequentially, so there is a barrier at the end of each diagonal. But the positions within the diagonal can be processed in parallel.
Profiling shows that the bottleneck is clearly in adding bigint values. I played around with some variations of the code, but it's not heavily optimized. I suspect that there could be a significant improvement from inline assembly to use 64-bit additions with carry.

Main algorithm code. THREADS controls the number of threads used, where the number of CPU cores should be a reasonable starting point:
#ifndef THREADS
#define THREADS 2
#endif

#if THREADS > 1
#include <pthread.h>
#endif

#include <vector>
#include <iostream>
#include <sstream>

#include "BigUint.h"

typedef std::vector<BigUint> BigUintVec;
typedef std::vector<int> IntVec;

static int N;
static int NPawn;
static int NPos;

static BigUintVec PawnC[2];
static IntVec PawnMinC[2];
static IntVec PawnMaxC[2];

#if THREADS > 1
static pthread_mutex_t ThreadMutex;
static pthread_cond_t ThreadCond;
static int BarrierCount;
#endif

#if THREADS > 1
static void ThreadBarrier()
{
    pthread_mutex_lock(&ThreadMutex);

    --BarrierCount;
    if (BarrierCount)
    {
        pthread_cond_wait(&ThreadCond, &ThreadMutex);
    }
    else
    {
        pthread_cond_broadcast(&ThreadCond);
        BarrierCount = THREADS;
    }

    pthread_mutex_unlock(&ThreadMutex);
}
#endif

static void* countThread(void* pData)
{
    int* pThreadIdx = static_cast<int*>(pData);
    int threadIdx = *pThreadIdx;

    int prevDiagMin = N - 1;
    int prevDiagMax = N;

    for (int iDiag = 1; iDiag < 2 * N; ++iDiag)
    {
        BigUintVec& rSrcC = PawnC[1 - iDiag % 2];
        BigUintVec& rDstC = PawnC[iDiag % 2];

        IntVec& rSrcMinC = PawnMinC[1 - iDiag % 2];
        IntVec& rDstMinC = PawnMinC[iDiag % 2];

        IntVec& rSrcMaxC = PawnMaxC[1 - iDiag % 2];
        IntVec& rDstMaxC = PawnMaxC[iDiag % 2];

        int diagMin = prevDiagMin;
        int diagMax = prevDiagMax;;
        if (iDiag < N)
        {
            --diagMin;
            ++diagMax;
        }
        else if (iDiag > N)
        {
            ++diagMin;
            --diagMax;
        }

        int iLastPos = diagMax;
        if (prevDiagMax < diagMax)
        {
            iLastPos = prevDiagMax;
        }

        for (int iPos = diagMin + threadIdx; iPos <= iLastPos; iPos += THREADS)
        {
            int nAdd = iPos - diagMin;

            for (int iPawn = nAdd; iPawn < NPawn; ++iPawn)
            {
                rDstC[iPos * NPawn + iPawn] = 0;
            }

            rDstMinC[iPos] = NPawn;
            rDstMaxC[iPos] = -1;

            int iFirstPrevPos = iPos;
            if (!nAdd)
            {
                iFirstPrevPos = prevDiagMin;
            }

            for (int iPrevPos = iFirstPrevPos;
                 iPrevPos <= prevDiagMax; ++iPrevPos)
            {
                int iLastPawn = rSrcMaxC[iPrevPos];
                if (iLastPawn + nAdd >= NPawn)
                {
                    iLastPawn = NPawn - 1 - nAdd;
                }

                if (rSrcMinC[iPrevPos] > iLastPawn)
                {
                    continue;
                }

                if (rSrcMinC[iPrevPos] < rDstMinC[iPos])
                {
                    rDstMinC[iPos] = rSrcMinC[iPrevPos];
                }

                if (iLastPawn > rDstMaxC[iPos])
                {
                    rDstMaxC[iPos] = iLastPawn;
                }

                for (int iPawn = rSrcMinC[iPrevPos];
                     iPawn <= iLastPawn; ++iPawn)
                {
                    rDstC[iPos * NPawn + iPawn + nAdd] += rSrcC[iPrevPos * NPawn + iPawn];
                }
            }

            if (rDstMinC[iPos] <= rDstMaxC[iPos])
            {
                rDstMinC[iPos] += nAdd;
                rDstMaxC[iPos] += nAdd;
            }
        }

        if (threadIdx == THREADS - 1 && diagMax > prevDiagMax)
        {
            int pawnFull = (iDiag + 1) * (iDiag + 1);
            rDstC[diagMax * NPawn + pawnFull] = 1;
            rDstMinC[diagMax] = pawnFull;
            rDstMaxC[diagMax] = pawnFull;
        }

        prevDiagMin = diagMin;
        prevDiagMax = diagMax;

#if THREADS > 1
        ThreadBarrier();
#endif
    }

    return 0;
}

static void countPawns(BigUint& rRes)
{
    NPawn = N * N + 1;
    NPos = 2 * N;

    PawnC[0].resize(NPos * NPawn);
    PawnC[1].resize(NPos * NPawn);

    PawnMinC[0].assign(NPos, NPawn);
    PawnMinC[1].assign(NPos, NPawn);

    PawnMaxC[0].assign(NPos, -1);
    PawnMaxC[1].assign(NPos, -1);

    PawnC[0][(N - 1) * NPawn + 0] = 1;
    PawnMinC[0][N - 1] = 0;
    PawnMaxC[0][N - 1] = 0;

    PawnC[0][N * NPawn + 1] = 1;
    PawnMinC[0][N] = 1;
    PawnMaxC[0][N] = 1;

#if THREADS > 1
    pthread_mutex_init(&ThreadMutex, 0);
    pthread_cond_init(&ThreadCond, 0);

    BarrierCount = THREADS;

    int threadIdxA[THREADS] = {0};
    pthread_t threadA[THREADS] = {0};
    for (int iThread = 0; iThread < THREADS; ++iThread)
    {
        threadIdxA[iThread] = iThread;
        pthread_create(threadA + iThread, 0, countThread, threadIdxA + iThread);
    }

    for (int iThread = 0; iThread < THREADS; ++iThread)
    {
        pthread_join(threadA[iThread], 0);
    }

    pthread_cond_destroy(&ThreadCond);
    pthread_mutex_destroy(&ThreadMutex);
#else
    int threadIdx = 0;
    countThread(&threadIdx);
#endif

    BigUint solCount;
    BigUintVec& rResC = PawnC[1];
    for (int iPawn = 0; iPawn < NPawn; ++iPawn)
    {
        BigUint nComb = rResC[(N - 1) * NPawn + iPawn];

        nComb *= nComb;
        if (iPawn < NPawn - 1)
        {
            nComb *= 2;
        }

        solCount += nComb;
    }

    std::string solStr;
    solCount.toDecString(solStr);
    std::cout << solStr << std::endl;
}

int main(int argc, char* argv[])
{
    std::istringstream strm(argv[1]);
    strm >> N;

    BigUint res;
    countPawns(res);

    return 0;
}

This also needs a bigint class that I wrote for this purpose. Note that this is not a general purpose bigint class. It does just enough to support the operations used by this specific algorithm:
#ifndef BIG_UINT_H
#define BIG_UINT_H

#include <cstdint>
#include <string>
#include <vector>

class BigUint
{
public:
    BigUint()
      : m_size(1),
        m_cap(MIN_CAP),
        m_valA(m_fixedValA)
    {
        m_valA[0] = 0;
    }

    BigUint(uint32_t val)
      : m_size(1),
        m_cap(MIN_CAP),
        m_valA(m_fixedValA)
    {
        m_valA[0] = val;
    }

    BigUint(const BigUint& rhs)
      : m_size(rhs.m_size),
        m_cap(MIN_CAP),
        m_valA(m_fixedValA)
    {
        if (m_size > MIN_CAP)
        {
            m_cap = m_size;
            m_valA = new uint32_t[m_cap];
        }

        for (int iVal = 0; iVal < m_size; ++iVal)
        {
            m_valA[iVal] = rhs.m_valA[iVal];
        }
    }

    ~BigUint()
    {
        if (m_cap > MIN_CAP)
        {
            delete[] m_valA;
        }
    }

    BigUint& operator=(uint32_t val)
    {
        m_size = 1;
        m_valA[0] = val;

        return *this;
    }

    BigUint& operator=(const BigUint& rhs)
    {
        if (rhs.m_size > m_cap)
        {
            if (m_cap > MIN_CAP)
            {
                delete[] m_valA;
            }

            m_cap = rhs.m_size;
            m_valA = new uint32_t[m_cap];
        }

        m_size = rhs.m_size;

        for (int iVal = 0; iVal < m_size; ++iVal)
        {
            m_valA[iVal] = rhs.m_valA[iVal];
        }

        return *this;
    }

    BigUint& operator+=(const BigUint& rhs)
    {
        if (rhs.m_size > m_size)
        {
            resize(rhs.m_size);
        }

        uint64_t sum = 0;
        for (int iVal = 0; iVal < m_size; ++iVal)
        {
            sum += m_valA[iVal];
            if (iVal < rhs.m_size)
            {
                sum += rhs.m_valA[iVal];
            }
            m_valA[iVal] = sum;
            sum >>= 32u;
        }

        if (sum)
        {
            resize(m_size + 1);
            m_valA[m_size - 1] = sum;
        }

        return *this;
    }

    BigUint& operator*=(const BigUint& rhs)
    {
        int resSize = m_size + rhs.m_size - 1;
        uint32_t* resValA = new uint32_t[resSize];

        uint64_t sum = 0;

        for (int iResVal = 0; iResVal < resSize; ++iResVal)
        {
            uint64_t carry = 0;

            for (int iLhsVal = 0;
                 iLhsVal <= iResVal && iLhsVal < m_size; ++iLhsVal)
            {
                int iRhsVal = iResVal - iLhsVal;
                if (iRhsVal < rhs.m_size)
                {
                    uint64_t prod = m_valA[iLhsVal];
                    prod *= rhs.m_valA[iRhsVal];
                    uint64_t newSum = sum + prod;
                    if (newSum < sum)
                    {
                        ++carry;
                    }
                    sum = newSum;
                }
            }

            resValA[iResVal] = sum & UINT64_C(0xFFFFFFFF);
            sum >>= 32u;
            sum += carry << 32u;
        }

        if (resSize > m_cap)
        {
            if (m_cap > MIN_CAP)
            {
                delete[] m_valA;
            }

            m_cap = resSize;
            m_valA = resValA;
        }
        else
        {
            for (int iVal = 0; iVal < resSize; ++iVal)
            {
                m_valA[iVal] = resValA[iVal];
            }

            delete[] resValA;
        }

        m_size = resSize;

        if (sum)
        {
            resize(m_size + 1);
            m_valA[m_size - 1] = sum;
        }

        return *this;
    }

    void divMod(uint32_t rhs, uint32_t& rMod)
    {
        uint64_t div = 0;
        for (int iVal = m_size - 1; iVal >= 0; --iVal)
        {
            div <<= 32u;
            div += m_valA[iVal];

            uint64_t val = div / rhs;
            div -= val * rhs;

            if (val || iVal == 0 || iVal < m_size - 1)
            {
                m_valA[iVal] = val;
            }
            else
            {
                --m_size;
            }
        }

        rMod = div;
    }

    void toDecString(std::string& rStr) const
    {
        std::vector<char> digits;

        BigUint rem(*this);
        while (rem.m_size > 1 || rem.m_valA[0])
        {
            uint32_t digit = 0;
            rem.divMod(10, digit);
            digits.push_back(digit);
        }

        if (digits.empty())
        {
            rStr = "0";
        }
        else
        {
            rStr.clear();
            rStr.reserve(digits.size());

            for (int iDigit = digits.size() - 1; iDigit >= 0; --iDigit)
            {
                rStr.append(1, '0' + digits[iDigit]);
            }
        }
    }

private:
    static const int MIN_CAP = 8;

    void resize(int newSize)
    {
        if (newSize > m_cap)
        {
            uint32_t* newValA = new uint32_t[newSize];

            for (int iVal = 0; iVal < m_size; ++iVal)
            {
                newValA[iVal] = m_valA[iVal];
            }

            if (m_cap > MIN_CAP)
            {
                delete[] m_valA;
            }

            m_cap = newSize;
            m_valA = newValA;
        }

        for (int iVal = m_size; iVal < newSize; ++iVal)
        {
            m_valA[iVal] = 0;
        }

        m_size = newSize;
    }

    int m_size;
    int m_cap;

    uint32_t* m_valA;
    uint32_t m_fixedValA[MIN_CAP];
};

#endif // BIG_UINT_H

Fantom
Here's an initial post that sets up the framework. I think the procedure is a relatively good one, but the implementation right now kind of sucks. I need to probably try to minimize the number of calculations I'm doing, and instead just pass more constants.
Strategy
Basically, each white pawn must be attacking other white pawns. So I start by placing a white pawn, placing pawns in each place it attacks, and essentially filling in the board with all the places a white pawn HAS to go. I stop if I've added too many white pawns already. If, at the end of this, I have exactly 2n^2 pawns, it's a solution. If less than that, add another white pawn somewhere, fill out all his required places, and count again. I recursively split every time a fill with less than 2n^2 is found, and calculate number of solutions with and without the last pawn I added.
Code
class main
{
  public  Void main(){

    echo(calculate(1))
    echo(calculate(2))
    echo(calculate(3))
    echo(calculate(4))
    echo(calculate(5))

  }

  public static  Int calculate(Int n){

    n *= 2
    //Initialize the array -  Definitely a weakpoint, but only runs once
    Bool[][] white := [,]
    n.times{
      row := [,]
      n.times{ row.add(false) }
      white.add(row)
    }

    return recurse(white, -1, 0, n, n*n/2)
  }

  private static  Int recurse(Bool[][] white, Int lastPlacement, Int numWhites, Int n, Int totalWhite){
    if(totalWhite - numWhites > n*n - 1 - lastPlacement) return 0
    lastPlacement++
    Int row := lastPlacement / n
    Int col := lastPlacement % n
    if(white[row][col]){ return recurse(white, lastPlacement, numWhites, n, totalWhite)}
    Bool[][] whiteCopy := copy(white)
    whiteCopy[row][col] = true
    Int result := fillIn(whiteCopy, numWhites + 1, totalWhite)
    if(result == -1){
      return recurse(white, lastPlacement, numWhites,n, totalWhite);
    }
    else if(result == totalWhite){
      //echo("Found solution")
      //echo("WhiteCopy = $whiteCopy")
      return recurse(white, lastPlacement, numWhites,n, totalWhite) + 1;
    }
    else return recurse(whiteCopy, lastPlacement, result,n, totalWhite) + recurse(white, lastPlacement, numWhites,n, totalWhite)

  }

  //Every white must be attacking other whites, so fill in the grid with all necessary points
  //Stop if number of whites used goes too high
  private static Int fillIn(Bool[][] white, Int count, Int n){
    white[0..-2].eachWhile |Bool[] row, Int rowIndex -> Bool?| {
      return row.eachWhile |Bool isWhite, Int colIndex -> Bool?|{
        if(isWhite){
          //Catching index out of bounds is faster than checking index every time
          try{
            if(colIndex > 0 && !white[rowIndex + 1][colIndex - 1]){
              white[rowIndex + 1][colIndex - 1] = true
              count++
            }
            if(!white[rowIndex + 1][colIndex + 1]){
              white[rowIndex + 1][colIndex + 1] = true
              count++
            }
          } catch {}
        }
        if(count > n){ count = -1; return true}
        return null
      }//End row.each
    }//End white.each
    return count
  }

  private static Bool[][] copy(Bool[][] orig){
    Bool[][] copy := [,]
    orig.each{
      copy.add(it.dup)
    }
    return copy
  }

}

Output
Only makes it to 5 right now, but I think most of the issue is in implementation.
3
30
410
6148
96120

Test

That's my strategy too, but seems way too slow compared to the other solutions posted here.

@edc65 Approaches that enumerate the solutions won't have a chance. If there were any doubts, the sheer number produced by feersum's algorithm is proof of that. Some kind of dynamic programming algorithm that calculates the number of solutions without enumerating them is the way to go here.


text:
Fill a water balloon
In this challenge, you must display ASCII art of a water balloon given the
amount of water that the balloon is filled with:
|  __||__  |
| / #   #\ |
| |######| |
| |######| |
| |######| |
| |######| |
| |######| |
| \######/ |
|          |
|          |
+----------+

How to draw the balloon
To display a balloon of size n, follow the following steps (note: whenever
the division symbol (/) is used, it represents integer division, rounding
down):

Draw a container consisting of ten vertical bars (|) on the left and right,
ten dashes (-) on the bottom, and a plus sign (+) in the bottom left and
bottom right corner. This makes the whole thing 12x11, and the "inside"
10x10.
|          |
|          |
|          |
|          |
|          |
|          |
|          |
|          |
|          |
|          |
+----------+

Draw two vertical bars (the opening of the balloon) centered in the middle
of the top row, with n/2 underscores (_) on either side (for this example,
n will be 5):
|  __||__  |
|          |
|          |
|          |
|          |
|          |
|          |
|          |
|          |
|          |
+----------+

Draw one slash (/) and one backslash (\) surrounding this top row, one
row below:
|  __||__  |
| /      \ |
|          |
|          |
|          |
|          |
|          |
|          |
|          |
|          |
+----------+

Draw n rows of identically-spaced vertical bars, and then one row of a
pair of (still identically-spaced) backslash and slash:
|  __||__  |
| /      \ |
| |      | |
| |      | |
| |      | |
| |      | |
| |      | |
| \      / |
|          |
|          |
+----------+

"Fill" the balloon with water, represented by a hash sign (#). Start at
the lowest row, and work upwards. If a row is not entirely filled, you may
place the hash marks wherever you want (in the below example, they are
placed randomly, but you could put them, say, all on the left side if you
want).
|  __||__  |
| / #   #\ |
| |######| |
| |######| |
| |######| |
| |######| |
| |######| |
| \######/ |
|          |
|          |
+----------+

The maximum n is 7, and the minimum is 0.
Input
The input will be an integer i, which is the amount of hash marks (water)
that must be drawn.
It will never be less than 2, or greater than 100.
Output
The output should be a balloon of size n containing i hash marks (units of
water), where n is the lowest possible size that can hold i units of water.
Since i will always be 2 or greater, n will always be 0 or greater.
The maximum possible size a balloon can be drawn at is n = 7. If a size 7
balloon cannot fit the amount of water specified, the balloon pops:
|          |
|          |
|##  #  ###|
|##########|
|##########|
|##########|
|##########|
|##########|
|##########|
|##########|
+----------+

(The above should be the output for input i = 76. Just like the unpopped
balloon, the six extra units of water on the top row may be arranged however
you please.)
Test cases
Why have one test case, when you can have all of them?
Here's an animated GIF of all inputs i from 2 to 100:

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

Related.

Octave, 523 bytes
23 of those bytes are just for the n=100 case.  Maybe someone can suggest a more efficient way...
n=input(0);x=zeros(11,6)+32;x(:,1)=124;x(11,:)=45;x(11,1)=43;
if n<5
w=3;h=2;a=2;
elseif n<7
w=3;h=3;a=2;
elseif n<17
w=4;h=4;a=4;
elseif n<37
w=5;h=6;a=6;
else
w=6;h=9;a=8;
end
if n<73
x(1,6)=124;x(1,9-w:5)=95;x(2,8-w)=47;x(3:1+h,8-w)=124;x(1+h,8-w)=92;x(2:1+h,9-w:6)=35;x=[x,fliplr(x)];x(2,5+w)=92;x(1+h,5+w)=47;x(2:1+floor((a*h-n)/a),9-w:4+w)=32;x(2+floor((a*h-n)/a),9-w+a-mod(a-n,a):4+w)=32;
else
x=[x,fliplr(x)];x(max(1,ceil((100-n)/10)):10,2:11)=35; if (n<100) x(ceil((100-n)/10),(2+mod(n,10)):11)=32; end
end
char(x)

Test
Input: 21
Output:

|  __||__  |
| /      \ |
| |      | |
| |###   | |
| |######| |
| |######| |
| \######/ |
|          |
|          |
|          |
+----------+

Python 2, 591 bytes
Took me some time and it probably could be golfed much more.
Hope there aren't any major errors.
r=[list(x)for x in ("|          |!"*10+"+----------+").split('!')]
s,t=[0]*4+[1]*2+[2]*10+[3]*4+[4]*16+[5]*6+[6]*22+[7]*8+[8]*29,[(4,2,2),(4,3,2),(3,4,4),(3,5,4),(2,6,6),(2,7,6),(1,8,8),(1,9,8),(0,9,10)]
a,b,c,d,e='|','/','\\','_','#'
def p(x,y,w):r[y][x]=w
def q(l):
 h,j,u=l
 p(5,0,a);p(6,0,a)
 for o in range(4-h):p(h+o+1,0,d);p(h+u-o,0,d)
 p(h,1,b);p(h+u+1,1,c)
 for o in range(j-2):p(h,o+2,a);p(h+u+1,o+2,a)
 p(h,j,c);p(h+u+1,j,b)
def w(i,l):
 h,j,u=l
 for o in range(i):x,y=o%u,o/u;p(h+x+1,j-y,e)
def f(i):
 n=s[i]
 l=t[n]
 if n<8:q(l)
 w(i,l)
 print "\n".join(["".join(x)for x in r])

Example run:
f(34)

gives:
|  __||__  |
| /####  \ |
| |######| |
| |######| |
| |######| |
| |######| |
| \######/ |
|          |
|          |
|          |
+----------+

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Workweek completion
I work from Monday to Friday. I start my day at 8:12 and have lunch from 12:00 to 12:42. My workday ends at 16:30.
If you are wondering why 8:12 and 12:42:

8:00 is the goal, but I never actually make it
12:42 because I take 45 minute breaks, but this works better for the challenge spec

Challenge
Write a function or full program that returns the smallest fraction of time I have worked and still need to work for the current week. The interval you must use is 6 min.
Each day has 76 six-minute intervals

Examples
Monday 02:00 -> 0/1
Monday 08:24 -> 1/190
Monday 18:00 -> 1/5
Saturday xx:xx -> 1/1

Monday 08:17 -> 0/1
Monday 08:18 - Monday 08:23 -> 1/380

Scoring
Shortest code win but golfing languages get a *3 multiplier.

Pyth
CJam
GolfScript

(note to self: add more)

Edit: I've lowered the modifier, but I will not remove it. Some languages have some overhead like variable declaration and other long keywords; function ,return, etc. I don't want to discourage someone from writing the skeleton of a method in their chosen language because it's longer than a complete CJam answer.

perl,j,k,piet,APL etc.

4.5 is a very high multiplier. Python and Mathematica (and some other) languages can easily come withing 2-3 x of CJam for non-trivial challenges.

-1 for arbitrary language bias.

The point here should only be code size on similar challenges as this is code-golf.

Should we change this to [code-challenge], then?

I'm voting to close this question as off-topic because the incomplete description/list of what constitutes a golfing language makes it impossible to objectively score solutions.

I would just remove the golf-lang restriction. (I'm also giving it a +1 for the rest of the question, by the way)

C++: 204 bytes
g++ 4.9.2
int f(char*a){int d=380,n=*a-'M'?*a-'W'?*a-'F'?*a-'S'?a[1]-'u'?3:1:5:4:2:0,m,h;sscanf(a,"%*s%d:%d",&h,&m);h=(m=h*10+m/6-82)<38?m:m>83?76:m-7;n=min(d,n*76+max(h,0));m=__gcd(n,d);printf("%d/%d\n",n/m,d/m);}

Live demo
Same as old answer, just replaced 5 ternary conditions of form a==b?c:d with a-b?d:c to save 1 byte each condition. Rest of the explanation remains same.

Old answer:
C++: 210 bytes

    int f(char*a){int d=380, n=*a=='M'?0:*a=='W'?2:*a=='F'?4:*a=='S'?5:a[1]=='u'?1:3,m,h;sscanf(a,"%*s%d:%d",&h,&m);h=(m=h*10+m/6-82)83?76:m-7;n=min(d,n*76+max(h,0));m=__gcd(n,d);printf("%d/%d\n",n/m,d/m);}

Live demo
Explanations
int f(char* a) {  // Function name. Returning int instead of void to save one char
    int d=380;  // denominator

    int n= *a == 'M' ?  // Number of days
               0 :  // Monday
               *a == 'W' ?
                   2 :  // Wednesday
                   *a == 'F' ?
                       4 :  // Friday
                       *a == 'S' ?
                           5 :  // Saturday or Sunday
                           a[1] == 'u' ?
                                 1 :  // Tuesday
                                 3;   // Thurdays

    int m, h;  // Minutes and hours

    sscanf(a, "%*s%d:%d", &h, &m);  // %*s - Skip day, %d:%d - Read hour and min

    h= (
         m=h*10+m/6-82  // Calculate (h * 60 + m) / 6 - (8 * 60 + 12) / 6
       ) < 38 ? m       // Before lunch
              : m>83 ? 76  // If it is past end of day 76) clamp to 76
                     :m-7; // After lunch, subtract lunch time

    n = min(d,                  // numerator (n) can not be more than denominator
            n * 76 + max(h,0) ); // Number of day * units (6 min) per day + units of current day (from time) clamped to 0 if negative

    m=__gcd(n, d);  // Find gcd to get normalized form of rational number

    printf("%d/%d\n", n/m, d/m);  // Print the result
}  // Function ends

Welcome to PPCG!  Correct answers are great - but you'll garner more votes if you explain what's clever about your solution.  There are various ways to do that; one that's popular is a formatted, annotated version of the same code.  Any chance of obliging?  Thanks.  It's good to see you here; happy golfing!

@TobySpeight Thanks for the welcome words and the suggestion. I looked at a few posts to understand what you mean. I will add similar description in my code also.

@TobySpeight Done

Where does __gcd come from?

@rink.attendant.6 std::__gcd is exposed in C++ library in gcc compilers.

Python - 195 bytes
Very simple, uses fractions library for simplest terms. Had a Pyth solution, but the *4.5 was too much.
from fractions import*
z=raw_input()
Q=input()
n=("SMTWTF".index(z[0])-1if z[0]!='T'else"uh".index(z[1])*2+1)*76
Q=max(Q[0]*10+Q[1]/6-82,0)
print Fraction(n+(min(Q, 38)if Q<45 else min(Q-7,76)),380)

Takes input in two lines, the time as a tuple, since no input format was specified.

JavaScript (ES6), 201 191 bytes
f=i=>{z=(a,b)=>b?z(b,a%b):a,i=/(\w+) (\d+):(\d+)/.exec(i),t=+i[3]/6+i[2]*10-82;t=i[0][0]=='S'?380:'neduit'.indexOf(i[1][2])*76+(t<0?0:t>82?76:t>45?t-7:t>38?38:t);g=z(t,380);return+t/g+'/'+380/g}

ECMAScript 5: 223 214 bytes
function f(i){z=function(a,b){return!b?a:z(b,a%b)},i=/(\w+) (\d+):(\d+)/.exec(i),t=+i[3]/6+i[2]*10-82;t=i[0][0]=='S'?380:'neduit'.indexOf(i[1][2])*76+(t<0?0:t>82?76:t>45?t-7:t>38?38:t);g=z(t,380);return+t/g+'/'+380/g}

Ungolfed

function f(input) {
    var greatestCommonDivisor = function (a, b) {
        // From https://stackoverflow.com/a/17445304/404623
        return !b ? a : greatestCommonDivisor(b, a % b);
    };

    // Get input from string
    var input = /(\w+) (\d+):(\d+)/.exec(input);

    // Parse time relative to day
    var t = Number(input[3]) / 6 + Number(input[2]) * 10 - 82;

    var m, g, divisor;

    if (input[0][0] == 'S') {
        // Weekend - week is over
        m = 380;
    } else {
        if (t < 0) {
            // Before start of work day
            m = 0;
        } else if (t > 82) {
            // After end of work day
            m = 76;
        } else if (t > 45) {
            // After lunch
            m = t - 7;
        } else if (t > 38) {
            // During lunch
            m = 38;
        } else {
            m = t;
        }

        // Indices correspond to third letter of day of week
        m += 'neduit'.indexOf(input[1][2]) * 76;
    }

    // Find common divisor
    divisor = greatestCommonDivisor(m, 380);

    // Return value
    return m / divisor + '/' + 380 / divisor;
}

function f(i) {
  z = function(a, b) {
    return !b ? a : z(b, a % b)
  }, i = /(\w+) (\d+):(\d+)/.exec(i), t = +i[3] / 6 + i[2] * 10 - 82;
  t = i[0][0] == 'S' ? 380 : 'neduit'.indexOf(i[1][2]) * 76 + (t < 0 ? 0 : t > 82 ? 76 : t > 45 ? t - 7 : t > 38 ? 38 : t);
  g = z(t, 380);
  return t / g + '/' + 380 / g
}

['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'].forEach(function(d) {
  var str;
  for (var h = 8; h < 17; h++) {
    for (var m = 0; m < 60; m += 6) {
      str = d + ' ' + (h < 10 ? '0' + h : h) + ':' + (m < 10 ? '0' + m : m);
      document.body.innerHTML += str + ' -> ' + f(str) + '<br>';
    }
  }
});

Assumes that Sunday is the last day of the week.

PHP, 254 bytes
This is just a port of my JavaScript answer. Due to PHP's odd behaviour with ternary operators, parentheses are necessary.
function z($a,$b){return$b?z($b,$a%$b):$a;}function f($q){preg_match('/(\w+) (\d+):(\d+)/',$q,$i);$t=$i[3]/6+$i[2]*10-82;$t=$i[0][0]=='S'?380:strpos('neduit',$i[1][2])*76+($t<0?0:($t>82?76:($t>45?$t-7:($t>38?38:$t))));$g=z($t,380);return$t/$g.'/'.(380/$g);}

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Play a Perfect Game of 4x4 Hex
Background
Hex is a two-player abstract strategy game played on a K×K rhombus of hexagonal tiles.
Two opposite sides of the rhombus are colored white, and the other two black, and the two players, black and white, take turns in placing a token of their color on an unoccupied tile.
The player who first manages to construct a path between the opposite sides of their color is the winner.
It is known that the game cannot end in a draw, and that the first player has a winning strategy regardless of the board size (see the Wikipedia page for details).
The Task
In this challenge, we fix the board size at K = 4, and represent the board as the following grid.
The thick lines denote adjacent tiles.

Your task is to produce a winning strategy for the first player, which you can choose to be either black or white.
This means that whichever legal moves the opposing player makes, your play must result in a victory.
Your input is a game position (the arrangement of tokens on the board), and your output is a legal move, in the format specified below.
If you want to find a winning strategy yourself, do not read this spoiler:

 Outline of one possible winning strategy, assuming white goes first.

 First select 5. After that, if you have a path from 5 to the bottom row OR black selects 0 or 1 at any point, respond by selecting whichever of 0 or 1 is vacant.

 If black selects 9 or 13, select 10 and then whichever of 14 or 15 is vacant. If black does not select 9, 13 or 14, then select 9 and next whichever of 13 or 14 is vacant.

 If black selects 14, respond by selecting 15. Next, select 10 if it is vacant; if black selects 10, respond with 11. If black then selects 6, respond with 7, and next whichever of 2 or 3 is vacant. If black does not select 6, select it, so you have a path from 5 to the bottom row.

Input and Output
Your input is a string of 16 characters WBE, which stand for white, black and empty.
They represent the tiles of the board, as enumerated above.
You can choose the input method (which also determines your output method) from the following:

Input from STDIN, output to STDOUT.
Input as one command line argument, output to STDOUT.
Input as 16 single-character command line arguments, output to STDOUT.
Input as argument of named function, output as return value.

Your output represents the tile on which you place your next token, as it is your turn to move.
You can choose from the following output formats:

A zero-based index (as used in the above picture).
A one-based index.
The input string with one E replaced by whichever of W or B you chose for your player.

Rules
Your strategy must be deterministic.
You are not required to correctly handle game positions that are unreachable from the empty board using your strategy, or positions that are already winning for either player, and you may crash on them.
Conversely, on boards that are reachable using your strategy, you must return a legal move.
This is code-golf, so the lowest byte count wins.
Standard loopholes are disallowed.
Testing
I have written a Python 3 controller for validating entries, since it would be extremely tedious to do by hand.
You can find it here.
It supports the first three input formats and Python 3 functions (functions in other languages have to be wrapped into programs), all three output formats, and both players.
If a strategy is not winning, it will output a losing game it found, so you can tweak your program.

This challenge reminds me of trying to compress a tic tac toe AI when I was writing calculator programs.
http://www.ticalc.org/archives/files/fileinfo/354/35408.html

Incorrect response 'WWWWWWWWBBBBBBBB' to message 'WWWWWWWWBBBBBBBB'. I should have won long ago, or am I wrong?

@SebastianHöffner That looks like a bug in the controller. I'll try to fix it when I have time.

@SebastianHöffner The bug should now be fixed.

Marbelous, 973b
This is a naive implementation of the hinted strategy in the question. It expects the board to be provided as 16 commandline/mainboard parameters like hex.mbl B W E E E W E E E B E E E E E E and it will output the zero-indexed position of white's next move.
00 }1 }0
&G B? W!
&0 &G &G
!!
00 }0 }1
&H B? W!
&1 &H &H
!!
.. }D .. }9 }9 }D }E }A }D }9 }A .. }E }F }5
}9 B! }E E? W? E? .. E? B? B? W? .. E? .. E?
B! ?0 B! &M &N &O E? &I \\ .. &J .. &K E? &5
?0 ++ ?0 &9 .. &D &P &A &I /\ &J .. &E &L !!
++ .. ++ !! .. !! &E !! \/ &L /\ &K !! &F
\\ .. // .. .. .. !! .. .. \/ .. \/ .. !!
.. =3 \/
&M /\ &N
\/ &O /\ &P
}0 }1 }6 .. }6 .. }7 &7 }2 }3 }A }A }B }E }F
..
..
..
..
..
..
..
..
..
.. .. .. .. .. .. .. .. .. .. .. .. .. B? W!
.. .. .. .. .. .. .. .. .. .. .. .. .. &Q &Q
.. .. .. .. B? .. E? W? E? .. E? B? E? &F \/
.. .. .. &S /\ &T &S &T &U E? &A &R &R !!
.. .. .. &7 .. .. \/ .. &2 &V !! &B \/
.. .. .. !! .. .. &U /\ &V &3 .. !!
.. .. .. .. .. .. .. .. .. !!
.. .. ..
.. .. E?
E? .. &6
&X E? !!
!! &Y
.. !!
}4 }8 }C
\/ \/ \/
30 30 31 31 32 33 35 36 37 39 31 30 31 31 31 33 31 34 31 35
&0 &X &1 &Y &2 &3 &5 &6 &7 &9 &A &A &B &B &D &D &E &E &F &F
:W?
}0
^4
=1
{0
:B?
}0
^0
=0
{0
:E?
}0
^1
=0
{0
:W!
}0
^4
=0
{0
:B!
}0
^0
>0
{0

I think I can probably golf about 200 characters out of this with better branching and elimination of code re-use.

I added the option for 16 command line argument and updated the verifier script, so this solution can be tested.

Marbelous +1 (PPCG thinks adding these characters improved the comment)


text:
Rotate a diamond tiling
Any regular hexagon can be tiled with diamonds, for instance like so (stolen from this question):
   ______
  /_/_/\_\
 /_/\_\/\_\
/\_\/_/\/_/\
\/_/\_\/_/\/
 \_\/_/\_\/
  \_\_\/_/

We'll consider the above a tiling of size 1 (since the diamonds' sides are made of one / or \ each). The same tiling of size 2 would look like:
      ____________
     /   /   /\   \
    /___/___/  \___\
   /   /\   \  /\   \
  /___/  \___\/  \___\
 /\   \  /   /\  /   /\
/  \___\/___/  \/___/  \
\  /   /\   \  /   /\  /
 \/___/  \___\/___/  \/
  \   \  /   /\   \  /
   \___\/___/  \___\/
    \   \   \  /   /
     \___\___\/___/

Your task is to rotate diamond tilings by a multiple of 60 degrees. The diamond tiling in the input can be in any size (and the size is not explicitly specified in the input). But it would always be a valid tiling, and all sides of the hexagon would have the same length.
These are the above examples rotated by 60 degrees clockwise:
   ______
  /_/\_\_\
 /\_\/_/\_\
/\/_/\_\/_/\
\/\_\/_/_/\/
 \/_/\_\_\/
  \_\/_/_/

      ____________
     /   /\   \   \
    /___/  \___\___\
   /\   \  /   /\   \
  /  \___\/___/  \___\
 /\  /   /\   \  /   /\
/  \/___/  \___\/___/  \
\  /\   \  /   /   /\  /
 \/  \___\/___/___/  \/
  \  /   /\   \   \  /
   \/___/  \___\___\/
    \   \  /   /   /
     \___\/___/___/

The input is a non-negative integer and a diamond tiling. Your program (or function) should rotate it by the integer * 60 degrees. You decide whether to rotate clockwise or counterclockwise, as long as it is consistent. Both the input and output shouldn't have extra leading or trailing spaces.
This is code-golf. Shortest code wins.
Related questions:

Rotate a Chinese checkerboard
Rotate a two-dimensional list by 45 degrees
Scale up a Diamond Tiling

Martin will be so jealous!

JavaScript (ES6), 452 356 315 bytes
Where \n represents the literal newline character. Edit: Saved 96 bytes by realising that my algorithm doesn't need to know the number and size of diamonds separately, plus a few minor golfs that I missed the first time around. Saved 41 bytes by rearranging the code so that the destination was always the same pair of characters, plus a minor golf that I missed when converting to my previous algorithm.

r=
(s,n)=>(z=s.search`_`,l=(f,n=z*2+1)=>[...Array(n)].map(f),a=s.split`\n`,l(_=>(o=a.map(s=>[...s].fill` `),l((_,r)=>l((_,c)=>(d=z+c*2-r,a[s=z+r-c]&&(a[s][r+c]=='/'?o[r][d]=o[r][d+1]='_':0,a[s][r+c-1]=='\\'?o[r][d]='/':0),a[--s]&&(a[s][r+c]==`_`||a[s][r+c-1]==`_`?o[r][d+1]=`\\`:0)))),a=o.map(a=>a.join``)),n),a.join`\n`)
;

   ______
  /_/_/\_\
 /_/\_\/\_\
/\_\/_/\/_/\
\/_/\_\/_/\/
 \_\/_/\_\/
  \_\_\/_/

<input type=button value="Rotate!" onclick="i1.textContent = r(i1.textContent, 1)">

      ____________
     /   /   /\   \
    /___/___/  \___\
   /   /\   \  /\   \
  /___/  \___\/  \___\
 /\   \  /   /\  /   /\
/  \___\/___/  \/___/  \
\  /   /\   \  /   /\  /
 \/___/  \___\/___/  \/
  \   \  /   /\   \  /
   \___\/___/  \___\/
    \   \   \  /   /
     \___\___\/___/

<input type=button value="Rotate!" onclick="i2.textContent = r(i2.textContent, 1)">

Explanation: Considers each pair of output characters, which could be __, /_, _\, / or \, checking for the appropriate characters in the input which map to those output characters. Ungolfed:
function rotate(str, num) {
  // Measure the size using the indent of the _ in the first row.
  var size = str.indexOf('_');
  var arr = str.split('\n');
  while (num--) {
    // We build a character array to represent the output by turning the
    // input into a nested array and replacing everything with spaces.
    // Note that the output will have any trailing spaces from the input.
    var res = arr.map(s => Array.from(s).fill(' '));
    // Loop over a diamond that encloses the hexagon.
    for (var destrow = 0; destrow <= size * 2; destrow++) {
      for (var col = 0; col <= size * 2; col++) {
        var destcol = size + col * 2 - destrow;
        var srcrow = size + destrow - col;
        var srccol = destrow + col;
        // Map / to __, \ to / and __ to \.
        // We write __ first in case it gets overwritten by / or \.
        if (arr[srcrow]) {
          if (arr[srcrow][srccol] == '/') {
            res[destrow][destcol] = res[destrow][destcol + 1] = '_';
          }
          if (arr[srcrow][srccol - 1] == '\\') {
            res[destrow][destcol] = '/';
          }
        }
        // Need to check both positions in case one was overwritten.
        if (arr[srcrow - 1] &&
            (arr[srcrow - 1][srccol] == '_' || arr[srcrow - 1][srccol - 1] == '_')) {
          res[destrow][destcol + 1] = '\\';
        }
      }
    }
    arr = res.map(a => a.join(''));
  }
  return arr.join('\n');
}

Pyth, 81 bytes
ju.es.e.reh|@s.e.e[yYykZ)bGCa+LV,t-y+k*3Y*5J-+kY/lG2Jc2j406610 4K"_/\\_\\"dKbGQ.z

Try it online
Rotates counterclockwise.
Each 60° rotation is performed using the following algorithm.  Suppose the input is a hexagon of order k, so it has 2⋅k + 1 rows and 4⋅k columns.  To find the rotated character at row i column j, let

u = i + j − k
v = j − 3⋅i + 5⋅k

Then the output character is

\, if the input has / at row (u + 1)/2 column (v + 1)/2; else
/, if the input has _ at row u/2 column v/2 or row u/2 column (v + 2)/2; else
_, if the input has \ at row (u + 2)/2 column v/2 or row (u + 1)/2 column (v − 1)/2; else
space.

(We do not count characters at half-integer indices.)

I think you can guarantee which positions have \ s, it's just the _s that you have to check in both places.

@Neil Yes, you know where the \ s are, but you might have to draw two _s for each \ .

Oh, you check each underscore separately?


text:
Highest perimeter polyomino
This is code golf. The winner is the valid code with the smallest number of bytes.

Challenge
Given inputs M and N, the width and height of a rectangular grid of squares, output a polygon that satisfies the following:

The polygon edges are made up only of square edges: there are no diagonal edges - all are vertical or horizontal.
The polygon has no holes: every square outside the polygon may be reached by orthogonal steps on squares outside the polygon, starting from a square outside the polygon on the outer boundary of the rectangle.
The polygon has no self-intersection: of the square edges meeting at a vertex, no more than 2 may be part of the polygon perimeter.
The polygon is connected: any square in the polygon must be reachable from any other square in the polygon via orthogonal steps that stay within the polygon.
The polygon has the maximum possible perimeter: according to the formula shown below.

Your code must work for M and N from 1 to 255.

Formula for maximum perimeter
The challenge here is finding the most golfable of those polygons with the maximum perimeter. The maximum perimeter itself is always defined by the formula:

This is true because for a maximum perimeter every square vertex must be on the perimeter. For an odd number of vertices this is not possible and the best that can be attained is one vertex less (since the perimeter is always even).

Output
Output the shape as a string of newline separated characters (N rows of exactly M characters). Here I am using space for squares outside the polygon, and '#' for squares inside the polygon, but you may use any two visually distinct characters, provided their meaning is consistent for all inputs.
You may include up to one leading newline and up to one trailing newline.
If you wish, you may instead output M rows of exactly N characters, and you may choose M by N output for some inputs and N by M output for others.

Examples
Invalid due to a hole:
###
# #
###

Invalid due to intersection (touching diagonally - a vertex with 4 square edges on the perimeter) and, incidentally, a hole:
##
# #
###

Invalid due to being disconnected:
#
# #
  #

Valid polygon of maximum perimeter:
# #
# #
###

Credits
I initially underestimated how quickly the value of the maximum perimeter could be calculated, and was going to just ask for that value as the output. Thanks to the wonderfully helpful people in chat for explaining how to work out the maximum perimeter for arbitrary N and M and helping turn this into a challenge that will last for more than one answer...
Specifically thanks to:
Sparr, Zgarb, feersum, jimmy23013.

I could name this question using polyominos or polygons (since both apply). Does anyone have a preference? You can indicate with comment voting on the following:

Highest perimeter polyomino

Highest perimeter connected polygon

N rows of exactly M characters: can we interchange the two input values if we find it convenient for certain inputs?

@steveverrill Both inputs are from 1 to 255. I can't see a benefit to switching their order. Do you mean outputting in a different order, or something else I'm missing?

(even if there's a benefit I'm inclined to insist on the output being aligned as specified, but I'll delay making the decision until I'm sure I haven't misunderstood something)

For example, if you have a particular strategy for shapes with one side even and one side odd, you might prefer to draw an odd number of lines with an even number of characters. That would be great if M was even and N was odd. But if the user decides to give the odd number first then the even number, can we switch them round?

@steveverrill that makes perfect sense now - thank you. I'll leave it as is for now while I think about it, as it's easier to make that change forwards than backwards, and I'll let you know what I decide after a think.

@steveverrill I've edited the Output section. Does that fit your request?

That suits me fine! First upvote on your last comment is not mine, so I guess it suits someone else, too.

That change in the output rules should make it simpler. Of course it was your choice if you wanted to make it easier. BTW, I believe I know how to solve this cleanly. So in the likely case that somebody else posts the same kind of solution first before I get to work on it tonight: I did not steal their idea! :)

@RetoKoradi yes I'm happy making it slightly easier in order to see a different approach

@RetoKoradi I only see it as making the output easier, which isn't the point of the challenge, so I'm happy with it

I think this will be all about generating the output with the shortest possible code. The pattern that needs to be generated looks fairly straightforward. As I expected, @steverrill already implemented exactly the pattern I also had in mind.

@RetoKoradi yes that's what I expected. Unless some languages find different patterns more suitable for golfing most people will probably choose similar patterns.

CJam, 47 bytes
l~_2%{\}|_'#:H*@({N+1$(2md\HS+*H+\SH+R=*++}fR\;

Try it online
Explanation:
l~      Get and convert input.
_2%     Calculate second value modulo 2.
{\}|    If value is even, swap the two inputs. This puts odd on top if one is odd.
_'#:H*  Create top row of all # signs. Also save away # character as shortcut for later.
@(      Pull number of rows to top, and decrement because first is done.
{       Start loop over rows.
N+      Add newline.
1$      Copy row length to top of stack.
(2md    Decrement, and calculate mod/div with 2.
\       Swap mod and div, will use div first.
HS+     "# "
*       Repeat it based on div 2 of row length.
H+      Add one more #.
\       Swap mod of earlier division to top.
SH+     " #"
R=      Pick space or # depending on even/odd row number.
*       Repeat 0 or 1 times depending on mod 2 of row length.
+       Add the possible extra character to line.
+       Add line to result.
}fR     End of for loop over lines.
\;      Remove row length from stack, leaving only result string.

There are two main cases for the result. If at least one of the sizes is odd, the pattern is a plain "rake". For example, for input 7 6:
#######
# # # #
# # # #
# # # #
# # # #
# # # #

If both sizes are even, there is an extra column where every second square is "on". For example, for input 8 6:
########
# # # #
# # # ##
# # # #
# # # ##
# # # #

Now, to show that these patterns reach the theoretical maximum of the perimeter as given in the problem description, we need to confirm that the first pattern has perimeter (M + 1) * (N + 1), and the second one the same value minus 1.
For the first pattern, we have for the perimeter, with M an odd dimension:

M for the top edge.
2 on the side of the top row.
(M - 1) / 2 for the gaps between the teeth.
(M + 1) / 2 teeth with perimeter 2 * (N - 1) + 1 each.

This adds up to:
M + 2 + (M - 1) / 2 + (M + 1) / 2 * (2 * (N - 1) + 1) =
M + 2 + (M - 1) / 2 + (M + 1) * (N - 1) + (M + 1) / 2 =
2 * M + 2 + (M + 1) * (N - 1) =
(M + 1) * 2 + (M + 1) * (N - 1) =
(M + 1) * (N + 1)

For the second case where both M and N are even, the perimeter adds up from:

M for the top edge.
2 on the side of the top row.
M / 2 for the open # in the top row.
M / 2 teeth with perimeter 2 * (N - 1) + 1 each for the plain teeth.
The rightmost tooth has an extra 2 * (N / 2 - 1) perimeter pieces for the jaggies.

Adding this all together:
M + 2 + M / 2 + (M / 2) * (2 * (N - 1) + 1) + 2 * (N / 2 - 1) =
M + 2 + (M / 2) * (2 * (N - 1) + 2) + N - 2 =
M + M * N + N =
(M + 1) * (N + 1) - 1

I think I can save a couple of bytes by placing the jagged part on the left. Should require some less stack shuffling. But it's time to sleep...

Ruby, Rev 1, 66
->(m,n){n.times{|i|puts ("#"*m**(1-i%2)).rjust(m,i>n-2?"# ":" ")}}

Used raising m to power 0 o 1 to decide whether 1 or m #'s will be printed.
Used > to test for last row instead of ==.
Can't get rid of the space after puts, nor any brackets!
Ruby, Rev 0, 69
->(m,n){n.times{|i|puts ("#"*(i%2==0?m:1)).rjust(m,i==n-1?"# ":" ")}}

This is an anonymous lambda function. Use it like this:
f=->(m,n){n.times{|i|puts ("#"*(i%2==0?m:1)).rjust(m,i==n-1?"# ":" ")}}

M=gets.to_i
N=gets.to_i
f.call(M,N)

In the end, after asking if M and N could be interchanged I didnt need it.

Typical outputs for N odd. If we delete the # on their own on the right hand side, clearly we will have (N+1)(M+1). Including them to join the shape removes 2 squares of horizontal perimeter and adds 2 squares of vertical perimeter, so there is no change.
Here we rely on the expression "#"*(i%2==0?m:1) to give alternating rows of M# symbols and one # symbol, and right justify to M characters.
5                        6
5                        5
#####                    ######
    #                         #
#####                    ######
    #                         #
#####                    ######

Typical outputs for N even. 5 6 clearly has the same perimeter as 6 5, or an increment of M+1=6 compared with 5 5 by addition of vertical perimeter due to the crenelation of the bottom row. 6 6 has the same as 6 5 plus an increment of (M+1)-1=6 in the vertical perimeter. Thus they are in accordance with the formula.
5                        6
6                        6
#####                    ######
    #                         #
#####                    ######
    #                         #
#####                    ######
# # #                    # # ##

It's very handy that Ruby's rjust allows you to specify the padding to use for the empty cells. Normally the padding is set to " " but for the last row we switch to "# " (note that padding will only be needed on the last row if N is even. Where N is odd the last row will be complete and there will be no justifying, so you won't see the crenelations.)
Check it out here.

@Vioz-  Thanks for the ideone! I tested the program down to low values of N and M to see  if there were any edge cases, but I didnt bother checking if it would work for values that high. Apparently both crenellation and crenelation are correct, so I'll leave it. Will be coming back later to see if I can delete some brackets and whitespace.

No problem for the link? I figured it would be helpful for others since I used it to test :P In regards to the spelling edit, I changed it to the first result I could find, because I've never seen the word actually used. I don't know much about Ruby (nothing, infact), but you can change i%2==0 to i%2<1 to save a byte (I've made this change to the ideone link).

Do you really need the # padding for the even last row? For example, in the very last figure, isn't the perimeter the same without the # in the bottom right corner?

@RetoKoradi it would indeed be the same perimeter - it looks like the code includes the extra # simply because it is already the way every line is ended, so it's fewer bytes than putting a space there. (I don't know ruby though...).

@trichoplax your intuition is correct. The padding is "# " not " #" because the latter would give 2 adjacent # for odd M which is definitely not wanted. 2 adjacent # for even M does no harm, so I went with that. I haven't tried ljust, it may be possible to do it more cleanly with that, but it wouldn't be so obvious that I'm printing exactly M characters per row.

@trichoplax I'm fairly new to Ruby, but I believe i%2?1:m will not work because zero is truthy in Ruby. Only false and nil (absence of data) are falsy. Will try it anyway, heh heh!

C, 109 97 bytes and correctness proof
I was writting up my solution but @steveverrill beat me to it. I thought i'd share it all the same, since I included a correctness proof for the strategy used.
Reduced Code:
m,n,x;main(){for(scanf("%i%i",&m,&n); n;)putchar(x<m?"# "[x%2*(++x^m||~n&1)&&n^1]:(x=0,n--,10));}

Before Reduction:
m,n,x;

main(){
    for(scanf("%i%i",&m,&n); n;)

        /* If x == m, prints out a newline, and iterates outer
         * loop (x=0,n--) using comma operator.
         * Otherwise, paints a '#' on :
         *     Every even column (when x%2 is 0)
         *     On odd columns of the last row (++x^m||~n&1 is 0)
         *     On the first row (when n^1 is 0)
         * And a ' ' on anything else (when predicate is 1) */
        putchar(x<m?"# "[x%2*(++x^m||~n&1)&&n^1]:(x=0,n--,10));
}

Strategy and Proof:
Assuming the correctness of the maximum perimiter equation (M+1)(N+1) - ((M+1)(N+1)) mod 2, the following explains the optimal strategy used and proves its correctness by induction:
For odd M, we draw a hand-like shape with M/2 + 1 fingers, for example:
3x2
# #
###

5x3
# # #
# # #
#####

We now prove this strategy is optimal for all odd M by induction:
Base Case: M=N=1
The single cell is filled. The solution is correct since (1 + 1)*(1 + 1) = 2*2 = 4, and a square has 4 sides.
Induction on width:
Assume that the hand-shape strategy works for (N, M-2) where M is odd, that is, its perimiter is optimal and is (N + 1)(M - 2 + 1) + ((M-1)(N+1)) mod 2. We now show that it will work for (N,M).
The process of adding a finger removes one edge from the polygon, and adds 3 + 2N. For example:
 5x3 -> 7x3
 # # # $
 # # # $
 #####$$

Combining this with our hypothesis that the previous perimeter was optimal, the new perimeter is:
(N + 1)*(M - 2 + 1) - ((M+1)*(N+1)) mod 2 - 1 + 3 + 2*N
(N + 1)*(M + 1) - ((M-1)*(N+1)) mod 2 - 2(N + 1) - 1 + 3 + 2*N
(N + 1)*(M + 1) - ((M-1)*(N+1)) mod 2

Since we are dealing with modulo 2 arithmetic,
((M-1)*(N+1)) mod 2 = ((M+1)*(N+1)) mod 2

Thus, proving that increasing the width by adding fingers leads to an optimal perimeter.
Induction on height:
Assume the hand-shape strategy works for (N-1, M), where M is odd, that is, its perimeter is optimal and is N(M + 1) + ((M+1)N) mod 2. We now show that it will work for (N,M).
Increasing the height of the hand merely elongates the fingers, located at the first and every other x-index. For each height increase, each finger adds two to the perimeter, and there are (M+1)/2 fingers, thus, an increase in N leads to an increase of 2(M+1)/2=M+1 in the perimeter.
Combining this with the hypothesis, we have that the new perimeter is:
N*(M + 1) + ((M+1)*N) mod 2 + M + 1
(N + 1)*(M + 1) + ((M+1)*N) mod 2

Modular arithmetic permits us to simplify the last term, so that we obtain:
(N + 1)*(M + 1) + ((M+1)*(N+1)) mod 2

Proving that the solution is optimal for all N>0 and odd M>0.
For even M, we fill in the board the same as we would for odd M, but we add crenelations to the last segment, for example:
4x3
# ##
# #
####

6x4
# # #
# # ##
# # #
######

We now prove that this strategy is optimal.
Induction for even M:
Assume that the the solution is correct for (N,M-1), with odd M-1 (as was proven in the last case), which has an optimal perimeter of (N + 1)M - (M(N+1)) mod 2. We now show that it will work for (N,M).
Like increasing the fingers, each crenelation adds two to the perimeter of the polygon. The total number of crenelations is (N + N mod 2)/2, for a total of N + N mod 2 perimeter added.
Combining this with the hypothesis, we have that the new perimeter is:
(N + 1)*M - (M*(N+1)) mod 2 + N + N mod 2
(N + 1)*(M + 1) - (M*(N+1)) mod 2 + N mod 2 - 1
(N + 1)*(M + 1) - (M*(N+1)) mod 2 - (N + 1) mod 2

We have that
(M*(N+1)) mod 2 - (N + 1) mod 2 = ((M+1)*(N+1)) mod 2

Because if N is odd, then this reduces to 0=0, and if N is even, it reduces to
- A mod 2 - 1 = -(A + 1) mod 2

Thus the strategy is optimal for all M,N>0.

That's a lot of math! Couldn't you just calculate the perimeter of the shape you are creating, and show that it matches the provided maximum value? You know how many "fingers" you have, how long each finger is, etc. So calculating the perimeter should be reasonably easy.

True. In some respects, I feel the induction path is more intuitive, since it's additive, but yes, it does lead to a more lengthy explanation.

You might want to know the perimeter equals to the number of integer points it passes.


text:
Nuggets of Code
Nuggets of Code
It's a hypothetical situation where it is Friday evening, and you've invited over the usual golfing buddies to participate in your favourite hobby: code golfing. However, as this is such a brain-draining task, you need to pick up some brain food for the group so you can golf as much as possible off your code.
Now, everyone's favourite snack is chicken nuggets, but there's a problem: There is no single pack of them which covers everyone's needs. So, since you're already in the golfing mood, you decide to create a program that figures out exactly what packs you must buy to be able to cover everyone's Nugget needs.
Chicken nugget pack sizes are all over the place, and depending on where you live in the world, the standard sizes change too. However, the closest [place that serves nuggets] stocks the following sizes of nugget packs:
4, 6, 9, 10, 20, 40
Now you may notice that you cannot order certain combinations of nuggets. For example, 11 nuggets is not possible, since there is no combination that equals 11 exactly. However, you can make 43 by getting 1 pack of 20, 1 pack of 10, 1 pack of 9 and 1 pack of 4,
20 + 10 + 9 + 4 = 43 (597)
where 597 is each term squared and added together (hint: the optimal solution has this as the highest value). There are of course other ways of making 43, but as you know, the more nuggets per pack, the cheaper it gets per nugget. So, you want to ideally buy the least number of packs and in the greatest quantities to minimize your cost.
The Task
You should create a program or function which takes a list of integers corresponding to each person's requirements. You should then calculate and print the most cost-efficientα order to buy the chicken nuggets. The most cost-efficientα order is the combination by which the sum of the squares of each quantity is the highest. If there is absolutely no way to buy the nuggets perfectly, you must print a falsy value such as 0, False, Impossible!, or whatever is available in your language.
Example I/O:
[2 7 12 4 15 3] => [20 10 9 4]
     1, 1, 2, 1 => False
  6 5 5 5 5 5 9 => 40
      [6, 4, 9] => 9 10
              1 => 0
            199 => 40, 40, 40, 40, 20, 10, 9
              2 => Impossible!

Here is the list of ideal solutions for the first 400. Note these are not formatted how I would expect yours to be, each tuple is in the form (N lots of M).
Rules

No standard loopholes.
No use of built-in functions that do all or the majority of the task, such as FrobeniusSolve in Mathematica.

α - To clarify this with an example, you could also make 43 by doing 4 + 6 + 6 + 9 + 9 + 9 = 43 (319), but this would not be optimal, and thus an incorrect output, as the sum of the squares is less than the combination I noted in the introduction. Essentially, higher sum of squares = lower cost = most cost-efficient.

Are there any time/memory limits?

@Dennis There are no time or memory limits.

It's actually Thursday.

@mbomb007 Astute observation :P I've adjusted the intro.

It's Friday somewhere (can confirm, am somewhere).

I NEED to use the chicken mcnugget theorem somehow...

To make it more practical 43 won't be optimal, instead mke the program to suggest 44? I suppose you could compare total and per unit price.

Pyth, 26 25 bytes
e+Zo.aNf!-TCM"
("./sQ

Notice that there are some unprintable chars. Try it online: Demonstration. It is quite slow (but not as slow as my 26 byte solution).
Explanation:
                          implicit: Q = input list
                     sQ   sum(Q)
                   ./     generate all integer partitions
       f                  filter for partitions T, which satisfy:
             "   ("          string containing chars with the ASCII-values of 4,6,9,10,20,40
           CM                convert each char to the ASCII-value
         -T                  remove this numbers from T
        !                    and check, if the resulting list is empty
    o                      order the remaining subsets N by:
     .aN                      the vector length of N (sqrt of sum of squares)
  +Z                       insert 0 at the beginning
 e                         print the last element

Pyth, 32 bytes
e+Zo.aNfqsTsQysm*]d/sQdCM"
(

Notice that there are some unprintable chars. Try it online: Demonstration
This version is way faster. It finds the solution for the input [6,7,8] in about one second and the solution for the input [30] in about 90 seconds.
Explanation:
                                 implicit: Q = input list
                          "...(  the string containing chars with the ASCII-values of 4,6,9,10,20,40
                        CM       convert each char to the ASCII-value
                m                map each number d to:
                  ]d                create the list [d]
                 *  /sQd            and repeat it sum(Q)/d times
               s                 unfold
              y                  generate all subsets
        f                        filter for subsets T, which satisfy:
         qsTsQ                      sum(Q) == sum(T)
    o                            order the remaining subsets N by:
     .aN                            the vector length of N (sqrt of sum of squares)
  +Z                             insert 0 at the beginning
 e                               print the last element

Why is it by the sqrt of the sum of the squares, rather than just the sum?

@mbomb007 Because it doesn't matter. If a > b, than sqrt(a) > sqrt(b) and vice versa. And using the .a method is shorter than squaring and summing s^R2.

Perl, 175 153
sub f{my$n=$_[0];if(!$n){return 1;}foreach$o(40,20,9,10,6,4){if($n>=$o&&f($n-$o)){print"$o ";return 1;}}return 0;}$n+=$_ for@ARGV;if(!f($n)){print":(";}

Takes it's input from the program arguments. Prints a :( if it can't find a perfect solution.
Ungolfed Code:
sub f
{
    my $n = $_[0];
    if(!$n)
    {
        return 1;
    }
    foreach $o(40,20,9,10,6,4)
    {
        if($n>=$o&&f($n-$o))
        {
            print "$o ";
            return 1;
        }
    }
    return 0;
}

$n += $_ for @ARGV;
if(!f($n))
{
    print ":(";
}

P.S.: This is probably the first entry that doesn't take 10 minutes for 1 2 ;)
Check it out here.

Congrats on what appears to be the fastest program so far! It might be faster than my reference program too :P I've added an ideone link at the bottom of your post so people can see the output.

Your code can produce incorrect output. Input 18 should print 9 9, not 4 4 10.

There are other incorrect outputs as well. If I'm not mistaken, you can fix all of them by swapping the order of 9 and 10.

@Dennis Thank you, fixed it!

CJam, 45 29 28 bytes
q~:+_[40K9A6Z)U]m*_::+@#=0-p

Note that this approach is very slow and memory-intensive.
Try it online in the CJam interpreter.
It can be sped up significantly at the cost of 5 bytes:
q~:+_40/4+[40K9A6Z)U]m*_::+@#=0-p

Complexity is still exponential in the sum of the input, but this should handle test cases up to 159 with the online interpreter and up to 199 with the Java interpreter in a couple of seconds.
Try it online in the CJam interpreter.
Idea
An optimal purchase (maximal sum of squares) is a valid purchase (correct number of nuggets) that has as many 40's as possible, then as many 20's as possible, then as many 9's as possible (e.g., 9 9 is preferable over 10 4 4) and so forth for 10's, 6's and 4's.
In this approach, we generate the Cartesian product of N copies of the array [40 20 9 10 6 4 0], where N is the desired number of nuggets. N is a (bad) upper bound for the number of purchases we have to make. In the sped up version of the code, we use N/40 + 4 instead.
Because of how the array is ordered, the Cartesian product will start with the vector [40 ... 40] and end with the vector [0 ... 0]. We compute the index of the first vector that has the correct sum (which will also have the optimal sum of squares), retrieve the corresponding array element, remove the zeroes that served as placeholders and print the result.
If no vector could be found, the index will be -1, so we retrieve [0 ... 0], which will print an empty array instead.
Code
q~                            e# Read from STDIN and evaluate the input.
  :+                          e# Push N, the sum of all elements of the resulting array.
     [40K9A6Z)U]              e# Push B := [40 20 9 10 6 4 0].
    _           m*            e# Push B**N, the array of all vectors of dimension N
                              e# and coordinates in B.
                  _::+        e# Copy and replace each vector by its sum.
                      @#      e# Get the first index of N.
                        =     e# Retrieve the corresponding element.
                         0-p  e# Remove 0's and print.

This may be one of the few situations where working out the solution by hand would be faster than letting the code finish.. nice work regardless :)

Julia, 126 bytes
r->(t=filter(i->all(j->j∈[4,6,9,10,20,40],i),partitions(sum(r)));show(!isempty(t)&&collect(t)[indmax(map(k->sum(k.^2),t))]))

This creates an unnamed function that accepts an array as input and prints an array or boolean to STDOUT, depending on whether a solution exists. To call it, give it a name, e.g. f=n->....
Ungolfed + explanation:
function f(r)
    # Nugget pack sizes
    packs = [4, 6, 9, 10, 20, 40]

    # Filter the set of arrays which sum to the required number of nuggets
    # to those for which each element is a nugget pack
    t = filter(i -> all(j -> j ∈ packs, i), partitions(sum(r)))

    # Print the boolean false if t is empty, otherwise print the array of
    # necessary nugget packs for which the sum of squares is maximal
    show(!isempty(t) && collect(t)[indmax(map(k -> sum(k.^2), t))])
end

Examples:
julia> f([1])
false

julia> f([2,7,12,4,15,3])
[20,10,9,4]

Python 3 - 265 characters
import itertools as i
n=list(map(int,input().split(',')));m=[]
for f in range(1,9):
 for j in range(6*f):
  for x in i.combinations((4,6,9,10,20,40,)*f,j+1):
   if sum(n)==sum(x):m.append(x)
if m!=[]:v=[sum(l**2for l in q)for q in m];print(m[v.index(max(v))])
else:print(0)

Showing spacing:
import itertools as i
n=list(map(int,input().split(',')));m=[]
for f in range(1,5):
 for j in range(6*f):
\tfor x in i.combinations((4,6,9,10,20,40,)*f,j+1):
\t if sum(n)==sum(x):m.append(x)
\t\tif m!=[]:v=[sum(l**2for l in q)for q in m];print(m[v.index(max(v))])
else:print(0)

Passes all test cases
Note: I don't know if this will pass all cases because it is so slow... But it should...

Nothing looks wrong with this right now, I'll test it and see. Once I get home I'll add a reference, ungolfed program that I used to generate the list that's in the Gist. While I wasn't timing, I believe it took somewhere in the 8-12 minute range for all cases.

@Vioz- Brilliant! :D

Looks like I may be wrong, after testing 36 it gets through about 40 million combinations (40,007,602 to be exact) before running into a MemoryError. This might be a limitation of my work machine though, as it only has 4GB of memory.

@Vioz- Hm... Well it's hopeless for me to carry on testing on my phone...

Side note: from blah import* is almost always preferable over import blah as x if blah is at least 6 chars

@Sp3000 why 6 chars? i was under the impression that it was always better because you save the x. every time you use something from blah

@undergroundmonorail If you're using it only once, then for <= 4 chars a straight import is better (5 breaks even). But if you're using it more than once then from blah import* is always best. The only exception I can think of to the above though is if you have multiple imports, which is the only time that comes to mind where as is actually useful.

@Sp3000 I think I'm misunderstanding you... len("import aaaa as x;aaaa.blah()") > len("from aaaa import*;blah()")

@undergroundmonorail Besides, since I use i.combinations once, so from itertools import* is one character longer

@undergroundmonorail I think you mean len("import aaaa as x;x.blah")

JavaScript, 261 256 261
d="length";function g(a){for(z=y=0;y<a[d];z+=+a[y++]);return z}x=[40,20,10,9,6,4];l=prompt().split(",");o=g(l);p=[];for(i=0;i<x[d];i++)r=g(p),s=r+x[i],(s<o-3||s==o)&&p.push(x[i]),(i==x[d]-1||40<o-r)&&r+x[i]<o-3&&(i=-1,0==i||o-r<p[p[d]-1]&&p.pop());g(p)==o&&p||0

I'm not sure if this is alright, it seems to work but I'm surely missing things.
It doesn't seem to be slow though, up to 123456 it outputs [40 x 3086, 10, 6] almost immediatly.
Explanation:
Iterating over the nugget sizes (biggest first)

If the sum of the stack plus the nugget size is less than the goal - 3 -> push it on a stack
If there is more than 40 left -> reset the loop counter
If the sum of the stack is more than the goal when the last nugget-size was reached -> pop the last element, reset the loop counter
If the sum of the stack adds up, return it, otherwise return 0

For 199 | 1 the stack built looks like this
i | stack
0   [40]
0   [40, 40]
0   [40, 40, 40]
0   [40, 40, 40, 40]
0   [40, 40, 40, 40]
1   [40, 40, 40, 40, 20]
2   [40, 40, 40, 40, 20, 10]
3   [40, 40, 40, 40, 20, 10, 9]
4   [40, 40, 40, 40, 20, 10, 9]
5   [40, 40, 40, 40, 20, 10, 9]
==> [40, 40, 40, 40, 20, 10, 9]

For 1
i | stack
0   []
1   []
2   []
3   []
4   []
5   []
==> 0

Your approach doesn't seem to check if the goal can be reached. 11 prints [6] and 18 prints [10, 4].

@Dennis Hey there, thanks for pointing that out. It's been a late night yesterday. Fixed it for 5 chars. 18 printed [10,4] because I was missing a pair of parens.
The check was indeed wrong, i just checked if there was at least one element in the resultset, not if it sums up correctly. I don't know what I thought there


text:
Write "Code Golf" without using any letters
Goal
Your goal is to write "Code Golf" without using any letters [A-Z, a-z], even in your source code. It can't use of the following special characters either (!, _, <, (, ), ., {, }, ', and >).
Bonus / Scoring

If the code backwards also writes "Code Golf", you get -10.

Good luck!
Standard loopholes disallowed.
Mine also isn't a duplicate, because it also has character restrictions.

You wouldn't know this as a new user, but challenges of the form "Print X without using characters Y" have been poorly received in general. It seems like every new user comes in thinking it's a new and clever idea, which means they've been way overdone at this point. A lot of the answers use the same bag of tricks. Doing a simple task with limited tools often leads to less interesting solutions than a difficult task with a large array of tools. Try doing some challenges yourself to get a sense of what the community is into.

Also, having username-dependence is a bad idea. It means users whose names is shorter or longer or more compressible have an unfair advantage. It's not fun to be unable to use a method because your username doesn't allow it.

Ok - i'll fix it up a little more.

Maybe too restrictive??

CJam, 25
"¡ÍÂÃ~¥ÍÊÄ"94"`[]":^"-"+~

Try it online
Explanation:
"¡ÍÂÃ~¥ÍÊÄ" is "Code Golf" with each character (code point) incremented by 94.
"¡ÍÂÃ~¥ÍÊÄ"94    push that string and 94
"`[]":^          xor the characters '`', '[' and ']', obtaining 'f'
"-"+             concatenate with "-", resulting in "f-"
~                evaluate "f-", which subtracts 94 from each character

That's really clever. I had the string, but I couldn't figure out how to produce the f...

@Dennis Thanks, I used another method first (you can see it in the edit history)

HTML, 46 bytes
Code Golf

This prints / outputs:
Code Golf

Whitespace, 146 characters
I have included Space, Tab, and Line feed indicators.

S S S T S S S S T   T   L
T   L
S S S S S T T   S T T   T   T   L
T   L
S S S S S S S T T   S S T   S S L
T   L
S S S S S S S T T   S S T   S T L
T   L
S S S S S S S S T   S S S S S L
T   L
S S S S S S S T S S S T T   T   L
T   L
S S S S S T T   S T T   T   T   L
T   L
S S S S S T T   S T T   S S L
T   L
S S S S S T T   S S T   T   S L
T   L
S S L
L
L

Try it online
Explanation:

S S pushes a number to the stack
S T S S S S T   T   L is the number 67 in binary ending with a line
T   L
S S outputs the top of the stack
This process repeats for each letter
Three linefeeds at the end terminates the program

Note that this does not end with a linefeed, so the command prompt will appear directly after the output.  There is also some easy golfing by manipulating the stack and/or creating the numbers more efficiently, but it's past my bedtime...
Edit:  I am unable to sleep and have been inspired by vihan1086's HTML answer.  I don't see a requirement that the backwards-forwards running be in one language, so here is an WHITESPACE + LMTH answer that runs forwards and backwards:

;201#&;801#&;111#&;17#&;23#&;101#&;001#&;111#&;76#&
This scores 146 + 50 - 10 = 186

GolfScript, 27 bytes
0000000: 5b 31 32 33 20 31 32 36 20 31 32 35 5d 2b 7e  [123 126 125]+~
000000f: 22 bc 90 9b 9a df b8 90 93 99 22 25           "........."%

The above is a reversible xxd dump.
The only ASCII characters the code uses are [123 65]+~"%.
Proof of work
$ LANG=en_US
$ xxd -ps -r > codegolf.gs <<< 5b31323320313236203132355d2b7e22bc909b9adfb89093992225
$ wc -c codegolf.gs
27 codegolf.gs
$ golfscript codegolf.gs
Code Golf

How it works

Lacking input, GolfScript initially has an empty string on the stack.
The array [123 126 125] contains the character codes of {, ~ and }.
+ concatenates. Since strings take priority over arrays, this pushes "{~}".
~ evaluates that string, pushing the block {~}.
The string of non-ASCII characters contains the logical NOTs of the character code of the string Code Golf.
% maps the pushed block over the string. ~ is logical NOT, which is involutive, so this pushes the character codes of Code Golf.
Finally, GolfScript prints the string on the stack.