Inverse of a SORT is that possible ?

Just starting out? Need help? Post your questions and find answers here.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

Derek
Addict
Addict
Posts: 2354
Joined: Wed Apr 07, 2004 12:51 am
Location: England

Post by Derek »

[OT]
blueznl wrote:
Derek wrote:
srod wrote:down to the shear speed of today's processors I reckon!

Code: Select all

Repeat
Until Random(100000000) = 10

Debug "Located 10 !"
Still took 20 seconds on my fast processor. :wink:
I shouldn't do these things, but I actually did a number of runs in the background, debugger on, and doing some forum browsing at the same time... and they average out at 11 seconds here :-)
I only ran it once and kind of guessed at 20 seconds, thinking about it, it was probably a lot shorter than that. :D

Also, my fast processor isn't my fastest one but it is fast compared to the p233mmx I had ten years ago. :lol: :lol:

[/OT]
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

srod wrote:Aye, very nice.

In theory though, this method could lock up, forever in seach of that last 'free' element! :wink:
It won't, because the numbers aren't actually random.
That fact that it doesn't lock up is quite surprising; down to the shear speed of today's processors I reckon! Kind of like the following which I would expect to run for a long long time before finishing :

Code: Select all

Repeat
Until Random(100000000) = 10

Debug "Located 10 !"
But that's 1 in 100000000. I just require 1 in 100.
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

If people are timing things, then you should agree on an initial seed value, so the results can be properly compared.
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

I said: I shouldn't be doing these kind of this.

I regret I did :) My apologies, it was not my intention to steal this thread. And if we wanna benchmark, I'm pretty sure this is not the best example to do so 8)
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
Post Reply