Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

## #1 2009-11-05 07:51:07

talhakosen
Member

Offline

### Calculate a block of five in 8 x 8 board ?

Hi all,

I need to know how to write a code with C or C++  which calculates below

8x8 cheesboard how many different ways can you select a block of five neighbour squares?
Two squares are neighbours if they have a common side.
(for 3x3 board  = 49 ways)

Thanx

## #2 2009-11-27 03:05:08

John E. Franklin
Star Member

Online

### Re: Calculate a block of five in 8 x 8 board ?

I did it out by hand.
(48 * 36) + (48 * 25) + (10 * 16) = 3 088

But for the 3 x 3, I only get 48, not 49.

Here are my calculations in mspaint.exe, zoom in to see at 800% with grid.

Last edited by John E. Franklin (2009-11-27 03:09:56)

igloo myrtilles fourmis

## #3 2009-11-27 03:41:48

mathsyperson
Moderator

Offline

### Re: Calculate a block of five in 8 x 8 board ?

These are all the shapes that can be made by sticking five squares together.

#### Code:

```XXXXX  (5x1, 2)

---

XXXX   (4x2, 8)
X

---

XXXX   (4x2, 8)
X

---

XXX    (3x2, 8)
XX

---

XXX    (3x2, 4)
X X

---

X
XXX    (3x3, 4)
X

---

X
XXX    (3x3, 8)
X

---

X
XXX    (3x3, 4)
X

---

X
XXX    (3x3, 1)
X

---

X
XX     (3x3, 4)
XX

---

XXX
X      (3x3, 4)
X

---

XXX    (4x2, 8)
XX```

Next to each is the dimensions of the smallest rectangle it will fit into, and the number of different forms it can take via reflection and rotation.

You can work out how many ways each one of these will fit on a chessboard, then add everything up.

For example, the line fits in a 5x1 box. There are (9-5)x(9-1) = 32 ways to place a 5x1 box on a chessboard, and the line can be oriented in two different ways, so altogether there are 64 ways to place a line on a chessboard.

Similarly, the T fits in a 3x3 box and is orientable 4 ways, so the number of ways to place a T on a chessboard is 4x(9-3)x(9-3) = 144.

etc...

Why did the vector cross the road?
It wanted to be normal.

## #4 2009-11-28 05:00:45

John E. Franklin
Star Member

Online

### Re: Calculate a block of five in 8 x 8 board ?

Also, my estimate is a little high because I did 5x5 grids with straight lines inside them moving around, and
then I moved the 5x5 grid around, so some of these will be on top of one another, like the 5x5 to the right with
the inerds to the the left, etc.  So my answer is not exact.

Edit:  @talhakosen,  you are right about the 49 in 3x3, I found the "plus" sign one by doing it over.

xox
ooo
xox

Last edited by John E. Franklin (2009-11-28 05:29:00)

igloo myrtilles fourmis

## #5 2009-11-28 05:59:59

John E. Franklin
Star Member

Online

### Re: Calculate a block of five in 8 x 8 board ?

Here is my latest computation of the 5 neighbors on a chessboard 8 by 8:

(42 * 8) + 64 + (35 * 8) + (35 * 8) + (36 * 4) + 36 + (36 * 8) + (36 * 4) + (42 * 4) + (36 * 4) + (35 * 4) + (36 * 4) = 2 168

See diagram below larger this time to see better.

Note the "plus" sign is the + 36 + above.

And the ooooo long straight is the + 64 + above.

Other shapes are rotated 4 times, hence multiply by 4 or 8 times if the mirror image is involved.

igloo myrtilles fourmis

## #6 2009-11-28 10:41:31

John E. Franklin
Star Member

Online

### Re: Calculate a block of five in 8 x 8 board ?

Oh my, my 2nd to last and 3rd to last drawings of 12, I didn't show the mirror images, so
the equation is short a little, so double those terms:
36 * 8 and add 35 * 8 instead of 36 * 4 and 35 * 4, sorry

igloo myrtilles fourmis

## #7 2009-11-28 15:31:59

soroban
Power Member

Offline

### Re: Calculate a block of five in 8 x 8 board ?

.

. .

#### Code:

```      *---*---*---*---*---*   *---*---*---*---*
|   |   |   |   |   |   |   |   |   |   |
*---*---*---*---*---*   *---*---*---* - *
|   |
*---*---*---*           *---*       *---*
|   |   |   |           |   |
*---*---* - *---*   *---* - *---*---*
|   |   |   |   |   |   |   |
*---*---*   *---*---*---*---*```

#### Code:

```      *---*       *---*---*       *---*
|   |       |   |   |       |   |
* - *---*   * - *---*   *---* - *---*
|   |   |   |   |       |   |   |   |
* - * - *   *---* - *   *---* - *---*
|   |   |   |   |   |       |   |
*---*---*   *---*---*       *---*

*---*---*       *---*       *---*---*
|   |   |       |   |       |   |   |
*---* - *---*   * - *---*   *---* - *
|   |   |   |   |   |       |   |
* - *---*   *---* - *---*   * - *---*
| - |           | - | - |   | - | - |
*---*           *---*---*   *---*---*```

#### Code:

```      *---*---*---*       *---*
|   |   |   |       |   |
*---* - *---*       * - *
|   |           |   |
* - *           * - *---*---*
|   |           |   |   |   |
*---*           *---*---*---*```

## #8 2010-01-01 10:49:58

oghk
Guest

### Re: Calculate a block of five in 8 x 8 board ?

hi.

if i solve this problem, i have enter a job. but i didnt solve it.