Results 1 to 40 of 186

Thread: VB6: Best way to find all permutations of a given string in a file - Contest

Threaded View

  1. #11
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: VB6: Best way to find all permutations of a given string in a file - Contest

    Oops, I noticed I had my computer in power saving mode, which meant I was running at 800 MHz... changes things a little, it wasn't hard disk cache after all, just the processor jumping up to 1800 MHz when running the code quickly enough.

    randem: I can figure out the actual permutation, but the way I store the data while processing is unoptimal for converting the information in to what is currenly required in the output file. In the other hand, if we know the positions and we have the file, we don't really need that information: it is useful for your validation, but it doesn't help us at this point.

    So it is entirely unrequired to output that data: only positions matter. This is why I'd suggest a simple file where only the start position of each permutation is outputted, separated by CRLF. No special formatting and I'd suggest the order also to be free if file outputting is included within timing (it'd be unfair to include sorting).


    I have a new question as well: should we output the text file while looking for permutations or should we output it once timing is finished? At the moment I have included the file output in my time. Which is... equal to amount of solving about 25000 very easy sudokus using my sudoku solver. Anyone interested can have merry time finding out how fast it is.

    I can tell my time under IDE as it is pretty poor: roughly 1300 ms.


    Oh, and GetTickCount would be all too unaccurate for my code...
    Code:
    'clsTime.cls
    Option Explicit
    
    Private m_Freq As Double
    Private m_Start As Currency
    Private m_Stop As Currency
    
    Private Declare Function QueryPerformanceFrequency Lib "kernel32" (lpFrequency As Currency) As Long
    Private Declare Function QueryPerformanceCounter Lib "kernel32" (lpPerformanceCount As Currency) As Long
    
    Public Function GetRemainingSeconds(ByVal CurrentValue As Long, ByVal EndVal As Long) As Currency
        Dim dblCurrent As Double
        If CurrentValue < 1 Then CurrentValue = 1
        If EndVal > CurrentValue Then
            QueryPerformanceCounter m_Stop
            dblCurrent = (CDbl(m_Stop - m_Start) / m_Freq)
            GetRemainingSeconds = CCur((dblCurrent / CurrentValue * EndVal) - dblCurrent)
        End If
    End Function
    Public Function GetTime() As Double
        QueryPerformanceCounter m_Stop
        GetTime = CDbl(m_Stop - m_Start) / m_Freq
    End Function
    Public Sub Start()
        QueryPerformanceCounter m_Start
    End Sub
    Private Sub Class_Initialize()
        Dim curFreq As Currency
        QueryPerformanceFrequency curFreq
        m_Freq = CDbl(curFreq)
    End Sub
    Code:
    Dim Q As clsTime
    
    ' initialize class
    Set Q = New clsTime
    
    ' start timing
    Q.Start
    
    ' return time in milliseconds
    MsgBox Fix(Q.GetTime * 1000)
    
    ' once done...
    Set Q = Nothing
    Last edited by Merri; Jun 2nd, 2007 at 05:45 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width