Author Topic: Let's play a game, pals. Challenge 4.  (Read 2434 times)

TheQuirk

  • VIP
  • Member
  • ***
  • Posts: 2,154
  • Kudos: 315
Let's play a game, pals. Challenge 4.
« 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]]

Pathos

  • Member
  • **
  • Posts: 518
  • Kudos: 416
Re: Let's play a game, pals. Challenge 4.
« Reply #1 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]]

TheQuirk

  • VIP
  • Member
  • ***
  • Posts: 2,154
  • Kudos: 315
Re: Let's play a game, pals. Challenge 4.
« Reply #2 on: 28 August 2005, 20:36 »
Nein.

Pathos

  • Member
  • **
  • Posts: 518
  • Kudos: 416
Re: Let's play a game, pals. Challenge 4.
« Reply #3 on: 29 August 2005, 11:37 »
So how should the examples I gave be interpreted.

TheQuirk

  • VIP
  • Member
  • ***
  • Posts: 2,154
  • Kudos: 315
Re: Let's play a game, pals. Challenge 4.
« Reply #4 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.

Kintaro

  • Member
  • **
  • Posts: 6,545
  • Kudos: 255
  • I want to get the band back together!
    • JohnTate.org
Re: Let's play a game, pals. Challenge 4.
« Reply #5 on: 30 August 2005, 11:13 »
COMMUNIST

I mean.

Hello, Glebz0r

piratePenguin

  • VIP
  • Member
  • ***
  • Posts: 3,027
  • Kudos: 775
    • http://piratepenguin.is-a-geek.com/~declan/
Re: Let's play a game, pals. Challenge 4.
« Reply #6 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
Quote
piratepenguin@pcdeclan:~/stuff/programming/c/rect$ ./rect
There are 4 rectangles.
Works.
"What you share with the world is what it keeps of you."
 - Noah And The Whale: Give a little love



a poem by my computer, Macintosh Vigilante
Macintosh amends a damned around the requested typewriter. Macintosh urges a scarce design. Macintosh postulates an autobiography. Macintosh tolls the solo variant. Why does a winter audience delay macintosh? The maker tosses macintosh. Beneath female suffers a double scum. How will a rat cube the heavier cricket? Macintosh calls a method. Can macintosh nest opposite the headache? Macintosh ties the wrong fairy. When can macintosh stem the land gang? Female aborts underneath macintosh. Inside macintosh waffles female. Next to macintosh worries a well.