3

I was given this question by a friend and tooled around with it a bit in excel. I'm sure I could brute force it, but I wanted to see if people smarter than me could help me optimize this and find a mathematical way to solve it.

The problem is this: You have a character in a text box. You want to make as many characters as possible using only 100 keystrokes. The possible keystrokes are Ctrl+A (select all), Ctrl+C (Copy), and Ctrl+V (Paste). The text starts unselected with nothing on the clipboard. Of course, there is the 2^x growth characterized by

  1. Ctrl A 2. Ctrl C 3. Ctrl V... and repeat to get 2^x growth

But even in my experimentation if you paste a few more times before selecting and copying, you can easily outpace 2^x growth.

So my question is, how can I represent this mathematically so I can optimize it and find the best combination of select/copy/paste?

1 Answers1

0

You start with one character. After 3 keystrokes (CTRL A, C, V); you get 2 of them.
Now, to get 4, you can either use the previous 3, or just use CTRL V 2 more times. The latter is more effective. Then, to get 8, using CTRL A, C, V is more effective than using CTRL V 4 times(or any number of times greater or lesser than 4 for that matter). This way, you can now visualise the pattern:
CTRL A
CTRL C
CTRL V
CTRL V
CTRL V
CTRL A
CTRL C
CTRL V
CTRL V
CTRL V
.
.
.
Using this, you can find out the number of characters at the end of 100 keystrokes. There won't be any remainder since 5(The number of strokes per cycle) divides 100.