English
Forum

Question of the Week!

 
- Page 1 -



Frank
Abbing
Perhaps is so one Thread time nice. Someone asks a programming task and the rest trying to find a short and good solution...
The best solution would be put to the code snippets.

My task for today is:

Find a short and fast Solution to determine, if a directory is empty or not!
 
08/25/08  
 



 
- Page 2 -



Frank
Abbing
Hehe, Dieter has also my API-method posted. Quick and short. The shlwapi is an explosion of useful and unexpected features!
Now you can someone else post a task.
 
08/26/08  
 



Your yes?

Sort performant as possible 200 real random numbers with 8 digit accuracy after rnd()*1000 (XProfan 11) course, So how would a person do.
 
08/26/08  
 




Jörg
Sellmeyer

CompileMarkSeparation
Randomize
Declare s$
Window 0,0 - 400,%maxy
Var h& = Create("ListBox",%hwnd,1,1,10,200,%maxy - 80)

WhileLoop 200

    AddString(h&,Format$("00#." + MkStr$("#",8),Rnd() * 1000))

Wend

While 1

    WaitInput
    Locate 1,29
    s$ = Format$("00#." + MkStr$("#",8),Rnd() * 1000)
    DeleteString(h&,Rnd(GetCount(h&)))
    AddString(h&,s$)
    SelectString(H&,-1,s$)
    Print s$

Wend

 
Windows XP SP2 XProfan X4
... und hier mal was ganz anderes als Profan ...
08/26/08  
 



I gebs yes to, was a stupid idea! The next please...
 
08/26/08  
 




Jörg
Sellmeyer
so, moreover GEHTS:

It should be determined from a number of individual decimal values. I present here as a starting point once the method of strings. The whole thing should also be mathematically. A kind of test bit with 4bit.
means, the number should in any "Bit" four states repräsentieren (0,1,2,3) and his eight digits.
CompileMarkSeparation
Proc ErmittleZahl

    Parameters Zahl$,l%
    Return Mid$(Zahl$,l%,1)

EndProc

Var a% = 33120113
Declare Tick&
Print a%
Set("FastMode",1)
Tick& = &GetTickCount

WhileLoop 8

    Print "Zahl",&Loop,"ist eine",ErmittleZahl(a%,&Loop)
    ErmittleZahl(a%,&Loop)

Wend


As I said, no Stringlösungen, but purely mathematical and not more than this 8 Schleifendurchläufen.
 
Windows XP SP2 XProfan X4
... und hier mal was ganz anderes als Profan ...
08/28/08  
 




Frank
Abbing
Why can You the 1000 times through?
Übrigens is but one of your Stringlösung, or? MID$ nunmal is a string function...
 
08/28/08  
 




Jörg
Sellmeyer
That the 1000it-Loop I had forgotten rauszunehmen.

Frank Abbing
Übrigens is but one of your Stringlösung, or?


Jörg Sellmeyer
I present here as a starting point once the method of strings. The whole thing should also be mathematically.


means: have You a mathematical Solution?
 
Windows XP SP2 XProfan X4
... und hier mal was ganz anderes als Profan ...
08/28/08  
 




Sebastian
Sprenger
Gehts now really about 2 Bits per digit and 8 Digits per number, or simply a Mid$-substitute? Naja whatever:
CompileMarkSeparation
Proc ErmittleZahl

    Parameters Zahl&, pos%
    Declare len%
    Dec pos%
    Case pos% < 0: Return ""

    IfNot Zahl&

        Case pos%: Return ""
        Return 0

    ElseIf Zahl& < 0

        CaseNot pos%: Return "-"
        Dec pos%
        Zahl& = Abs(Zahl&)

    EndIf

    len% = Lg(Zahl&) / Lg(10)
    Case pos% > len%: Return ""
    Return Int((Zahl& / 10 ^ (len% - pos%)) Mod 10)

ENDPROC

Old procedure ErmittleZahl simply replace...
 
Profan² 7.0e, XProfan 9, 11.2a, FreeProfan32
Windows Vista Home Premium 32-Bit, 2.8 Ghz, 4 GB RAM
Windows Me, 1.8 Ghz, 256 MB RAM
08/28/08  
 




Frank
Abbing
Hm, maybe something like?
CompileMarkSeparation
Declare a&,b&,x&
a&=33120113
x&=100
Print a&
Print

WhileLoop 8

    x&=1

    Whileloop 8-(&loop-1)

        x&=x&*10

    EndWhile

    a&=a&-(Int(a&/x&)*x&)
    b&=a&/(x&/10)
    Print b&

Wend

WaitInput
End
 
08/28/08  
 




Jörg
Sellmeyer
I post my views Solution. The need for 1000 Durchgänge ~1500 - ~2000 ms (therefore, the 1000 loop)
The Stringlösung need only ~1000 - 1500ms. Your need ~2800 - ~3500ms
I thought, mathematically could it to go faster. The idea is: i want Strings by Sendmessage to another program transfer. The strings consist of up to 16 characters (could one of eight agencies over &wparam and &lparam send). There are only four different characters, therefore the numbers of 0-3 per one decimal place.
CompileMarkSeparation
Set("Decimals",0)

Proc ErRechneZahl

    Parameters Zahl%,l%
    Sub Zahl%,(Zahl% Mod (10^l%)) / 10^l%
    Return (Zahl% Mod (10^l%)) / 10^(l% -1)
    um die Bedingung mit maximal 4 Zuständen zu erfüllen, müßte das hier zurückgegeben werden:
    Zahl% = (Zahl% Mod (10^l%)) / 10^(l% -1)
    Return If(Zahl% < 4,Zahl%,0)

EndProc

Var a% = 33120113
Declare Tick&
Print a%
Tick& = &GetTickCount

WhileLoop 1000

    Locate 13,1
    Print &Loop

    WhileLoop 8

        Print ErRechneZahl(a%,&Loop)

    Wend

Wend

Print &GetTickCount - Tick&
Waitinput

The numbers are backward issued but that means nothing.

Related to the Lg(Zahl&), rauszubekommen the number of posts, gefällt me! However, I am not clear, why do you even through the Lg(10) dividest. The is still 1 or?
 
Windows XP SP2 XProfan X4
... und hier mal was ganz anderes als Profan ...
08/28/08  
 




Frank
Abbing
OK, got my routine improved. Should now work significantly faster:
CompileMarkSeparation
Declare a&,b&,x&
a&=33120113
x&=100
Print a&
Print

WhileLoop 8

    x&=10^(8-(&loop-1))
    a&=a&-(Int(a&/x&)*x&)
    b&=a&/(x&/10)
    Print b&

Wend

WaitInput
End
 
08/29/08  
 




Sebastian
Sprenger
Jörg Sellmeyer
why do you even through the Lg(10) dividest. The is still 1 or?

True, he is it?
*ausprobier*
Yes, he's. well to know. One can take the logarithm to a certain base (in my case 10) calculate, but if The Lg-function with 10 anyhow 1 outputs, kann's Yes omitted.
 
Profan² 7.0e, XProfan 9, 11.2a, FreeProfan32
Windows Vista Home Premium 32-Bit, 2.8 Ghz, 4 GB RAM
Windows Me, 1.8 Ghz, 256 MB RAM
08/29/08  
 




Answer


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

25.426 Views

Untitledvor 0 min.
p.specht05/22/13
mene12/06/12
Peter Max Müller12/11/11
Jens Tiburski12/29/10
More...

Themeninformationen



Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie