Stop Microsoft

Miscellaneous => Programming & Networking => Topic started by: TheQuirk on 28 August 2005, 02:03

Title: Let's play a game, pals. Challenge 4.
Post by: TheQuirk on 28 August 2005, 02:03
You have a piece of math paper, 100 by 100 squares. On the paper, there are rectangles. The rectangles do not touch each other.

You have an array of 100 by 100, representing the piece of paper. For every square which is part of a rectangle, the value is 1. For every square which isn't, the value is 0. You have to figure out how many rectangles are drawn on the paper.

For example, the following array would represent a 10x10 piece of paper with two rectangles:

Code: [Select]

[[0000000000]
 [0111100000]
 [0111100000]
 [0111100000]
 [0000000000]
 [0000000000]
 [0000001100]
 [0000001100]
 [0000001100]
 [0000000000]]
Title: Re: Let's play a game, pals. Challenge 4.
Post by: Pathos on 28 August 2005, 12:38
Can rectangles overlap?

[[0000000000]
 [0112222000]
 [0112222000]
 [0002222110]
 [0002222110]
 [0000000000]
 [0000001100]
 [0000001100]
 [0000001100]
 [0000000000]]

or

[[0000000000]
 [0111111000]
 [0111111000]
 [0002222220]
 [0002222220]
 [0000000000]
 [0000001100]
 [0000001100]
 [0000001100]
 [0000000000]]
Title: Re: Let's play a game, pals. Challenge 4.
Post by: TheQuirk on 28 August 2005, 20:36
Nein.
Title: Re: Let's play a game, pals. Challenge 4.
Post by: Pathos on 29 August 2005, 11:37
So how should the examples I gave be interpreted.
Title: Re: Let's play a game, pals. Challenge 4.
Post by: TheQuirk on 29 August 2005, 20:38
It's not an issue; you won't be getting that sort of data. You'll only be getting non-touching, non-overlapping rectangles.
Title: Re: Let's play a game, pals. Challenge 4.
Post by: Kintaro on 30 August 2005, 11:13
COMMUNIST

I mean.

Hello, Glebz0r
Title: Re: Let's play a game, pals. Challenge 4.
Post by: piratePenguin on 2 November 2005, 09:36
Quote from: TheQuirk
100 by 100 squares
Feck that, 10x10 will do.

http://illhostit.com/files/3770320186421918/rect.c (http://illhostit.com/files/3770320186421918/rect.c)
Quote
piratepenguin@pcdeclan:~/stuff/programming/c/rect$ ./rect
There are 4 rectangles.
Works.