# Riddle - Make "the sentence" appear 100 times

You’re starting with a blank document, a standard computer text editor. You need to make “the sentence” appear 100 times, each sentence on a separate line. A sentence does not have to be re-copied in order to be pasted more than once, as per standard copy/paste procedure.

What is the fastest way to get the sentence to appear exactly 100 times?

You have only 4 main actions available to you:

Write the sentence (and if need be, move to the next line): 3 seconds

Select one line: 1 second

Copy selected lines: 2 seconds

Paste the copied lines: 2 seconds

So is pressing return to go onto the next line included in the “Paste the copied lines” action, or do we need to do that after each pasting?

You can move to and from any line you like - no time penalty.

Writing the sentence 100 times is 300 seconds, so that gives us an upper bound.

Try this: Get 4 copies of the sentence by writing it once, copying it, and pasting it three times (10 seconds). Then select and copy those (6 seconds) and paste them 24 times (48 seconds). That gives you a grand total of 64 seconds.

I don’t think you can do any better because of the high cost of copying mulitple lines.

I think I can improve on ultrafilter’s method.

Get 5 copies of the sentence by writing it once, copying it, and pasting it 4 times (12 seconds). Then select and copy those (7 seconds) and paste them 19 times (38 seconds). That gives you a grand total of 57 seconds.

The next factor of 100 is even better:

Get 10 copies of the sentence by writing it once, copying it, and pasting it 9 times (22 seconds). Then select and copy those (12 seconds) and paste them 9 times (18 seconds). That gives you a grand total of 52 seconds.

I think 52 seconds is the one to beat.

Assuming I understand the rules correctly, the best I can do is 56 seconds:

Type the line 4 times: 12 seconds
Select 4 lines: 4 seconds (16)
Copy: 2 seconds (18)
Paste 4 times: 8 seconds (26) (Should be 20 lines now)
Select 20: 20 seconds (46)
Copy: 2 seconds (48)
Paste 4 times: 8 seconds (56) (Should have 100 lines now)

Using VI, about 3 seconds total:

100ithe sentence<return><esc>

On preview, Giles’ answer beats mine, although his should be 54 total:

write once: 3
select: 1 (4)
copy: 2 (6)
paste 9: 18 (24)
select 10: 10 (34)
copy: 2 (36)
paste 9: 18 (54)

I use AutoCAD, or Microstation and write the sentence one. Then use the array command to make 99 copies. Following that, I window it, and Ctrl-C it to the clipboard. Open notepad and Ctrl-V.

Or, open Excel and write the sentence once in A1 Select A1 and drag the fill handle to A100. Copy and paste into text editor.

Not more than about 10 seconds, including initializing all the required apps.

I make it 54 seconds:

Write the sentence (3s)
Select it (1s)
Copy it (2s)
Paste it 9 times (18s)
Select the 10 lines (10s)
Copy them (2s)
Paste them 9 times (18s)

i.e. the “get 10 copies” phase takes 24 seconds, not 22.

By my reckoning, the time needed to write out the sentence n times and paste it 100/n - 1 times is t(n) = 3n + 2 + 200/n seconds when n is a proper divisor of 100. Here’s the breakdown:

``````
n          t(n)
1          205
2          108
4          64
5          57
10        52
20        72
25        85
50        156

``````

When n is not a proper divisor of 100, the equation becomes more complicated. Since there’s no cost given for deleting a copy of the sentence, there’s not enough information to give a complete answer. I guess you could assume that selecting lines and cutting them is the same cost as selecting and copying them, but I don’t have time to do that analysis right now.

1 Type 1 line (3)
1 Select 1 line (1)
2 Paste 1 line(2)
3 Paste 1 line(2)
4 Paste 1 line(2)
4 Select 4 lines (4)
8 Paste 4 lines(2)
12 Paste 4 lines(2)
16 Paste 4 lines(2)
20 Paste 4 lines(2)
20 Select 20 lines (20)
40 Paste 20 lines(2)
60 Paste 20 lines(2)
80 Paste 20 lines(2)
100 Paste 20 lines(2)

100 lines in 50 secs (I think)

You missed out three Copy phases (2 seconds each).

Bugger… I was feeling all smug too. :smack:

On a “standard computer text editor” instead of selecting multiple lines, you can use Ctrl-A (or it’s equivalent) to select the whole document.

Write “a sentence” (with carraige return)
Hold down the Ctrl key.
Type A, C, V, V
repeat until done.

Lightning quick, though I haven’t worked out the numbers.

48 seconds:

Write sentence - 1 sentence, 3 seconds.
Write sentence - 2 sentences, 6 seconds.
Select sentences - 2 sentences, 8 seconds.
Copy sentences - 2 sentences, 10 seconds.
Paste sentences 4 times - 42 + 2 = 10 sentences, 4 * 2 + 10 = 18 seconds.
Select sentences - 10 sentences, 18 + 10 = 28 seconds.
Copy sentences - 10 sentences, 30 seconds.
Past sentence 9 times: 100 sentences, 30 + 9
2 = 48 seconds.

I view selecting document via Ctrl-A as equivalent to select the sentence. If anything, it’s easer.
Each copy cycle is 7 seconds (1 for select, 2 for copy, 2 for paste, 2 for paste)
write sentence 4 times (3 sec*4=12 sec)
copy cycle (7 sec), now 8 sentences
copy cycle (7 sec), now 16 sentences
copy cycle (7 sec), now 32 sentences
paste (still have 16 sentences in buffer) 5 more times (10 seconds), now 112 sentences

Total time: 43 seconds. Further refinements of this technique could probably shave another couple.

Come to think of it, there’s an easier way yet. Just **hold down ** Ctrl-V. Once the auto-repeat catches, you’ll have 100 sentences before you know what happened!

The rules as set out in the OP don’t allow ctrl-A, or holding down ctrl-V for autorepeat, or using any different kind of word processor, so solutions that rely on something like that aren’t relevant.

Are we doing this excercise on imaginary computers using imaginary constraints?

I just did this in Word in about 12 seconds.
Typed the sentence,
Selected the sentence and hit Ctrl-C
Ctrl-V’d the sentence four times.
Ctrl-A and Ctrl-C
Ctrl-V 20 times
Of course, had I been in ISPF, (which I consider a standard computer text editor–although it is the best), I’d have typed the sentence, typed c on the first line, then typed b99 on the next line and I’d have been done a lot faster.

I suspect the answer is yes. The OP used “Riddle” in the subject and laid down a set of rules. The scenario is just flavoring to help you understand the riddle, not a free license to break the ground rules IMHO. Otherwise, non-imaginary airplane on treadmills would be wildly impractical, too.

The OP is poorly formed. It makes reference to both “standard computer text editor” and “standard copy/paste”, both of which imply a real-world connection. Then it posits specific rules with unrealistic time durations,non of which are true for a standard computer text editor, so that impies a pure mathematical exercise. UncleBeer and TomnDeb both have some confusion also. So seeing as the guest hasn’t come along to distinguish, I think my solution is reasonable, or at least worth mentioning.

But I did miss the key word “exactly” 100 times.

I didn’t even see the word standard in there. This sort of thing is a pretty standard problem, and I just grabbed on to that.