counting runs

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

counting runs

Jason Tangen
Hello,

I'm trying to solve a seemingly simple problem and I could use some  
help. A coin flip will come out "Heads" or "Tails" and will produce,  
for example, the following series for 20 flips:

T,T,H,T,T,H,H,H,T,T,H,T,H,H,H,T,H,T,H,T

I need to count up the number events for a particular run.  For example,

Heads x 3 = 2
Heads x 2 = 0
Heads x 1 = 4
Tails x 1 = 4
Tails x 2 = 3
Tails x 3 = 0

I need to account for runs up to 60 (rather than 3 above) for  
hundreds of flips (rather than 20 above).

I've been using a very clumsy multiple if-then solution to date, but  
this quickly becomes difficult with many runs.

Can someone point me in the right direction?

Cheers,
Jason
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: counting runs

Alex Tweedly
Jason Tangen wrote:

> Hello,
>
> I'm trying to solve a seemingly simple problem and I could use some  
> help. A coin flip will come out "Heads" or "Tails" and will produce,  
> for example, the following series for 20 flips:
>
> T,T,H,T,T,H,H,H,T,T,H,T,H,H,H,T,H,T,H,T
>
> I need to count up the number events for a particular run.  For example,
>
> Heads x 3 = 2
> Heads x 2 = 0
> Heads x 1 = 4
> Tails x 1 = 4
> Tails x 2 = 3
> Tails x 3 = 0
>
> I need to account for runs up to 60 (rather than 3 above) for  
> hundreds of flips (rather than 20 above).
>
> I've been using a very clumsy multiple if-then solution to date, but  
> this quickly becomes difficult with many runs.
>
> Can someone point me in the right direction?


something like

>     local myVar, MyData, MyArray, I, tRunLen, tRunType
>    
>     put fld "Field" into MyData
>     put 0 into tRunLen
>     put "" into tRunType
>    
>     repeat for each item I in myData
>         if I <> tRunType then
>             if tRunType <> "" then
>                 add 1 to MyArray[tRunType, tRunLen]
>             end if
>             put I into tRunType
>             put 1 into tRunLen
>         else
>             add 1 to tRunLen
>         end if
>     end repeat
>     if tRunLen > 0 then
>         add 1 to MyArray[tRunType, tRunLen]
>     end if
>    
>     put the keys of MyArray into temp
>     sort temp
>     put temp into msg


--
Alex Tweedly       http://www.tweedly.net



--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.361 / Virus Database: 267.12.6/151 - Release Date: 28/10/2005

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Date conversions in summer time

Monte Goulding
In reply to this post by Jason Tangen
Hi

Just wondering if anyone else has seen date conversions adding an extra hour
each time you convert?

Cheers

--

Monte Goulding                                      BCompSci
Sweat Technologies                      BAppSci (Hons)

InstallGadget - How to create an installer in 10 seconds
Download now from: http://www.sweattechnologies.com/InstallGadget 

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: counting runs

Nicolas Cueto
In reply to this post by Jason Tangen
Hi,

Below is my suggestion. It allows the
number of flips and coin sides to be
varied, and can tally events of un-
limited length.

Cheers,
Nicolas Cueto


on mouseUp
 
  -- PREP THE VARIABLES
  put 100 into tNumberOfFlips
  put "HT" into tCoin
  put the number of characters in tCoin into tRandSeed
  put empty into tThePreviousToss
  put empty into tTheRun
  put empty into tTheSeries
 
  -- START FLIPPING THE COIN
  repeat with i = 1 to tNumberOfFlips
    put char (random(tRandSeed)) of tCoin into tTheCurrentToss
    if tTheCurrentToss <> tThePreviousToss then
      -- THE RUN IS BROKEN
      put tTheRun & cr after tTheSeries
      put tTheCurrentToss into tTheRun
    else
      -- THE RUN CONTINUES
      put tTheCurrentToss after tTheRun
    end if
    put tTheCurrentToss into tThePreviousToss
  end repeat
  delete the last char of tTheSeries
  sort lines of tTheSeries
  delete line 1 of tTheSeries
 
  -- COUNT THE NUMBER OF EVENTS FOR EACH PARTICULAR RUN
  put empty into tThePreviousLine
  put 1 into tEventCount
  put empty into tFinalEventCounts
  repeat for each line tTheCurrentLine in tTheSeries
    if tTheCurrentLine <> tThePreviousLine then
      -- A NEW EVENT
      put "Event count for run-type " & tThePreviousLine & \
          ": " & tEventCount & cr after tFinalEventCounts
      put 1 into tEventCount
    else
      -- THE PREVIOUS EVENT CONTINUES
      add 1 to tEventCount
    end if
    put tTheCurrentLine into tThePreviousLine
  end repeat
  delete line 1 of tFinalEventCounts
  put tFinalEventCounts into field "fResult"

end mouseUp
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: counting runs

masmit
In reply to this post by Jason Tangen
This should also work:



on mouseUp
   repeat 10000
     put  any item of "H,T" after flipList -- just to generate a  
sample list
   end repeat

   put flipList into headsList -- make a copy to work on
   replace "T" with cr in headsList -- split runs of heads into lines
   filter headsList without empty -- get rid of empty lines
   repeat for each line L in headsList
     add 1 to resArray["Heads",length(L)]
   end repeat


   --do same for tails
   put flipList into tailsList -- make a copy to work on
   replace "H" with cr in tailsList
   filter tailsList without empty
   repeat for each line L in tailsList
     add 1 to resArray["Tails",length(L)]
   end repeat


   put the keys of resArray into kList
   sort lines of kList numeric by item 2 of each
   repeat for each line L in kList
     put L into desc
     replace comma with "x" in desc
     put desc && resArray[L] & cr after rList
   end repeat
   put rList
end mouseUp

if the Hs & Ts are separated by commas to start with, just 'replace  
comma with empty in flipList'.



Mark

On 1 Nov 2005, at 00:22, Jason Tangen wrote:

> Hello,
>
> I'm trying to solve a seemingly simple problem and I could use some  
> help. A coin flip will come out "Heads" or "Tails" and will  
> produce, for example, the following series for 20 flips:
>
> T,T,H,T,T,H,H,H,T,T,H,T,H,H,H,T,H,T,H,T
>
> I need to count up the number events for a particular run.  For  
> example,
>
> Heads x 3 = 2
> Heads x 2 = 0
> Heads x 1 = 4
> Tails x 1 = 4
> Tails x 2 = 3
> Tails x 3 = 0
>
> I need to account for runs up to 60 (rather than 3 above) for  
> hundreds of flips (rather than 20 above).
>
> I've been using a very clumsy multiple if-then solution to date,  
> but this quickly becomes difficult with many runs.
>
> Can someone point me in the right direction?
>
> Cheers,
> Jason
> _______________________________________________
> use-revolution mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: counting runs

Dick Kriesel
In reply to this post by Jason Tangen
On 10/31/05 4:22 PM, "Jason Tangen" <[hidden email]> wrote:

> Hello,
>
> I'm trying to solve a seemingly simple problem and I could use some
> help. A coin flip will come out "Heads" or "Tails" and will produce,
> for example, the following series for 20 flips:
>
> T,T,H,T,T,H,H,H,T,T,H,T,H,H,H,T,H,T,H,T
>
> I need to count up the number events for a particular run.  For example,
>
> Heads x 3 = 2
> Heads x 2 = 0
> Heads x 1 = 4
> Tails x 1 = 4
> Tails x 2 = 3
> Tails x 3 = 0
>
> I need to account for runs up to 60 (rather than 3 above) for
> hundreds of flips (rather than 20 above).
>
> I've been using a very clumsy multiple if-then solution to date, but
> this quickly becomes difficult with many runs.
>
> Can someone point me in the right direction?
>
> Cheers,
> Jason

Here's yet another solution.  At the core, it uses an array like Alex's
solution, but with slightly fewer instructions.  So all it really adds to
suggestions already posted is a technique for reporting results as the
original example suggests: runs of heads first sorted by descending run
length, followed by runs of tails sorted by ascending run length, with no
run lengths missing.

-- Dick



post script:

local sArray,sChar,sCount,sMax

on mouseUp
  ask "enter a comma-delimited sequence of H's and T's" \
      with "T,T,H,T,T,H,H,H,T,T,H,T,H,H,H,T,H,T,H,T"
  recordFlips it
  putResults
end mouseUp

on recordFlips pSequence
  put "" into sArray
  put char 1 of pSequence into sChar
  put 0 into sCount
  put 0 into sMax
  repeat for each item tChar in pSequence
    recordFlip tChar
  end repeat
  add 1 to sArray[sChar,sCount]
end recordFlips

on recordFlip pChar
  if pChar = sChar then
    add 1 to sCount
    if sCount > sMax then
      put sCount into sMax
    end if
  else
    add 1 to sArray[sChar,sCount]
    put pChar into sChar
    put 1 into sCount
  end if
end recordFlip

on putResults
  -- note: fill in any missing runs
  put the keys of sArray into tKeys
  repeat with i = 1 to sMax
    if sArray["H",i] is empty then put 0 into sArray["H",i]
    if sArray["T",i] is empty then put 0 into sArray["T",i]
  end repeat
  -- note: sort runs of heads descending, then runs of tails ascending
  put the keys of sArray into tKeys
  sort tKeys numeric descending by sortKey(each)
  -- note: put the results
  put ""
  repeat for each line tKey in tKeys
    put item 1 of tKey && "x" && item 2 of tKey & ":" && sArray[tKey] & cr
after msg
  end repeat
end putResults

function sortKey pKey
  if item 1 of pKey is "H" then put item 2 of pKey into tSortKey
  else put 0 - item 2 of pKey into tSortKey
  return tSortKey
end sortKey


_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

AW: counting runs

Thomas Fischer-4
In reply to this post by Jason Tangen
Hi Jason,

if you just want to count the occurrences of H and T in strings like
> T,T,H,T,T,H,H,H,T,T,H,T,H,H,H,T,H,T,H,T
the easiest (and most likely fastest, unchecked though) way might be to do something like

  put  "T,T,H,T,T,H,H,H,T,T,H,T,H,H,H,T,H,T,H,T" & comma into myString
  put the number of items in myString into totalCount
  replace "T," with "" in myString
  put the number of items in myString into headCount
  put totalCount - headCount into tailCount
  answer "total: " & totalCount & return & \
      "Heads: " & headCount & return &  \
      "Tails: " & tailCount
 
All the best
Thomas


--
Thomas Fischer
Salzburg

> -----Ursprungliche Nachricht-----
> Von: [hidden email]
> [mailto:[hidden email]]Im Auftrag von Jason
> Tangen
> Gesendet: Dienstag, 1. November 2005 01:22
> An: [hidden email]
> Betreff: counting runs
>
>
> Hello,
>
> I'm trying to solve a seemingly simple problem and I could use some  
> help. A coin flip will come out "Heads" or "Tails" and will produce,  
> for example, the following series for 20 flips:
>
> T,T,H,T,T,H,H,H,T,T,H,T,H,H,H,T,H,T,H,T
>
> I need to count up the number events for a particular run.  For example,
>
> Heads x 3 = 2
> Heads x 2 = 0
> Heads x 1 = 4
> Tails x 1 = 4
> Tails x 2 = 3
> Tails x 3 = 0
>
> I need to account for runs up to 60 (rather than 3 above) for  
> hundreds of flips (rather than 20 above).
>
> I've been using a very clumsy multiple if-then solution to date, but  
> this quickly becomes difficult with many runs.
>
> Can someone point me in the right direction?
>
> Cheers,
> Jason
> _______________________________________________
> use-revolution mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: Date conversions in summer time

Sarah Reichelt-2
In reply to this post by Monte Goulding
> Just wondering if anyone else has seen date conversions adding an extra hour
> each time you convert?
>

What version of Revolution are you using Monte? I thought this one had
been fixed in 2.6?
If you need a convert that works with earlier versions, I have a
function that checks & allows for this bug if necessary. Just let me
know if you need it.

Cheers,
Sarah
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: counting runs

Jim Ault
In reply to this post by Jason Tangen
On 10/31/05 4:22 PM, "Jason Tangen" <[hidden email]> wrote:

> Hello,
>
> I'm trying to solve a seemingly simple problem and I could use some
> help. A coin flip will come out "Heads" or "Tails" and will produce,
> for example, the following series for 20 flips:
>
> T,T,H,T,T,H,H,H,T,T,H,T,H,H,H,T,H,T,H,T
>
> I need to count up the number events for a particular run.

<long reply>
This example is a rather involved routine, but it shows several things that
will help you analyze the flipping results. (Sorry about the pun, but could
not resist).  
<slappinghand force = ³strong²>6 times</slappinghand>

This solution does not use Arrays.  It is 142 lines (not going for shortest
solution here)
It very quickly generates a report of statistics, and 6 graphic
representations
It could be worth your time to play with it, then again you might like the
arrays better.
This code includes a breakpoint at the end so that it will automatically
stop and you can study the variables that it builds.

Hope this is helpful to you and others.

Jim Ault
Las Vegas

----------- start copying here ------------------
on headsUpReporting  --10.31.05
  --prepares (1) final table of statistics
  --        + (6) graphic representations of the results
  --
  --PAUSE at the last breakpoint to see all the variables
  --  then decide how you want to present the results
  --
  --the commas are redundant for most of the work,
  --     but, conveniently, we will use them later for graphics
  --
  --since working with arrays may be confusing to you and others
  -- I offer this solution which DOES NOT use arrays, but rather
  --            repeat loops, words, and lines
  --  (sorry about the rogue format of the variables.. old, old habit)

 
  --variation of Mark Smith's earlier reply
  repeat 10000
    --take heart, couple of seconds and it is all done, Rev is fast
    put any item of "H,T" after originalStrr -- just to generate a sample
list
    put comma after originalStrr   --we want the commas here
  end repeat
  if last char of originalStrr is comma then delete last char of
originalStrr
  --
  -- this is a cross-tab technique vs an array accumulator
  --
  put originalStrr into headsOnly
  put originalStrr into tailsOnly
  replace comma with empty in headsOnly
  replace comma with empty in tailsOnly
  put the number of characters in (headsOnly) into flipsTotal --a simple
tally
 
  replace "T" with space in headsOnly --strip t's (hey.. I'm in Vegas)
  replace "H" with space in tailsOnly
 
  put the number of words in headsOnly into maxx
  repeat with x = 1 to maxx
    get number of chars in word x of headsOnly
    add 1 to item 2 of line (it) of finalTable
    put 0 into item 3 of line (it) of finalTable
    put (it) into item 1 of line (it) of finalTable --1st col of table
  end repeat
  put maxx into numRunsHeads --a simple tally
 
  put the number of words in tailsOnly into maxx
  repeat with x = 1 to maxx
    get number of chars in word x of tailsOnly
    add 1 to item 3 of line (it) of finalTable
    put (it) into item 1 of line (it) of finalTable
  end repeat
  put maxx into numRunsTails --a simple talley
 
  get headsOnly
  replace space with empty in it
  put the number of chars in (it) into numHeads --a simple tally
  get tailsOnly
  replace space with empty in it
  put the number of chars in (it) into numTails --a simple tally
 
  put 0 into maxHRun
  put 0 into maxTRun
  put the number of lines in finalTable into maxx
  --fill in the table so it is easier to read
  repeat with x = 1 to maxx
    if item 1 of line x of finalTable < 1 then put x into item 1 of line x
of finalTable
    if item 2 of line x of finalTable < 1 then put 0 into item 2 of line x
of finalTable
    if item 3 of line x of finalTable < 1 then put 0 into item 3 of line x
of finalTable
  end repeat
 
  --get the longest run of heads & tails for the stats
  repeat with x = maxx down to 1
    if maxHRun < 1 then
      if item 2 of line x of finalTable > 0 then
        put item 1 of line x of finalTable into maxHRun
      end if
    end if
    if maxTRun < 1 then
      if item 3 of line x of finalTable > 0 then
        put item 1 of line x of finalTable into maxTRun
      end if
    end if
    --next test to see if both the max lengths have been found
    if maxHRun > 0 and maxTRun > 0 then exit repeat
  end repeat
 
  --build the report
  put "Report of " & flipsTotal & " Coin Flips" into finalReport
  put "  on " & the short date & "  at  " & the short time after finalReport
  put return & "Total Heads = " & numHeads & "  Num Runs = " & numRunsHeads
after finalReport
  put return & "Total Tails = " & numTails & "  Num Runs = " & numRunsTails
after finalReport
  put return & "Max length Heads = " & maxHRun & "  Avg Run = " &
numHeads/numRunsHeads after finalReport
  put return & "Max length Tails = " & maxTRun & "  Avg Run = " &
numTails/numRunsTails after finalReport
  put return & return & "Len, Heads, Tails Runs" & return & finalTable after
finalReport
  replace comma with space&space in finalReport
  --visual ONE
  put headsOnly into graphHeadsInSequence
  put tailsOnly into graphTailsInSequence
  replace space with return in graphHeadsInSequence
  replace space with return in graphTailsInSequence
  put graphHeadsInSequence into graphHeadsByLength
  sort graphHeadsByLength descending
  put graphTailsInSequence into graphTailsByLength
  sort graphTailsByLength descending
 
 
  --visual TWO
  put originalStrr into graphBothInSequence
  replace "H,T" with ("H" & return & "T") in graphBothInSequence
  replace "T,H" with ("T" & return & "H") in graphBothInSequence
  replace comma with empty in graphBothInSequence
 
  --visual THREE
  put graphBothInSequence into graphAsTwoGroups
  sort lines graphAsTwoGroups descending
  get ""
  --------------- output ---------------
  --make them easy to find in variable watcher
  put finalReport into a_finalReport
  put graphHeadsInSequence into a_graphHeadsInSequence
  put graphTailsInSequence into a_graphTailsInSequence
  put graphHeadsByLength into a_graphHeadsByLength
  put graphTailsByLength into a_graphTailsByLength
  put graphBothInSequence into a_graphBothInSequence
  put graphAsTwoGroups into a_graphAsTwoGroupsByLength
  --
  --now view the following in variable watcher
  --  a_finalReport
  --
  --visual ONE  scroll to view
  --  a_graphHeadsInSequence, a_graphHeadsByLength
  --  a_graphTailsInSequence, a_graphTailsByLength
  --
  --visual TWO  scroll to view
  --  a_graphBothInSequence
  --
  --visual THREE  scroll to view
  --  a_graphAsTwoGroupsByLength
  ------------------------------------------
  breakpoint  -- PAUSE HERE and read the section above
 
end headsUpReporting
----------- stop copying here ------------------



On 10/31/05 4:22 PM, "Jason Tangen" <[hidden email]> wrote:

> Hello,
>
> I'm trying to solve a seemingly simple problem and I could use some
> help. A coin flip will come out "Heads" or "Tails" and will produce,
> for example, the following series for 20 flips:
>
> T,T,H,T,T,H,H,H,T,T,H,T,H,H,H,T,H,T,H,T
>
> I need to count up the number events for a particular run.  For example,
>
> Heads x 3 = 2
> Heads x 2 = 0
> Heads x 1 = 4
> Tails x 1 = 4
> Tails x 2 = 3
> Tails x 3 = 0
>
> I need to account for runs up to 60 (rather than 3 above) for
> hundreds of flips (rather than 20 above).
>
> I've been using a very clumsy multiple if-then solution to date, but
> this quickly becomes difficult with many runs.
>
> Can someone point me in the right direction?
>
> Cheers,
> Jason
> _______________________________________________
> use-revolution mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: counting runs

Quentin Long
In reply to this post by Jason Tangen
sez [hidden email]:

>I'm trying to solve a seemingly simple problem and I could use some  
>help. A coin flip will come out "Heads" or "Tails" and will produce,  
>for example, the following series for 20 flips:
>
>T,T,H,T,T,H,H,H,T,T,H,T,H,H,H,T,H,T,H,T
>
>I need to count up the number events for a particular run.  For example,
>
>Heads x 3 = 2
>Heads x 2 = 0
>Heads x 1 = 4
>Tails x 1 = 4
>Tails x 2 = 3
>Tails x 3 = 0
>
>I need to account for runs up to 60 (rather than 3 above) for  
>hundreds of flips (rather than 20 above).
   Presuming the data is indeed a string of Ts and Hs, separated by commas,
something like this might do what you want...

local LongestRun = 60 # this value can be dialed up or down as desired

function FindRuns TheFlips
  # TheFlips must be a comma-delimited series of Ts and Hs!
  # if TheFlips is anything else, God knows what this handler will do to it

  put TheFlips into DerTempT
  put TheFlips into DetTempH

  put "T" into RunsT
  put "H" into RunsH
  repeat
    put RunsT into item (1 + the number of items in RunsT) of RunsT
    put RunsH into item (1 + the number of items in RunsH) of RunsH
    if (the number of items in RunsT => LongestRun) then exit repeat
  end repeat
  put ("," & (item 1 to LongestRun of RunsT) & ",") into RunsT
  put ("," & (item 1 to LongestRun of RunsH) & ",") into RunsH

  put true into TsLeft
  put true into HsLeft

  put "Record of Ts" into RezultT
  put "Record of Hs" into RezultH

  repeat with K1 = LongestRun down to 1 # or however many
    # first, let's see if we need to worry about any further runs
    put (offset ("T",DerTempT) > 0) into TsLeft
    put (offset ("H",DerTempH) > 0) into HsLeft

    if TsLeft then
      # we still have some Ts
      if offset (RunsT,DerTempT) > 0 then
        # hey, we got at least one run of this particular length!
        put the length of DerTempT into DerLength
        replace RunsT with "," in DerTempT
        # RunsT is a string of length (2n+1), where n is the number of Ts in
it.
        # if we replace all instances of RunsT with single commas, that
shortens
        # DerTempT by (2n) characters per instance that got replaced.
therefore...
        put (DerLength - the length of DerTempT) div (2 * K1) into NumOfRuns
      else # nope, no more Ts left, hence no runs of however-many Ts
        put 0 into NumOfRuns
      end if
      put ("Heads x" & K1 && "=" && NumOfRuns) & return before RezultT
    end if

    # now do to the Hs what we did to the Ts
    if HsLeft then
      if offset (RunsH,DerTempH) > 0 then
        put the length of DerTempH into DerLength
        replace RunsH with "," in DerTempH
        put (DerLength - the length of DerTempH) div (2 * K1) into NumOfRuns
      else
        put 0 into NumOfRuns
      end if
      put ("Tails x" & K1 && "=" && NumOfRuns) & return before RezultH
    end if

    # now adjust RunsT and RunsH for the next time around the repeat loop
    delete char 1 to 2 of RunsT
    delete char 1 to 2 of RunsH
  end repeat

  # clean up RezultT and RezultH -- nuke the crap in the final line of each
  delete line -1 of RezultT
  delete line -1 of RezultH

  return RezultT & return & "=======" & return & RezultH
end FindRuns

   Hope this helps...
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution