%I #86 Jan 01 2024 08:02:28
%S 1,2,3,4,5,6,9,12,16,20,27,36,48,64,81,108,144,192,256,324,432,576,
%T 768,1024,1296,1728,2304,3072,4096,5184,6912,9216,12288,16384,20736,
%U 27648,36864,49152,65536,82944,110592,147456,196608,262144,331776,442368,589824,786432,1048576,1327104,1769472,2359296,3145728,4194304
%N a(n) = solution to the "Select All, Copy, Paste" problem: Given the ability to type a single letter, or to type individual "Select All", "Copy" or "Paste" command keystrokes, what is the maximal number of letters of text that can be obtained with n keystrokes?
%C It is assumed that we start with a single letter in the copy buffer.
%C Alternatively, a(n-1) = maximal value of Product (k_i-1) for any way of writing n = Sum k_i.
%C 1. The description above assumes that the text is deselected after the Copy command is invoked.
%C 2. This sequence is the solution to the equivalent problem formulated as {insert, "Select All+ Copy" macro (without deselection), Paste}.
%C 3. This sequence is a "paradigm-shift" sequence with procedure length p =1 (in the sense of A193455).
%C 4. The optimal number of pastes per copy, as measured by the geometric growth rate (p+z root of z), is z = 4. [noninteger maximum between 3 and 4]
%C 5. The function a(n) = maximum value of the product of the terms k_i, where Sum (k_i) = n+1-i_max.
%C 6. All solutions will be of the form a(n) = m^b * (m+1)^d.
%H William Boyles, <a href="/A178715/b178715.txt">Table of n, a(n) for n = 1..8303</a> (terms 1..101 from Joerg Arndt) (all terms with at most 1000 digits)
%H Jonathan T. Rowell, <a href="https://cs.uwaterloo.ca/journals/JIS/VOL18/Rowell/rowell3.html">Solution Sequences for the Keyboard Problem and its Generalizations</a>, Journal of Integer Sequences, Vol. 18 (2015), Article 15.10.7.
%H <a href="/index/Rec#order_05">Index entries for linear recurrences with constant coefficients</a>, signature (0,0,0,0,4).
%F a(n) = 4*a(n-5) for n>=16.
%F a(n) =
%F a(5;10) = 5; 20 [C=1, 2 below, respectively]
%F a(n=1:14) = Q^(C-R)*(Q+1)^R
%F where C = floor(n/5)+1, R = n+1 mod C,
%F and Q = floor(n+1/C)-1
%F a(n>=15) = 3^(4-R)*4^(C-4+R)
%F where C = floor (n/5)+1, R = n mod 5.
%F G.f.: x*(1 +2*x +3*x^2 +4*x^3 +5*x^4 +2*x^5 +x^6 +3*x^10 +x^14) / (1 -4*x^5). - _Colin Barker_, Nov 19 2016
%e For n = 7 the a(7) = 9 solution is to type the seven keystrokes: paste, paste, paste, select-all, copy, paste paste which yields nine text characters.
%e Here is a table showing the pattern for n = 1 to 35. The first column is n and the second column is the number of characters that can be obtained with n keystrokes. The remainder of the line shows how to get the maximum, as follows. S = Select and C = Copy while a dot stands for Paste. The dots at the beginning of a line are equivalent to a single letter being typed, based on the assumption that at the start there is a single letter in the paste buffer.
%e 01: 00001 .
%e 02: 00002 ..
%e 03: 00003 ...
%e 04: 00004 ....
%e 05: 00005 .....
%e 06: 00006 ......
%e 07: 00009 ...SC..
%e 08: 00012 ....SC..
%e 09: 00016 ....SC...
%e 10: 00020 .....SC...
%e 11: 00027 ...SC..SC..
%e 12: 00036 ....SC..SC..
%e 13: 00048 ....SC...SC..
%e 14: 00064 ....SC...SC...
%e 15: 00081 ...SC..SC..SC..
%e 16: 00108 ....SC..SC..SC..
%e 17: 00144 ....SC...SC..SC..
%e 18: 00192 ....SC...SC...SC..
%e 19: 00256 ....SC...SC...SC...
%e 20: 00324 ....SC..SC..SC..SC..
%e 21: 00432 ....SC...SC..SC..SC..
%e 22: 00576 ....SC...SC...SC..SC..
%e 23: 00768 ....SC...SC...SC...SC..
%e 24: 01024 ....SC...SC...SC...SC...
%e 25: 01296 ....SC...SC..SC..SC..SC..
%e 26: 01728 ....SC...SC...SC..SC..SC..
%e 27: 02304 ....SC...SC...SC...SC..SC..
%e 28: 03072 ....SC...SC...SC...SC...SC..
%e 29: 04096 ....SC...SC...SC...SC...SC...
%e 30: 05184 ....SC...SC...SC..SC..SC..SC..
%e 31: 06912 ....SC...SC...SC...SC..SC..SC..
%e 32: 09216 ....SC...SC...SC...SC...SC..SC..
%e 33: 12288 ....SC...SC...SC...SC...SC...SC..
%e 34: 16384 ....SC...SC...SC...SC...SC...SC...
%e 35: 20736 ....SC...SC...SC...SC..SC..SC..SC..
%e It appears that A000792 is the result if only one keystroke instead of two is required for the "Select All, Copy" operation. Here is the table. Here "C" means that all the previously typed characters are copied to the paste buffer.
%e 01: 00001 .
%e 02: 00002 ..
%e 03: 00003 ...
%e 04: 00004 ....
%e 05: 00006 ...C.
%e 06: 00009 ...C..
%e 07: 00012 ....C..
%e 08: 00018 ...C..C.
%e 09: 00027 ...C..C..
%e 10: 00036 ....C..C..
%e 11: 00054 ...C..C..C.
%e 12: 00081 ...C..C..C..
%e 13: 00108 ....C..C..C..
%e 14: 00162 ...C..C..C..C.
%e 15: 00243 ...C..C..C..C..
%e 16: 00324 ....C..C..C..C..
%e 17: 00486 ...C..C..C..C..C.
%e 18: 00729 ...C..C..C..C..C..
%e 19: 00972 ....C..C..C..C..C..
%e 20: 01458 ...C..C..C..C..C..C.
%e 21: 02187 ...C..C..C..C..C..C..
%e 22: 02916 ....C..C..C..C..C..C..
%e 23: 04374 ...C..C..C..C..C..C..C.
%e 24: 06561 ...C..C..C..C..C..C..C..
%e 25: 08748 ....C..C..C..C..C..C..C..
%e 26: 13122 ...C..C..C..C..C..C..C..C.
%e 27: 19683 ...C..C..C..C..C..C..C..C..
%e 28: 26244 ....C..C..C..C..C..C..C..C..
%e 29: 39366 ...C..C..C..C..C..C..C..C..C.
%e 30: 59049 ...C..C..C..C..C..C..C..C..C..
%e 31: 78732 ....C..C..C..C..C..C..C..C..C..
%t LinearRecurrence[{0,0,0,0,4},{1,2,3,4,5,6,9,12,16,20,27,36,48,64,81},60] (* _Harvey P. Dale_, Apr 11 2017 *)
%o (PARI) Vec(x*(1 +2*x +3*x^2 +4*x^3 +5*x^4 +2*x^5 +x^6 +3*x^10 +x^14) / (1 -4*x^5) + O(x^100)) \\ _Colin Barker_, Nov 19 2016
%o (Python)
%o def a(n):
%o c=(n//5) + 1
%o if n<15:
%o if n==5: return 5
%o if n==10: return 20
%o r=(n + 1)%c
%o q=((n + 1)//c) - 1
%o return q**(c - r)*(q + 1)**r
%o else:
%o r=n%5
%o return 3**(4 - r)*4**(c - 4 + r)
%o print([a(n) for n in range(1, 102)]) # _Indranil Ghosh_, Jun 27 2017
%Y See A193286 for another version. Cf. A000792.
%Y A000792, A178715, A193286, A193455, A193456, and A193457 are paradigm shift sequences with procedure lengths p=0,1,...,5, respectively.
%Y Cf. A367116 (squares summing to n).
%K nonn,nice,easy
%O 1,2
%A _Bill Blewett_, Jan 11 2011
%E Edited by _N. J. A. Sloane_, Jul 21 2011
%E Additional comment and formula from _David Applegate_, Jul 21 2011
%E Additional comments, formulas, and CrossRefs by _Jonathan T. Rowell_, Jul 30 2011
%E More terms from _Joerg Arndt_, Nov 15 2014