# Copy Paste Select-All Problem

In the Copy Paste Select-All problem, a user wants to replicate the most amount of ‘a’s with the least amount of keystrokes. I was asked how many keystrokes would be necessary to produce 50,000 ‘a’s.

There are 3 basic ways to create ‘a’s: Pressing ‘a’, Selecting-All -> Copying -> Pasting, and Pasting what is in the clip board. Pressing ‘a’ will cost 1 keystroke while selecting-all, copying, pasting will cost 2 each. So just pasting will cost 2 keystrokes, but selecting-all -> copying -> pasting will cost 6.

Now let’s create the recursive definition of our dynamic programming problem. $$L(x) = { \mbox{max}[ L(x-6)*2,L(x-2)+buffer,L(x-1)+1 ] }$$