Re: Calculate Last Digits




"Robert Morley" <rmorley@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:O0$wPu4EIHA.280@xxxxxxxxxxxxxxxxxxxxxxx
See possible code improvement, in-line:

For j = 0 To 9
If Cnt(j) > Cnt(max) Then
max = j
End If

This might work faster by adding the following line at this point:

If Cnt(j) >= 3 Then Exit For

(Or use whatever method you prefer to exit the For Loop...personally I avoid
Exit For, as discussed at enormous length in older threads <g>, but this is
the easiest change given the existing code.)

I couldn't get much difference with that, I think it is a wash between extra
testing and sometimes early exiting. It does seem like the excess looping should
be cut out, but I'm not sure it gets any faster if you do a real sort, or
whatever.

- - - - -

I did get a big (3X) boost by switching from strings to longs for the pattern
"map" (edited lines only):

Private Map(10) As Long
.....
Map(1) = 111111
Map(2) = 211110
' etc.
.....
Dim pattern As Long
.....
pattern = pattern * 10 + Cnt(max)
.....

The 211110 etc. patterns work just as well as longs, and the comparisons and
manipulations are much faster.


.



Relevant Pages

  • Re: perl file parsing
    ... AGGACATGCGGCCCGGCGACCTCATCATCTACTTCGACGACGCCAGCCACGTCGGGATG ... the number of times the pattern has occured. ... chomp; #remove newline characters ...
    (perl.beginners)
  • what are the USERID,PASSWD in /etc/passwd
    ... echo "Usage: `basename $0` USERNAME" ... exit $E_WRONGARGS ... file_excerpt $pattern ...
    (comp.unix.shell)
  • Re: regexp (vim6)
    ... pattern would match Function, unless preceeded by Exit or End - which is ... Exit or End, followed by Function. ... Prev by Date: ...
    (comp.editors)
  • Re: perl file parsing
    ... my $fastaFile = 'myfile'; ... my $pattern = 'CTTGGCGAGAAGGGCCGCTACCTGCTGGCCGCCTCCTTCGGCAACGT'; ... chomp; #remove newline characters ...
    (perl.beginners)