The mathematics of CTRLC CTRLV
Moderators: gmalivuk, Moderators General, Prelates
The mathematics of CTRLC CTRLV
So let's say I want to type "this is spam this is spam this is spam this is spam this is spam this is spam this is spam this is spam this is spam this is spam..."
I want to type the string "this is spam" 20 times.
So I type it once, 13 keystrokes including the space at the end. I hit ctrl+(a, c, (v*20)). Total of 36 keystrokes.
But, I can also do ctrl+(a, c, (v*10), a, c, (v*2)) for a total of 30 keystrokes.
I can also do ctrl+(a, c, (v*5), a, c, (v*4)) for a total of 27
There has to be a mathematical formula to find the best way to do this  time is money!!!
I want to type the string "this is spam" 20 times.
So I type it once, 13 keystrokes including the space at the end. I hit ctrl+(a, c, (v*20)). Total of 36 keystrokes.
But, I can also do ctrl+(a, c, (v*10), a, c, (v*2)) for a total of 30 keystrokes.
I can also do ctrl+(a, c, (v*5), a, c, (v*4)) for a total of 27
There has to be a mathematical formula to find the best way to do this  time is money!!!
Re: The mathematics of CTRLC CTRLV
Well, best thing i can think of doing is doing a series of experiments and recording them as coordinate pairs. this will generate some points to which you can do regression analysis for and using calculus you can minimize the keystrokes. You could also just brute force it entirely to find the minimum number of keystrokes. Unfortunately I cannot think of any nice purely mathematical approach, but I do hope some one can for the sake of elegance.

 Posts: 127
 Joined: Wed Apr 09, 2008 2:52 am UTC
Re: The mathematics of CTRLC CTRLV
Here are my initial thoughts:
Spoiler:
"It is common sense to take a method and try it. If it fails, admit it frankly and try another. But above all, try something."
 Franklin D. Roosevelt
 Franklin D. Roosevelt

 Posts: 111
 Joined: Wed Sep 30, 2009 2:26 am UTC
 Location: Lima, Perú
 Contact:
Re: The mathematics of CTRLC CTRLV
These ideas might be helpful: Exponentiation by squaring.
Gott weiß ich will kein Engel sein!
Re: The mathematics of CTRLC CTRLV
Sounds like trying to find the minimal addition chain, a hard problem.
 squareroot1
 Posts: 172
 Joined: Fri Nov 06, 2009 8:27 pm UTC
Re: The mathematics of CTRLC CTRLV
Questions:
Am I to assume the paste operation copies over what is selected, and after one paste the cursor goes to the end of the string? I assume yes on both counts.
Is there 'free' selection with the mouse or move to end of selection by hitting right arrow? I assume neither.
Do you have to hit the desired number of copies exactly? Did both, kinda.
In math,If you can overshoot it is mostly trivial,
For the exact case, I suspect
Edit: Better notation, thanks Qaanol.
Am I to assume the paste operation copies over what is selected, and after one paste the cursor goes to the end of the string? I assume yes on both counts.
Is there 'free' selection with the mouse or move to end of selection by hitting right arrow? I assume neither.
Do you have to hit the desired number of copies exactly? Did both, kinda.
In math,
Spoiler:
Spoiler:
Spoiler:
Edit: Better notation, thanks Qaanol.
EduardoLeon wrote:These ideas might be helpful: Exponentiation by squaring.
There doesn't appear to be a method to select less significant groupings of copies. It seems like we are limited to ctrl+a,c, and v, and the implied action of the cursor after ctrl+v, so what you currently have is all you can use. This severely reduces the complexity of the problem and makes it much easier than the minimal addition chain. Atleast that's how I understand it.qbg wrote:Sounds like trying to find the minimal addition chain, a hard problem.
Last edited by squareroot1 on Sat Nov 21, 2009 6:55 am UTC, edited 1 time in total.
Re: The mathematics of CTRLC CTRLV
27 is minimal here.
Edit: Incorrect statements removed, thanks.
Edit: Incorrect statements removed, thanks.
Last edited by Qaanol on Sat Nov 21, 2009 12:24 pm UTC, edited 2 times in total.
wee free kings
 squareroot1
 Posts: 172
 Joined: Fri Nov 06, 2009 8:27 pm UTC
Re: The mathematics of CTRLC CTRLV
Qaanol wrote:27 is minimal here. There are 5 different ways to achieve it.
[math]acv^5acv^4 = acv^4acv^5 = acvacvacv^5 = acvacv^5acv = acv^5acvacv[/math]
acv^4 can't equal acvacv, either acvacv=acv^3 or acv^2acv^2 = acv^4
Ctrl+v is either overwrite or append, hopefully OP will clear up which is preferred.

 Posts: 778
 Joined: Mon Aug 11, 2008 10:58 pm UTC
 Location: Palo Alto, CA
Re: The mathematics of CTRLC CTRLV
As someone already said, this is an addition chain problem. There is no known algorithm to find the optimal chain that is better than brute force search. That isn't to say that it's impossible for one to exist, but the related decision problem is NPcomplete, so if you found a fast algorithm for this, you would have better things to worry about anyway.
GENERATION 16 + 31i: The first time you see this, copy it into your sig on any forum. Square it, and then add i to the generation.
Re: The mathematics of CTRLC CTRLV
squareroot1 wrote:Ctrl+v is either overwrite or append, hopefully OP will clear up which is preferred.
It is both. Immediately after Ctrla Ctrlc, all the text is selected, so all Ctrlv does is to overwrite the text with the same thing, but deselects it and puts the cursor at the end. Subsequent Ctrlvs will append a copy of the original text.
All posts are works in progress. If I posted something within the last hour, chances are I'm still editing it.
Re: The mathematics of CTRLC CTRLV
OK, this is less hard than people are claiming. Admittedly, finding an optimal chain requires you to be able to factorize, but then so does finding any nontrivial chain.
Let [imath]f(n_1, \ldots, n_k)[/imath] be the number of copies of the original text created by [imath]acv^{n_1} \ldots acv^{n_k}[/imath], and let [imath]g(n_1, \ldots, n_k)[/imath] be the number of keystrokes required. Clearly [imath]g(n_1, \ldots, n_k) = c + \sum_{i=1}^k (n_i + 2)[/imath].
Lemma 1: [imath]f(n_1, \ldots, n_k) = \prod_{i=1}^k n_i[/imath].
Proof: In any sequence of ctrlvs, the first v will overwrite the original text, and subsequent ones will duplicate it, so f(n) = n. Given [imath](n_1, \ldots, n_k)[/imath], the last [imath]n_k[/imath] ctrlvs will copy the result of what came before [imath]n_k[/imath] times, so [imath]f(n_1, \ldots, n_k) = n_k f(n_1, \ldots, n_{k1})[/imath]. So the result follows by induction on k.
The problem given can be rephrased as choosing [imath]k[/imath] and [imath](n_1, \ldots, n_k)[/imath] to minimize [imath]g(n_1, \ldots, n_k)[/imath], subject to [imath]f(n_1, \ldots, n_k) = N[/imath]. Neither f nor g depend on the ordering of the [imath]n_i[/imath], so we merely need to find a factorization of N that minimizes g.
Certainly optimal factorizations exist  let's assume we have one. What can we say about it? Certainly if [imath]n[/imath] appears in it, we shouldn't be able to factorize it into [imath]p[/imath] and [imath]q[/imath] with [imath]p + q + 2 < n[/imath], otherwise our factorization wouldn't be optimal. What numbers cannot be factorized in this way?
Lemma 2: If [imath]n[/imath] appears in an optimal factorization, then [imath]n[/imath] is either prime, 4, 6 or 8.
Proof: Let [imath]n[/imath] be in some optimal factorization, and let [imath]pq = n[/imath]. Without loss of generality let [imath]p \leq q[/imath]. If [imath]p \geq 3[/imath], then [imath]p + q + 2 < 3q \leq n[/imath], so the factorization is not optimal. If [imath]p = 2[/imath], then [imath]p + q + 2 \geq n[/imath] implies [imath]\frac{n}{2}+4 \geq n[/imath] implies [imath]n \leq 8[/imath]. And if [imath]p=1[/imath], then [imath]p+q+2 = n+3 > n[/imath], which is certainly worse.
Thus we only need to worry about the prime factors dividing n that are 2 or 3, as any other prime factor p of N must appear as a sequence of p keystrokes only. We might as well not have any 8s, as g(4,2) = g(8). Also, g(6,2) < g(4,3), so 2s would rather be paired with other 2s than 3s. So our sequence consists of all the prime factors greater than 3, then as many 4s as possible, then a 6 if we have an spare 2 and a 3, then any 2s or 3s that are left. This is optimal.
EDIT: Slight notation correction.
Let [imath]f(n_1, \ldots, n_k)[/imath] be the number of copies of the original text created by [imath]acv^{n_1} \ldots acv^{n_k}[/imath], and let [imath]g(n_1, \ldots, n_k)[/imath] be the number of keystrokes required. Clearly [imath]g(n_1, \ldots, n_k) = c + \sum_{i=1}^k (n_i + 2)[/imath].
Lemma 1: [imath]f(n_1, \ldots, n_k) = \prod_{i=1}^k n_i[/imath].
Proof: In any sequence of ctrlvs, the first v will overwrite the original text, and subsequent ones will duplicate it, so f(n) = n. Given [imath](n_1, \ldots, n_k)[/imath], the last [imath]n_k[/imath] ctrlvs will copy the result of what came before [imath]n_k[/imath] times, so [imath]f(n_1, \ldots, n_k) = n_k f(n_1, \ldots, n_{k1})[/imath]. So the result follows by induction on k.
The problem given can be rephrased as choosing [imath]k[/imath] and [imath](n_1, \ldots, n_k)[/imath] to minimize [imath]g(n_1, \ldots, n_k)[/imath], subject to [imath]f(n_1, \ldots, n_k) = N[/imath]. Neither f nor g depend on the ordering of the [imath]n_i[/imath], so we merely need to find a factorization of N that minimizes g.
Certainly optimal factorizations exist  let's assume we have one. What can we say about it? Certainly if [imath]n[/imath] appears in it, we shouldn't be able to factorize it into [imath]p[/imath] and [imath]q[/imath] with [imath]p + q + 2 < n[/imath], otherwise our factorization wouldn't be optimal. What numbers cannot be factorized in this way?
Lemma 2: If [imath]n[/imath] appears in an optimal factorization, then [imath]n[/imath] is either prime, 4, 6 or 8.
Proof: Let [imath]n[/imath] be in some optimal factorization, and let [imath]pq = n[/imath]. Without loss of generality let [imath]p \leq q[/imath]. If [imath]p \geq 3[/imath], then [imath]p + q + 2 < 3q \leq n[/imath], so the factorization is not optimal. If [imath]p = 2[/imath], then [imath]p + q + 2 \geq n[/imath] implies [imath]\frac{n}{2}+4 \geq n[/imath] implies [imath]n \leq 8[/imath]. And if [imath]p=1[/imath], then [imath]p+q+2 = n+3 > n[/imath], which is certainly worse.
Thus we only need to worry about the prime factors dividing n that are 2 or 3, as any other prime factor p of N must appear as a sequence of p keystrokes only. We might as well not have any 8s, as g(4,2) = g(8). Also, g(6,2) < g(4,3), so 2s would rather be paired with other 2s than 3s. So our sequence consists of all the prime factors greater than 3, then as many 4s as possible, then a 6 if we have an spare 2 and a 3, then any 2s or 3s that are left. This is optimal.
EDIT: Slight notation correction.
Last edited by Token on Sat Nov 21, 2009 1:06 pm UTC, edited 1 time in total.
All posts are works in progress. If I posted something within the last hour, chances are I'm still editing it.
Re: The mathematics of CTRLC CTRLV
Token wrote:OK, this is less hard than people are claiming. Admittedly, finding an optimal chain requires you to be able to factorize, but then so does finding any nontrivial chain.
Let [imath]f(n_1, \ldots, n_k)[/imath] be the number of copies of the original text created by [imath]acv^{n_1} \ldots acv^{n_k}[/imath], and let [imath]g(n_1, \ldots, n_k)[/imath] be the number of keystrokes required. Clearly [imath]g(n_1, \ldots, n_k) = c + \sum_{i=1}^k (n_i + 2)[/imath].
Lemma 1: [imath]f(n_1, \ldots, n_k) = \prod_{i=1}^k n_i[/imath].
Proof: In any sequence of ctrlvs, the first v will overwrite the original text, and subsequent ones will duplicate it, so f(n) = n. Given [imath](n_1, \ldots, n_k)[/imath], the last [imath]n_k[/imath] ctrlvs will copy the result of what came before [imath]n_k[/imath] times, so [imath]f(n_1, \ldots, n_k) = n_k f(n_1, \ldots, n_{k1})[/imath]. So the result follows by induction on k.
The problem given can be rephrased as choosing [imath]k[/imath] and [imath](n_1, \ldots, n_k)[/imath] to minimize [imath]g(n_1, \ldots, n_k)[/imath], subject to [imath]f(n_1, \ldots, n_k) = N[/imath]. Neither f nor g depend on the ordering of the [imath]n_i[/imath], so we merely need to find a factorization of N that minimizes g.
Certainly optimal factorizations exist  let's assume we have one. What can we say about it? Certainly if [imath]n[/imath] appears in it, we shouldn't be able to factorize it into [imath]p[/imath] and [imath]q[/imath] with [imath]p + q + 2 < n[/imath], otherwise our factorization wouldn't be optimal. What numbers cannot be factorized in this way?
Lemma 2: If [imath]n[/imath] appears in an optimal factorization, then [imath]n_i[/imath] is either prime, 4, 6 or 8.
Proof: Let [imath]n[/imath] be in some optimal factorization, and let [imath]pq = n[/imath]. Without loss of generality let [imath]p \leq q[/imath]. If [imath]p \geq 3[/imath], then [imath]p + q + 2 < 3q \leq n[/imath], so the factorization is not optimal. If [imath]p = 2[/imath], then [imath]p + q + 2 \geq n[/imath] implies [imath]\frac{n}{2}+4 \geq n[/imath] implies [imath]n \leq 8[/imath]. And if [imath]p=1[/imath], then [imath]p+q+2 = n+3 > n[/imath], which is certainly worse.
Thus we only need to worry about the prime factors dividing n that are 2 or 3, as any other prime factor p of N must appear as a sequence of p keystrokes only. We might as well not have any 8s, as g(4,2) = g(8). Also, g(6,2) < g(4,3), so 2s would rather be paired with other 2s than 3s. So our sequence consists of all the prime factors greater than 3, then as many 4s as possible, then a 6 if we have an spare 2 and a 3, then any 2s or 3s that are left. This is optimal.
Well done.
If you want to maximize the number of copies that will be produced should you have to stop early, then work your way through the list from smallest to largest, and don't combine a 2 and 4 into an 8.
wee free kings
 squareroot1
 Posts: 172
 Joined: Fri Nov 06, 2009 8:27 pm UTC
Re: The mathematics of CTRLC CTRLV
Token wrote:squareroot1 wrote:Ctrl+v is either overwrite or append, hopefully OP will clear up which is preferred.
It is both. Immediately after Ctrla Ctrlc, all the text is selected, so all Ctrlv does is to overwrite the text with the same thing, but deselects it and puts the cursor at the end. Subsequent Ctrlvs will append a copy of the original text.
Good point, I was mainly stressing whether Ctrlv would do that initial overwrite of the selected text or not. Basically, acv^2 is doubling, not acv which is the identity.
Token wrote:Thus we only need to worry about the prime factors dividing n that are 2 or 3, as any other prime factor p of N must appear as a sequence of p keystrokes only. We might as well not have any 8s, as g(4,2) = g(8). Also, g(6,2) < g(4,3), so 2s would rather be paired with other 2s than 3s. So our sequence consists of all the prime factors greater than 3, then as many 4s as possible, then a 6 if we have an spare 2 and a 3, then any 2s or 3s that are left. This is optimal.
I got the same result after fiddling with the approach I outlined above. I ended up watching Bones and The Bourne Ultimatum instead of posting. I didn't bother proving it with lemmas and all that jazz, but yeah. Spoiled for length.
Spoiler:
Edit: Very nice Token, very nice indeed.
Re: The mathematics of CTRLC CTRLV
Hold down CTRL+V till the message has appeared 13 times, let go = 13*(CTRL+V) managed in one keystroke
Re: The mathematics of CTRLC CTRLV
The method described in this thread is usually optimal, but not always for large N. For instance, outputting "this is spam " 257 times takes 272 keystrokes by that method, but there's a way to do it in 58 (57 if you don't need a trailing space at the very end).
 squareroot1
 Posts: 172
 Joined: Fri Nov 06, 2009 8:27 pm UTC
Re: The mathematics of CTRLC CTRLV
Nitrodon wrote:The method described in this thread is usually optimal, but not always for large N. For instance, outputting "this is spam " 257 times takes 272 keystrokes by that method, but there's a way to do it in 58 (57 if you don't need a trailing space at the very end).
I assume you mean "this is spam "(acv^4)^4"this is spam"? Oh wait, that's 49 keystrokes (50 with the trailing space.) But it also uses keystrokes other than ctrl+{a,c,v}.
My method is obviously used to create N copies from a given, arbitrary string. I'm fairly sure I don't refer to the length of the initial string, because I'm not interested in an addition chain problem.
Sobuno wrote:Hold down CTRL+V till the message has appeared 13 times, let go = 13*(CTRL+V) managed in one keystroke
Sigh, so obviously its trivial, turn the repeat rate for the keyboard as high as possible, then do acv* and hold v until you get the desired number of copies. Release at the appropriate millisecond. Don't overshot! If you do, av* and try again.
Last edited by squareroot1 on Sat Nov 21, 2009 11:45 pm UTC, edited 1 time in total.
Re: The mathematics of CTRLC CTRLV
I count 50.
Initial 13 + ctrl + (1 + 1 + 4)*4 + 13 = 13 + 1 + 24 + 12 = 50
Initial 13 + ctrl + (1 + 1 + 4)*4 + 13 = 13 + 1 + 24 + 12 = 50
wee free kings
Re: The mathematics of CTRLC CTRLV
Thanks a lot for all the replies  my math background is not good enough to know all the references, but I understand the formulas.
This is true  the only time string length would ever make a difference would be if it were less than 4 keystrokes (typing 'a <space> a <space> ctrl+(acv)' is faster than 'a <space> ctrl+(acv acv)') but that only really matters for the initial steps, and the rules of what changes are pretty simple.
This is missing the point
To specify some confusion, after selecting all, the next strike of 'v' performs the same function as 'right arrow' or 'end'  it overwrites the selected text with a copy of itself  and clears the 'selected' buffer, moving the cursor to the end of the selection (the end of the document if ctrla was used, which it was).
I'm going to try a bit harder to digest Token's reply. I'm glad this subject got the attention it deserved (it's very important!)
The 13 keystrokes required for "this is spam " don't really matter, since they must be typed in every keystroke.
This is true  the only time string length would ever make a difference would be if it were less than 4 keystrokes (typing 'a <space> a <space> ctrl+(acv)' is faster than 'a <space> ctrl+(acv acv)') but that only really matters for the initial steps, and the rules of what changes are pretty simple.
Hold down CTRL+V till the message has appeared 13 times, let go = 13*(CTRL+V) managed in one keystroke
This is missing the point
To specify some confusion, after selecting all, the next strike of 'v' performs the same function as 'right arrow' or 'end'  it overwrites the selected text with a copy of itself  and clears the 'selected' buffer, moving the cursor to the end of the selection (the end of the document if ctrla was used, which it was).
I'm going to try a bit harder to digest Token's reply. I'm glad this subject got the attention it deserved (it's very important!)
 Yakk
 Poster with most posts but no title.
 Posts: 11120
 Joined: Sat Jan 27, 2007 7:27 pm UTC
 Location: E pur si muove
Re: The mathematics of CTRLC CTRLV
Let's take 7427466391 copies.
By Token's proof, this takes 7427466391+K (for some small K) steps, as this is a 10 digit prime.
My plan? Generate 7427466390, then manually type in the last copy (or use shiftarrow to highlight, ctrlc, ctrlv^2).
7427466390=2*3*5*31*139*57457
which, as you can quite imagine, takes less work to do this number than the original using Token's method.
Odds are pulling off the same trick on 57457, or changing the target number by something other than 1, would do even better.
Of course, this changes the problem from "has a pretty solution" to "oh my god, what have we done" hard, I suspect.
By Token's proof, this takes 7427466391+K (for some small K) steps, as this is a 10 digit prime.
My plan? Generate 7427466390, then manually type in the last copy (or use shiftarrow to highlight, ctrlc, ctrlv^2).
7427466390=2*3*5*31*139*57457
which, as you can quite imagine, takes less work to do this number than the original using Token's method.
Odds are pulling off the same trick on 57457, or changing the target number by something other than 1, would do even better.
Of course, this changes the problem from "has a pretty solution" to "oh my god, what have we done" hard, I suspect.
One of the painful things about our time is that those who feel certainty are stupid, and those with any imagination and understanding are filled with doubt and indecision  BR
Last edited by JHVH on Fri Oct 23, 4004 BCE 6:17 pm, edited 6 times in total.
Last edited by JHVH on Fri Oct 23, 4004 BCE 6:17 pm, edited 6 times in total.
 squareroot1
 Posts: 172
 Joined: Fri Nov 06, 2009 8:27 pm UTC
Re: The mathematics of CTRLC CTRLV
Yakk wrote:Of course, this changes the problem from "has a pretty solution" to "oh my god, what have we done" hard, I suspect.
You suspect correctly. The ability to simply type in the next n copies changes the complexity from "Here's a nice solution  with proof!" to "Oh me yarm addition chain! It's NPcomplete!" as a few people have already stated.
OT: Is this thread dead yet, Jim?
Re: The mathematics of CTRLC CTRLV
People have said it's an addition chain problem, but I don't see how. Maybe I'm just too tired.
All posts are works in progress. If I posted something within the last hour, chances are I'm still editing it.
 squareroot1
 Posts: 172
 Joined: Fri Nov 06, 2009 8:27 pm UTC
Re: The mathematics of CTRLC CTRLV
Token wrote:People have said it's an addition chain problem, but I don't see how. Maybe I'm just too tired.
Let's see if I can explain this simply.
The difference is, some people consider it
1. Type string.
2. Press some combination of ctrl+a, ctrl+c, ctrl+v.
3. End.
while others consider it
1. Type string.
2. Press some combination of ctrl+a, ctrl+c, ctrl+v.
3. Type the string again?
4. Press some combination of ctrl+a, ctrl+c, ctrl+v?
5. Type the string again?
6. Press some combination of ctrl+a, ctrl+c, ctrl+v?
...
N. End
The latter is an addition chain problem and NPcomplete, mainly because of the question marks.
 phlip
 Restorer of Worlds
 Posts: 7569
 Joined: Sat Sep 23, 2006 3:56 am UTC
 Location: Australia
 Contact:
Re: The mathematics of CTRLC CTRLV
That's not quite an addition chain, though... an addition chain is "each new number can be the sum of some two previous numbers; minimise the length of the chain", whereas this new problem is more restrictive: "each new number is either the previous number plus or minus one (weight k), or the previous number times n for some natural n (weight an+b); minimise the total weight of the chain." Specifically, with a = 1, b = 2, k = the length of the initial string. That is, plus one means typing a kcharacter string... minus one means k backspaces (or possibly fewer ctrl+backspaces?)... multiplying it by n means acv^{n}.
For instance, if you go "acvvacvvacvv" to get 8, you can't then quickly add 2 to get 10, even though you did, at one point, have 2 (indeed, you had 2 in the clipboard at one point). Your options after "acvvacvvacvv" are identical to your options after "acvvvvacvv". As opposed to an addition chain, where you can do (1,2,4,8,10).
I wouldn't be surprised if it's still NPcomplete, though.
Note that the relative sizes of a, b and k in that definition are important, too... if I wanted 17 "1"s, then I could do "1111acvvvv1", but if I wanted 17 warandpeaces, I'd do "<war and peace here>acv^{17}".
[edit]
I did some bruteforcing, results in the spoiler.
[edit again]
Actually, if you remove the backspace option I threw in, I think this could be solved dynamically without too much trouble... if you have the solutions for 0 through n1, then you can probably find the solution for n reasonably quickly, 'cause you don't have that many options to check, just n1 and all of n's factors... Backspace complicates that a little, though.
For instance, if you go "acvvacvvacvv" to get 8, you can't then quickly add 2 to get 10, even though you did, at one point, have 2 (indeed, you had 2 in the clipboard at one point). Your options after "acvvacvvacvv" are identical to your options after "acvvvvacvv". As opposed to an addition chain, where you can do (1,2,4,8,10).
I wouldn't be surprised if it's still NPcomplete, though.
Note that the relative sizes of a, b and k in that definition are important, too... if I wanted 17 "1"s, then I could do "1111acvvvv1", but if I wanted 17 warandpeaces, I'd do "<war and peace here>acv^{17}".
[edit]
I did some bruteforcing, results in the spoiler.
Spoiler:
[edit again]
Actually, if you remove the backspace option I threw in, I think this could be solved dynamically without too much trouble... if you have the solutions for 0 through n1, then you can probably find the solution for n reasonably quickly, 'cause you don't have that many options to check, just n1 and all of n's factors... Backspace complicates that a little, though.
Code: Select all
enum ಠ_ಠ {°□°╰=1, °Д°╰, ಠ益ಠ╰};
void ┻━┻︵╰(ಠ_ಠ ⚠) {exit((int)⚠);}
Re: The mathematics of CTRLC CTRLV
Yeah backspace and typing both complicate it  but if it were simple it wouldn't be any fun, would it?
The rules on the space also cause problems. Does it have to end with a trailing space? Probably not, but if x is equal to the length of the string WITHOUT the space this means backspacing an instance costs (x+1) while typing in one on the end costs (x), and typing two on the end costs (2x+1).
Nobody has mentioned that we can also pick how much we want to highlight (remember no mouse). If I want to make exactly 19 copies of 'this is spam' (13 with trailing space), then I can do
13 + ctrl+ acv^7, a shift+(leftarrow * 13), ctrl+ c v^3
This doesn't save time over typing it out (since i have to hit leftarrow the same amount of times as the original string), but for larger numbers this might save time if we need to add on multiples of a specific number.
The rules on the space also cause problems. Does it have to end with a trailing space? Probably not, but if x is equal to the length of the string WITHOUT the space this means backspacing an instance costs (x+1) while typing in one on the end costs (x), and typing two on the end costs (2x+1).
Nobody has mentioned that we can also pick how much we want to highlight (remember no mouse). If I want to make exactly 19 copies of 'this is spam' (13 with trailing space), then I can do
13 + ctrl+ acv^7, a shift+(leftarrow * 13), ctrl+ c v^3
This doesn't save time over typing it out (since i have to hit leftarrow the same amount of times as the original string), but for larger numbers this might save time if we need to add on multiples of a specific number.
Re: The mathematics of CTRLC CTRLV
Regarding this, I've reached the conclusion after a bunch of coding, that errors are invariant under copypaste transformations.
 Yakk
 Poster with most posts but no title.
 Posts: 11120
 Joined: Sat Jan 27, 2007 7:27 pm UTC
 Location: E pur si muove
Re: The mathematics of CTRLC CTRLV
Oh ya  ctrlshiftarrow moves by words.
One of the painful things about our time is that those who feel certainty are stupid, and those with any imagination and understanding are filled with doubt and indecision  BR
Last edited by JHVH on Fri Oct 23, 4004 BCE 6:17 pm, edited 6 times in total.
Last edited by JHVH on Fri Oct 23, 4004 BCE 6:17 pm, edited 6 times in total.

 Posts: 1478
 Joined: Sun Nov 05, 2006 12:49 am UTC
Re: The mathematics of CTRLC CTRLV
Use the X copy buffer. Highlight, middleclick (x19).
Re: The mathematics of CTRLC CTRLV
joeframbach wrote:Use the X copy buffer. Highlight, middleclick (x19).
no middleclick. need more than 19
Re: The mathematics of CTRLC CTRLV
Qaanol wrote:Or write a script to do what you need automatically.
Computers are really good at repetitive tasks.
If you have a repetitive task, there is an easy way to get a computer to do it for you.
In PHP
<?while($i<20){echo "this is spam";$i++);?>
43 characters. It's good if you want to type something 1000 times, but scripting is not optimal here.
(unless some codeguru can shorten this up a lot)
Who is online
Users browsing this forum: No registered users and 12 guests