Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Off-the-wall request

From: joel::neely::fedex::com at: 9-Oct-2002 11:41

Hi, folks, I'd like to ask for some volunteers to participate (off-list) in a little experiment. If there is enough participation to make it worthwhile, I'll be glad to summarize/report results back to the list, or some equivalent (such as REBOLforces). Here's the story: I've been having some conversations with collegues lately about the variety of approaches that can be taken with some problems. I'd be interested in seeing the results of having a bunch of programmers tackle the same simple programming problem. THIS IS NOT A CONTEST! I'm simply interested in seeing how many different ways people tend to approach the task, not in evaluating how well I like their solutions. It's not about creating the fastest, smallest, most elegant, (etc.) program, but simply seeing how people tend to think about it. As far as I'm concerned, this is the geekotechish equivalent of asking what your favorite flavor of ice cream is; there are no right or wrong answers, just a curiousity to see what kinds of answers are offered. IF YOU'RE WILLING TO PLAY, read the description below; if not, thanks for reading this far anyway. THE TASK: N-Queens (specifications below) Write a /Core function which can be called with an integer argument as in xxxxxxxxxx 5 (where XXXXXXXXXX is whatever you wish -- function, object/method, ...) and which will reply (in text) either with a solution for the n-queens problem for the specified board size, or with a message indicating that there is no solution for that size. Representation of the solution is entirely up to you. THE PROBLEM: (The pictures are only for the purpose of describing the problem to anyone not familiar with it. They are NOT meant as specifications for the program's representation or output.) For the specified board size (say N), imagine a chess-board of N by N size. For N of 5, this would be something like +-----+-----+-----+-----+-----+ |.....| |.....| |.....| |.....| |.....| |.....| |.....| |.....| |.....| +-----+-----+-----+-----+-----+ | |.....| |.....| | | |.....| |.....| | | |.....| |.....| | +-----+-----+-----+-----+-----+ |.....| |.....| |.....| |.....| |.....| |.....| |.....| |.....| |.....| +-----+-----+-----+-----+-----+ | |.....| |.....| | | |.....| |.....| | | |.....| |.....| | +-----+-----+-----+-----+-----+ |.....| |.....| |.....| |.....| |.....| |.....| |.....| |.....| |.....| +-----+-----+-----+-----+-----+ A solution is a placement of N queens such that no queen threatens another. (Hint: there will be one queen in each column, and one queen in each row.) Since queens can move/attack any distance along a row, column, or diagonal, the following is a solution for N=5: +-----+-----+-----+-----+-----+ |.....| |.....| |.....| |.....| Q |.....| |.....| |.....| |.....| |.....| +-----+-----+-----+-----+-----+ | |.....| |.....| | | |.....| |.....| Q | | |.....| |.....| | +-----+-----+-----+-----+-----+ |.....| |.....| |.....| |.....| |..Q..| |.....| |.....| |.....| |.....| +-----+-----+-----+-----+-----+ | |.....| |.....| | | Q |.....| |.....| | | |.....| |.....| | +-----+-----+-----+-----+-----+ |.....| |.....| |.....| |.....| |.....| Q |.....| |.....| |.....| |.....| +-----+-----+-----+-----+-----+ while the following is not: +-----+-----+-----+-----+-----+ |.....| |.....| |.....| |.....| Q |.....| |.....| |.....| |.....| |.....| +-----+-----+-----+-----+-----+ | |.....| |.....| | | |.....| |..Q..| | | |.....| |.....| | +-----+-----+-----+-----+-----+ |.....| |.....| |.....| |..Q..| |.....| |.....| |.....| |.....| |.....| +-----+-----+-----+-----+-----+ | |.....| |.....| | | |.....| |.....| Q | | |.....| |.....| | +-----+-----+-----+-----+-----+ |.....| |.....| |.....| |.....| |..Q..| |.....| |.....| |.....| |.....| +-----+-----+-----+-----+-----+ THE PROCESS: If you're willing to play, write a stand-alone REBOL/Core source file (one that doesn't depend on any other source files in your personal bag of tricks ;-) that contains your definition of XXXXXXXXXX and email it to me (along with any instructions for usage that you wish) OFF THE LIST at joel DOT neely AT fedex DOT com I'll look through the responses and report back on my observations. I promise to avoid embarrasing anyone. I won't refer to any individuals in my report, and will anonymize any source code snippets that I feel should be included in the remarks. FOR EXTRA FUN: If you wish to submit additional solutions in other languages (than REBOL/Core, that is) I'd be happy to have them. I can't promise to have access to any other language implementations, but this is about looking at source code anyway, so that doesn't really matter. Thanks in advance to anyone willing to participate! -jn- -- ---------------------------------------------------------------------- Joel Neely joelDOTneelyATfedexDOTcom 901-263-4446