Path: utzoo!utgpu!watserv1!watmath!att!mcdchg!chinet!laird From: laird@chinet.chi.il.us (Laird J. Heal) Newsgroups: comp.sources.wanted Subject: Re: Wanted "Eight Queen Problem" in C, Modula2, Lisp or Prolog !! Keywords: "academic dishonesty" is what they call it here Message-ID: <1990Oct18.105325.593@chinet.chi.il.us> Date: 18 Oct 90 10:53:25 GMT References: <1353@ul-cs.ulowell.edu> <1990Oct16.125350.3405@maverick.ksu.ksu.edu> Organization: Chinet - Chicago Public Access UNIX Lines: 40 In article <1990Oct16.125350.3405@maverick.ksu.ksu.edu> tar@math.ksu.edu (Tim Ramsey) writes: >hpatel@hawk.ulowell.edu (WHY AM I HERE ???) writes: >>Hello Friends, >> I need this problem called "Eight Queen Problem" very badly. >>The problem is about the chess game. (8 by 8 board) The queen should be >>placed the way that no queen will kill any other queen. >> If you have this problem written in C, C++, Modula2, Lisp or Prolog, >>Please mail me. >> Thank you very much. >Ah, I remember this homework assignment. Does your instructor read >comp.sources.wanted? Sir, you jump to conclusions: besides, that program is published, although not too widely. Still, it would be more entertaining to solve it directly rather than wait for the net to cough it up. Eight ranks, eight files, put the queens on one rank each and use eight nested loops for file placement, measuring on the diagonals to determine if any can see the other. If one is clever he can replace the eight nested loops with a recursive algorithm to test all combinations without ever testing to see if there were more than one queen on a file, instead switching positions in sequence. >Tim Ramsey (tar@hilbert.math.ksu.edu) (913) 532-6750 (voice) 2-7004 (FAX) >Department of Mathematics, Kansas State University, Manhattan KS 66506 It brings to mind a problem an Algol class had once, to take twelve (12) balls eleven (11) of which had the same weight and figure out which ball was different and by how much with only three weighings and with only three Algol statements. I was not taking that class, but I later solved the problem and wrote it up as a student's choice in a Fortran class. The three Algol statements came from the need to have an input, an output, and a very long nested if, hardly what one should teach his students today. The Fortran three-way if statement was well- suited to that particular problem. -- My .signature is on vacation ------------- like me!