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

You are not logged in.

- Topics: Active | Unanswered

**talhakosen****Member**- Registered: 2009-11-01
- Posts: 10

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

Offline

**John E. Franklin****Member**- Registered: 2005-08-29
- Posts: 3,562

I did it out by hand.

Answer is:

(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-26 04:09:56)*

**igloo** **myrtilles** **fourmis**

Offline

**mathsyperson****Moderator**- Registered: 2005-06-22
- Posts: 4,900

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

```
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.

Offline

**John E. Franklin****Member**- Registered: 2005-08-29
- Posts: 3,562

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-27 06:29:00)*

**igloo** **myrtilles** **fourmis**

Offline

**John E. Franklin****Member**- Registered: 2005-08-29
- Posts: 3,562

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**

Offline

**John E. Franklin****Member**- Registered: 2005-08-29
- Posts: 3,562

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**

Offline

**soroban****Member**- Registered: 2007-03-09
- Posts: 451

.

. .

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

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

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

Offline

**oghk****Guest**

hi.

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

and then i didnt understand your answer. please again answer and real solve. pls. pls. pls.