A Piece of P.I.E

A 4 × 4 4 \times 4 square is made up of 16 1 × 1 1 \times 1 squares, each of which is coloured either black or white. Let n n be the number of these 4 × 4 4 \times 4 squares such that within the 4 × 4 4 \times 4 square there are no 3 × 3 3 \times 3 squares made up entirely of white 1 × 1 1 \times 1 squares. What is the digit sum of n ? n?


The answer is 28.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

2 solutions

Daniel Chiu
Dec 27, 2013

As the title suggests, we use PIE, or the Principle of Inclusion-Exclusion. We count the complement: the number of ways at least one corner can have a 3 × 3 3\times 3 white corner. The number of ways one corner can have a 3 × 3 3\times 3 white square is 2 7 2^7 , as each of the other 7 squares can be either color. The number of ways two adjacent corners can have white 3 × 3 3\times 3 squares is 2 4 2^4 , as there are 4 squares that can be either color. The number of ways two opposite corners can have white 3 × 3 3\times 3 squares is 2 2 2^2 , since only 2 squares can be either color. The number of ways three corners can have white 3 × 3 3\times 3 squares is 2 2 , as only the other corner can be either color. Finally, there is only 1 1 way all four corners can have 3 × 3 3\times 3 white squares.

By PIE, the number of ways is 4 2 7 4 2 4 2 2 2 + 4 2 1 = 447 4\cdot 2^7-4\cdot 2^4-2\cdot 2^2+4\cdot 2-1=447 Then, n n is 2 16 447 = 65089 2^{16}-447=65089 and the answer is 6 + 5 + 0 + 8 + 9 = 28 6+5+0+8+9=\boxed{28} .

Bob Smith
Dec 29, 2013

C++, since this problem has annoying casework

#include <iostream>
using namespace std;

int main() {
    int ans=0;
    for(int i = 0; i < 65536; i++)
    {
        if((i&1911)&&(i&(1911*2))&&(i&(1911*16))&&(i&(1911*32)))
        {
            ans++;
        }
    }

    cout << ans;
}

Returns 65089.

This is an interesting exercise in bitmasks; can you guess why 1911 was chosen?

((1+2+4)*(1+16+256).)

The time spent to decipher your program is more than the time spent to solve this problem :-)

George G - 7 years, 5 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...