Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #7181

Re: Short 8 queens solution

From Kaz Kylheku <kaz@kylheku.com>
Newsgroups comp.lang.ruby
Subject Re: Short 8 queens solution
Date 2015-12-29 00:03 +0000
Organization Aioe.org NNTP Server
Message-ID <20151228155018.815@kylheku.com> (permalink)
References <n5scpp$qga$1@dont-email.me>

Show all headers | View raw


On 2015-12-28, WJ <w_a_x_man@yahoo.com> wrote:
> (0..7).to_a.permutation{|b|
>   p b if [:+,:-].all?{|op| 8==b.each_with_index.map(&op).uniq.size}}

TXR Lisp:

1> (keep-if
     (op all [list + -] (opip (mapcar @1 (range 0) @@1)
                              uniq
                              length
                              (eql 8)))
     (perm (range 0 7)))
((0 4 7 5 2 6 1 3) (0 5 7 2 6 3 1 4) (0 6 3 5 7 1 4 2) (0 6 4 7 1 3 5 2)
 (1 3 5 7 2 0 6 4) (1 4 6 0 2 7 5 3) (1 4 6 3 0 7 5 2) (1 5 0 6 3 7 2 4)
 (1 5 7 2 0 3 6 4) (1 6 2 5 7 4 0 3) (1 6 4 7 0 3 5 2) (1 7 5 0 2 4 6 3)
 (2 0 6 4 7 1 3 5) (2 4 1 7 0 6 3 5) (2 4 1 7 5 3 6 0) (2 4 6 0 3 1 7 5)
 (2 4 7 3 0 6 1 5) (2 5 1 4 7 0 6 3) (2 5 1 6 0 3 7 4) (2 5 1 6 4 0 7 3)
 (2 5 3 0 7 4 6 1) (2 5 3 1 7 4 6 0) (2 5 7 0 3 6 4 1) (2 5 7 0 4 6 1 3)
 (2 5 7 1 3 0 6 4) (2 6 1 7 4 0 3 5) (2 6 1 7 5 3 0 4) (2 7 3 6 0 5 1 4)
 (3 0 4 7 1 6 2 5) (3 0 4 7 5 2 6 1) (3 1 4 7 5 0 2 6) (3 1 6 2 5 7 0 4)
 (3 1 6 2 5 7 4 0) (3 1 6 4 0 7 5 2) (3 1 7 4 6 0 2 5) (3 1 7 5 0 2 4 6)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short 8 queens solution "WJ" <w_a_x_man@yahoo.com> - 2015-12-28 22:23 +0000
  Re: Short 8 queens solution Kaz Kylheku <kaz@kylheku.com> - 2015-12-29 00:03 +0000
    Re: Short 8 queens solution Kaz Kylheku <kaz@kylheku.com> - 2015-12-29 00:13 +0000

csiph-web