%I #46 Jun 24 2024 16:27:03
%S 1,3,2,4,5,6,10,9,8,7,11,12,13,14,15,21,20,19,18,17,16,22,23,24,25,26,
%T 27,28,36,35,34,33,32,31,30,29,37,38,39,40,41,42,43,44,45,55,54,53,52,
%U 51,50,49,48,47,46,56,57,58,59,60,61,62,63,64,65,66
%N Enumeration of natural numbers by the boustrophedonic diagonal method.
%C A triangle such that (1) every positive integer occurs exactly once; (2) row n consists of n consecutive numbers; (3) odd-numbered rows are increasing; and (4) even-numbered rows are decreasing.
%C Self-inverse permutation of the natural numbers.
%C Mirror image of triangle in A056023. - _Philippe Deléham_, Apr 04 2009
%C a(n) is a pairing function: a function that reversibly maps Z^{+} x Z^{+} onto Z^{+}, where Z^{+} is the set of integer positive numbers. - _Boris Putievskiy_, Dec 24 2012
%C For generalizations see A218890, A213927. - _Boris Putievskiy_, Mar 10 2013
%H Reinhard Zumkeller, <a href="/A056011/b056011.txt">Rows n = 1..125 of table, flattened</a>
%H Boris Putievskiy, <a href="http://arxiv.org/abs/1212.2732">Transformations Integer Sequences And Pairing Functions</a>, arXiv:1212.2732 [math.CO], 2012.
%H Eric W. Weisstein, <a href="http://mathworld.wolfram.com/PairingFunction.html">MathWorld: Pairing functions</a>
%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%F a(n) = ((i+j-1)*(i+j-2)+((-1)^t+1)*i - ((-1)^t-1)*j)/2, where i=n-t*(t+1)/2, j=(t*t+3*t+4)/2-n, t=floor((-1+sqrt(8*n-7))/2). - _Boris Putievskiy_, Dec 24 2012
%e The start of the sequence as a table:
%e 1, 3, 4, 10, 11, 21, ...
%e 2, 5, 9, 12, 20, 23, ...
%e 6, 8, 13, 19, 24, 34, ...
%e 7, 14, 18, 25, 33, 40, ...
%e 15, 17, 26, 32, 41, 51, ...
%e ...
%e Enumeration by boustrophedonic ("ox-plowing") diagonal method. - _Boris Putievskiy_, Dec 24 2012
%e The start of the sequence as triangle array read by rows:
%e 1;
%e 3, 2;
%e 4, 5, 6;
%e 10, 9, 8, 7;
%e 11, 12, 13, 14, 15;
%e ...
%p A056011 := proc(n,k)
%p if type(n,'even') then
%p A131179(n)-k+1 ;
%p else
%p A131179(n)+k-1 ;
%p end if;
%p end proc: # _R. J. Mathar_, Sep 05 2012
%t Flatten[If[EvenQ[Length[#]],Reverse[#],#]&/@Table[c=(n(n+1))/2;Range[ c-n+1,c],{n,20}]] (* _Harvey P. Dale_, Mar 25 2012 *)
%t With[{nn=20},{#[[1]],Reverse[#[[2]]]}&/@Partition[ TakeList[ Range[ (nn(nn+1))/2],Range[nn]],2]//Flatten] (* _Harvey P. Dale_, Oct 05 2021 *)
%o (Haskell)
%o a056011 n = a056011_tabl !! (n-1)
%o a056011_list = concat a056011_tabl
%o a056011_tabl = ox False a000027_tabl where
%o ox turn (xs:xss) = (if turn then reverse xs else xs) : ox (not turn) xss
%o a056011_row n = a056011_tabl !! (n-1)
%o -- _Reinhard Zumkeller_, Nov 08 2013
%Y Cf. A079826, A131179 (first column), A218890, A213927.
%Y Cf. A000027, A038722.
%K nonn,tabl,nice,easy
%O 1,2
%A _Clark Kimberling_, Aug 01 2000
%E New name from _Peter Luschny_, Apr 15 2023, based on _Boris Putievskiy_'s comment