Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Whilst waiting for my tea to brew, and thinking about my latest programming problem, I found myself 'walking the diagonals' on my tiled kitchen floor.

Walking the diagonals means starting in one corner of the rectangle and walking away at 45 degrees:

+---+---+--- | \ | | +---+---+--- | | \ | +---+---+--- | | | \

And when you hit the opposite edge, 'reflect' back in the other direction:

| \ | | | / | ---+---+---+---+---+ | | \ | / | | +---+---+---+---+---

Ditto at the ends:

| | / | +---+---+--- | / | | / +---+---+---+ | \ | / | +---+---+---+

The walk ends when you arrive directly into a corner. See the first diagram, but going the other way.

What I noticed was that starting in one corner, and continuing until I encountered another corner, I found myself in the diagonally opposite corner. When I drew a diagram on a post-it, I discovered that I had walked on every tile exactly once.

This was interesting, because I've been doing this 'walking the diagonals' when deep in thought -- a mindless repetitious activity that frees the mind for deeper things -- and recalled that in my old house kitchen, where the rectangle was the same width, but 2 tiles shorter, the tour also ended up in the opposite diagonal; also covered every tile exactly once and was 14 10 steps smaller.

How big is the rectangle in my current kitchen? Answer: 13 x 5.

(Other answers are possible, particularly 5x9 solution; but most of them would either have required me to use one of the terms: 'kitchenette' or 'galley' (as in train or ship) rather than kitchen :)

I was going to post code, but choroba's is much prettier; especially if you a) stop it considering even numbers; b) add a system 'cls'; or equivalent into the redraw loop; c) reduce the sleep time after the for loop to 1/10th second. Quite hypnotic once the sizes get up a bit (I start it at 21 and inc by 2).

Solution:

Old: 5x11 s/\/\/\/\/\ /\/\/\/\/\/ \/\/\/\/\/\ /\/\/\/\/\/ \/\/\/\/\/e New: 5x13 s/\/\/\/\/\/\ /\/\/\/\/\/\/ \/\/\/\/\/\/\ /\/\/\/\/\/\/ \/\/\/\/\/\/e

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I'm with torvalds on this
In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked

In reply to [OT] One for the weekend. (Updated: Answer posted!) by BrowserUk

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2024-04-24 17:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found