<geezer> Ahh this takes me back. Back around '84 a FORTRAN instructor assigned an 8x8 Queens problem to the class as an extra credit assignment. Elegance wasn't a requirement.

Since I was more interested in writing games, simulations, and comm software than solving logic problems it didn't hold any interest for me. But after a couple of weeks it was apparent that no-one else was making any headway on solving the problem. The instructor gloated.

One afternoon I hacked up a pure Brute Force and Ignorance solution. Howzat? All of the arrangements of 8 queens on a chessboard can be represented as a base-8 counter. Initialize it to 00000000 and add one. Check to see if any digits are repeated or any digits are rows+cols offset from each other (diagonal). Lather, rinse, repeat. It took all of an hour to write and debug, most of that fighting the line editor.

Unleashing that on our Prime 950 (I think it was running PrimeOS 7?) it immediately ground the entire machine to a slow death. Fearing being tortured by my classmates and having the lab people hunt me down like an animal, I managed to stop the program and sneak out. Before I did, I set the program to run at midnight (a phantom job) that night and dump results (the octal numbers representing successful matches) to a file.

The next morning I got the results. 96 matches (which was correct) including rotations and mirrors. The job ran for 1 hour and 10 minutes, and used 1 hour and 3 minutes of CPU time. Thank God this particular University didn't charge students for CPU time.

I used Pascal (which I liked better at the time) to take the results and format them according to the instructor's wishes. I had actually used FORTRAN to solve the problem, so I wasn't cheating... </geezer>


In reply to Re: Efficient N-Queen solution with Perl by clintp
in thread Efficient N-Queen solution with Perl by lestrrat

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.