The number of unique permutations of pans possible in a Pocket Palette is:

const width = 7; const height = 4; // We represent the palette as a bitfield stored in a 32 bit integer. // 0 bits represent empty space (filled by 1x1 mini pans at the end), and // 1 bits represent spaces filled by other pans, or spaces off the edge of // the palette. We are lucky that the palette is only 7 spaces wide, as // this allows room for 1 space of padding between rows while still fitting // in 32 bits. if ((width + 1) * height > 32) throw 'palette does not fit in 32 bits'; const move = (pan, x, y) => pan << x + y * (width + 1); // We calculate the number of permutations by brute force. At each position // in the palette we try to place every pan type. If it fits, we recurse and // try every pan in every subsequent position until we reach the end of the // palette. const permutations = (palette, start) => { // The passed in palette counts as one valid permutation, when completed // using 1x1 mini pans (if necessary). let count = 1; // Try each pan type. for (let i = 0; i < pans.length; i++) { const pan = pans[i]; const maxShift = maxShifts[i]; // Try putting this pan at every position in the palette starting // here. for (let shift = start; shift < maxShift; shift++) // If the pan fits here, place it and recurse. if (!(palette & pan << shift)) count += permutations(palette | pan << shift, shift + 1); } return count; } // We consider five types of pans (rotated pans count as different types). // Standard are 2x1, double are 2x2, and mixing are 2x4. Mini pans (1x1) // can always fill any leftover space and there is always only one way to // place them so we don't need to count them. const standardH = 1 | move(1, 1, 0); const standardV = 1 | move(1, 0, 1); const double = standardH | move(standardH, 0, 1); const mixingH = double | move(double, 2, 0); const mixingV = double | move(double, 0, 2); const pans = [ standardH, standardV, double, mixingH, mixingV ]; // Calculate the maximum we can move each pan before it hits the end // of the 32 bit bitfield. let maxShifts = []; for (let pan of pans) maxShifts.push(31 - (Math.log2(pan) | 0)); let palette = 0; for (let x = 0; x < width; x++) for (let y = 0; y < height; y++) palette |= move(1, x, y); let answer = permutations(~palette, 0); console.log("The answer is: " + answer); self.postMessage(answer);

Computers can count millions of things very quickly! If you'd like to edit the code, try here.