Hi,

For my comeback to PerlMonks forum, I have an intriguing math problem. I am looking for an efficient way to partition my coordinate system (x,y) into squares. Example:

0 1 2 3 4 5 6 7 8 9 0 1 2 1 2 x 3 x 4 x 5 x 6 x 7 x x 8 x 9 x x 0 x 1 x x 2
Let the square be annotated as a tuple (x,y,s) where x and y are the start coordinates and s is its length. So the first one would be (1,1,3). The thing is that x in the above coordinate marks the beginning of another square so the initiall one cannot be extended over it. The squares cannot overlap and cannot include the next "x" point (in the above graph). Furthermore, the one starting at x=1, y=4 is (1,4,1) and the one at x=3, y=4 is (3,4,2). Also the one starting at x=8, y=7 is (8,7,1) -> the point itself.

Am I making any sense ?

I need to know how many of these squares are in the space and all their coordinates (tuples). Initially I thought this would be an easy task but it seams it is not... any help on how to compute this would be much appreciated.

Thank you !! :)

PS

Code is not so relevant as i will code it once the key ingredient is there and we can optimize it later. But what bugs me is the wrapping my head around the partitioning of the space. UPDATE:

Original 0 1 2 3 4 5 6 7 8 9 0 1 2 1 2 x 3 x 4 x 5 x 6 x 7 x x 8 x 9 x x 0 x 1 x x 2 filled (almost) 0 1 2 3 4 5 6 7 8 9 0 1 2 1 o o o i i i u u g t a k 2 o o o i i i u u z m m m 3 o o o i i i p p p m m m 4 a b j j l l p p p m m m 5 n h j j l l p p p w w b 6 k k s s y y y h k w w c 7 k k s s y y y l n n q q 8 d d u f y y y v n n q q 9 d d p x 0 g u j ... 1 o i i x 2 z i i result: (1,1,3) (4,1,3) (7,1,2) (9,1,1) (10,1,1) (11,1,1) (12,1,1) (7,3,3) (9,2,1) (10,2,3) ...
I just hope i did not missfilled.... so any square that had an x initially now is a starting point to be filled. filling is done left to right and up -> down (sorry for being unclear ) and sorry for reusing the letters when filling

In reply to Tricky math problem ... by baxy77bax

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.