25.03.2013 Views

Cracking the Coding Interview - Fooo

Cracking the Coding Interview - Fooo

Cracking the Coding Interview - Fooo

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Solutions to Chapter 6 | Brain Teasers<br />

6 2 There is an 8x8 chess board in which two diagonally opposite corners have been cut<br />

off You are given 31 dominos, and a single domino can cover exactly two squares<br />

Can you use <strong>the</strong> 31 dominos to cover <strong>the</strong> entire board? Prove your answer (by providing<br />

an example, or showing why it’s impossible)<br />

SOLUTION<br />

CareerCup com<br />

pg 60<br />

Impossible Here’s why: The chess board initially has 32 black and 32 white squares By removing<br />

opposite corners (which must be <strong>the</strong> same color), we’re left with 30 of one color and<br />

32 of <strong>the</strong> o<strong>the</strong>r color Let’s say, for <strong>the</strong> sake of argument, that we have 30 black and 32 white<br />

squares<br />

When we lay down each domino, we’re taking up one white and one black square Therefore,<br />

31 dominos will take up 31 white squares and 31 black squares exactly On this board, however,<br />

we must have 30 black squares and 32 white squares Hence, it is impossible<br />

1 4 4

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!