A065188 "Greedy Queens" permutation of the positive integers.
1, 3, 5, 2, 4, 9, 11, 13, 15, 6, 8, 19, 7, 22, 10, 25, 27, 29, 31, 12, 14, 35, 37, 39, 41, 16, 18, 45, 17, 48, 20, 51, 53, 21, 56, 58, 60, 23, 63, 24, 66, 28, 26, 70, 72, 74, 76, 78, 30, 32, 82, 84, 86, 33, 89, 34, 92, 38, 36, 96, 98, 100, 102, 40, 105, 107, 42, 110, 43, 113
Offset: 1
Keywords
Examples
The top left corner of the board is: +------------------------ | Q x x x x x x x x x ... | x x x Q x x x x x x ... | x Q x x x x x x x x ... | x x x x Q x x x x x ... | x x Q x x x x x x x ... | x x x x x x x x x Q ... | x x x x x x x x x x ... | x x x x x x x x x x ... | x x x x x Q x x x x ... | ... which illustrates p(1)=1, p(2)=3, p(3)=5, p(4)=2, etc. - _N. J. A. Sloane_, Aug 18 2016, corrected Aug 21 2016
Links
- Alois P. Heinz, Table of n, a(n) for n = 1..10000
- F. Michel Dekking, Jeffrey Shallit, and N. J. A. Sloane, Queens in exile: non-attacking queens on infinite chess boards, Electronic J. Combin., 27:1 (2020), #P1.52.
- Matteo Fischetti and Domenico Salvagnin, Chasing First Queens by Integer Programming, 2018.
- Matteo Fischetti and Domenico Salvagnin, Finding First and Most-Beautiful Queens by Integer Programming, arXiv:1907.08246 [cs.DS], 2019.
- N. J. A. Sloane, Scatterplot of first 100 terms
- N. J. A. Sloane, Table of n, a(n) for n = 1..50000 [Obtained using the Maple program of _Alois P. Heinz_]
- Index entries for sequences that are permutations of the natural numbers
Crossrefs
A065185 gives the associated p(i)-i delta sequence. A065186 gives the corresponding permutation for "promoted rooks" used in Shogi, A065257 gives "Quintal Queens" permutation.
A065189 gives inverse permutation.
See A199134, A275884, A275890, A275891, A275892 for information about the split of points below and above the diagonal.
Cf. A269526.
Programs
-
Maple
SquareThreatened := proc(a,i,j,upto_n,senw,nesw) local k; for k from 1 to i do if a[k,j] > 0 then RETURN(1); fi; od; for k from 1 to j do if a[i,k] > 0 then RETURN(1); fi; od; if 1 = i and 1 = j then RETURN(0); fi; for k from 1 to `if`((-1 = senw),min(i,j)-1,senw) do if a[i-k,j-k] > 0 then RETURN(1); fi; od; for k from 1 to `if`((-1 = nesw),i-1,nesw) do if a[i-k,j+k] > 0 then RETURN(1); fi; od; for k from 1 to `if`((-1 = nesw),j-1,nesw) do if a[i+k,j-k] > 0 then RETURN(1); fi; od; RETURN(0); end; GreedyNonThreateningPermutation := proc(upto_n,senw,nesw) local a,i,j; a := array(1..upto_n,1..upto_n); for i from 1 to upto_n do for j from 1 to upto_n do a[i,j] := 0; od; od; for j from 1 to upto_n do for i from 1 to j do if 0 = SquareThreatened(a,i,(j-i+1),upto_n,senw,nesw) then a[i,j-i+1] := 1; fi; od; od; RETURN(eval(a)); end; PM2PL := proc(a,upto_n) local b,i,j; b := []; for i from 1 to upto_n do for j from 1 to upto_n do if a[i,j] > 0 then break; fi; od; b := [op(b),`if`((j > upto_n),0,j)]; od; RETURN(b); end; GreedyQueens := upto_n -> PM2PL(GreedyNonThreateningPermutation(upto_n,-1,-1),upto_n);GreedyQueens(256); # From Alois P. Heinz, Aug 19 2016: (Start) max_diagonal:= 3 * 100: # make this about 3*max number of terms h:= proc() true end: # horizontal line free? v:= proc() true end: # vertical line free? u:= proc() true end: # up diagonal free? d:= proc() true end: # down diagonal free? a:= proc() 0 end: # for A065188 b:= proc() 0 end: # for A065189 for t from 2 to max_diagonal do if u(t) then for j to t-1 do i:= t-j; if v(j) and h(i) and d(i-j) then v(j),h(i),d(i-j),u(i+j):= false$4; a(j):= i; b(i):= j; break fi od fi od: seq(a(n), n=1..100); # this is A065188 seq(b(n), n=1..100); # this is A065189 # (End)
-
Mathematica
Fold[Function[{a, n}, Append[a, 2 + LengthWhile[Differences@ Union@ Apply[Join, MapIndexed[Select[#2 + #1 {-1, 0, 1}, # > 0 &] & @@ {n - First@ #2, #1} &, a]], # == 1 &]]], {1}, Range[2, 70]] (* Michael De Vlieger, Jan 14 2018 *)
-
PARI
A065188_first(N, a=List(), u=[0])={for(n=1,N, for(x=u[1]+1,oo, setsearch(u,x) && next; for(i=1,n-1, abs(x-a[i])==n-i && next(2)); u=setunion(u,[x]); while(#u>1 && u[2]==u[1]+1, u=u[^1]); listput(a,x); break));a} \\ M. F. Hasler, Jan 11 2022
Formula
It would be nice to have a formula! - N. J. A. Sloane, Jun 30 2016
a(n) = A275895(n-1)-1. - M. F. Hasler, Jan 11 2022
Comments