All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > General > Word Problems
Test #7 (Posted on 2014-12-03) Difficulty: 4 of 5
<BEGIN> What a piece of work is a man,
How noble in reason,
How infinite in faculties, in form and moving
How express and admirable in action
How like an angel in apprehension
How like a god!
The beauty of the world, the paragon of animals—and yet to me,
What is this quintessence of dust?
Man delights not me — nor woman neither,
Though by your smiling you seem to say so.

How many sequential appearances of the letters t-e-s-t are there on this page between <BEGIN> and the 2nd appearance of <END>?

Watch out - all counts.
<END>
To avoid ambiguity- scan sequentially from left to right and in the sentence "THIS TEST GETS TROUBLE" you should reach a count of 9: 4 starting with the 1st letter of the sample sentence, similar 4 starting with the fifth plus another one beginning with the eighth letter (the last letter in the word "TEST").

See The Solution Submitted by Ady TZIDON    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution | Comment 5 of 7 |
Here's the text to be examined, in lower case and in 80-character chunks:

 what a piece of work is a man, how noble in reason, how infinite in faculties, 
in form and moving how express and admirable in action how like an angel in appr
ehensionhow like a god! the beauty of the world, the paragon of animals--and yet 
to me,what is this quintessence of dust?man delights not me -- nor woman neither,
though by your smiling you seem to say so.how many sequential appearances of the
 letters t-e-s-t are there on this page between <begin> and the 2nd appearance o
f <end>?watch out - all counts.

The following table shows each location where an "s" appears, together with the count of how many "t"'s follow it in the text:
 

24 31
49 31
78 29
109 29
110 29
165 28
231 24
253 21
258 20
266 19
267 19
278 19
292 17
336 14
348 14
356 13
360 13
372 13
393 12
408 9
414 8
434 5
510 0

The following tabulates, for each "e", its location and the number of "st" sets that follow it. For example, each of positions 420, 424 and 426 contain an "e" and precede the last 5 "st"'s that begin with the "s" at 434. The "e" at 412 can use all the "st"s from the "s" at 414 as well as the "s" at 433, making 13 in all, etc.


11 417
13 417
41 386
47 386
65 355
77 355
104 326
108 326
124 268
143 268
151 268
161 268
163 268
176 240
187 240
190 240
201 240
212 240
238 216
245 216
265 175
268 137
271 137
286 118
299 101
314 101
318 101
349 73
350 73
373 34
376 34
386 34
392 34
400 22
403 22
406 22
412 13
420 5
424 5
426 5
439 0
442 0
445 0
446 0
451 0
463 0
472 0
478 0
484 0

The following table works similarly to the previous one, this time, for each "t" finding the total count of the "est"'s from there onward:

5 7186
64 5580
75 5225
131 3950
185 2638
193 2158
199 2158
210 1918
239 1462
241 1462
250 1246
255 1246
264 1246
279 797
291 679
296 679
316 477
321 376
353 230
378 162
398 94
404 50
405 50
410 28
416 15
422 10
431 0
443 0
461 0
491 0
497 0
509 0

The grand total for all the beginning "t"'s is:

41122
 
DefDbl A-Z
Dim crlf$, s As String, w As String
Dim stCt(30, 1), estCt(50, 1), testCt(40, 1)

Private Sub Form_Load()
 ChDir "C:Program Files (x86)DevStudioVBprojects looble"
 Text1.Text = ""
 crlf$ = Chr(13) + Chr(10)
 Form1.Visible = True
 DoEvents
 
 s = ""
 Open "test no 7.txt" For Input As #1
 Do
   Line Input #1, l$
   s = s + LCase$(l$)
 Loop Until EOF(1)
 Text1.Text = Text1.Text & s & crlf
 DoEvents
 
 Do
   ix = InStr(ix + 1, s, "s")
   If ix > 0 Then
     stPtr = stPtr + 1
     stCt(stPtr, 0) = ix
     ix2 = ix
     Do
      ix2 = InStr(ix2 + 1, s, "t")
      If ix2 > 0 Then stCt(stPtr, 1) = stCt(stPtr, 1) + 1
     Loop Until ix2 = 0
     Text1.Text = Text1.Text & ix & Str(stCt(stPtr, 1)) & crlf
   End If
 Loop Until ix = 0
 Text1.Text = Text1.Text & crlf
 
 ix = 0
 Do
   ix = InStr(ix + 1, s, "e")
   If ix > 0 Then
     estPtr = estPtr + 1
     estCt(estPtr, 0) = ix
     For i = 1 To 30
       If stCt(i, 0) > ix Then
         estCt(estPtr, 1) = estCt(estPtr, 1) + stCt(i, 1)
       End If
       If stCt(i, 1) = 0 Then Exit For
     Next
     Text1.Text = Text1.Text & ix & Str(estCt(estPtr, 1)) & crlf
   End If
 Loop Until ix = 0
 Text1.Text = Text1.Text & crlf
 
 ix = 0
 Do
   ix = InStr(ix + 1, s, "t")
   If ix > 0 Then
     testPtr = testPtr + 1
     testCt(testPtr, 0) = ix
     For i = 1 To 50
       If estCt(i, 0) > ix Then
         testCt(testPtr, 1) = testCt(testPtr, 1) + estCt(i, 1)
       End If
       If estCt(i, 1) = 0 Then Exit For
     Next
     Text1.Text = Text1.Text & ix & Str(testCt(testPtr, 1)) & crlf
     overAllCt = overAllCt + testCt(testPtr, 1)
   End If
 Loop Until ix = 0
   
 Text1.Text = Text1.Text & crlf & overAllCt & crlf & " done"
End Sub

 

Edited on December 3, 2014, 2:03 pm
  Posted by Charlie on 2014-12-03 14:01:05

Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (8)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information