Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Algorithm question
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Algorithm question
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows 2008 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01518379
Message ID:
01518379
Views:
125
I have a basic algorithm question and know that there will be a very simple and efficient solution which replaces the looping and keeping track of variables version I currently have.

I have a cursor with a list of key values such as -> AAAABBBBBCCCDDE (alpha value is simply for illustration)

I want to produce a cursor with those values spread as evenly as possible by frequency, eg (done quickly by hand so not precise):
BACBADBECBADBCA

In a nutshell, my current methodology is to track how often each element should appear in the list (eg. B should be one in every 3 (15/5)) and then insert based on that.

I'm confident that there is someone out there who will make me slap my head in disgust by listing the simple & elegant solution that I should have come up with in the first place :)

Cheers,
Jamie
Cheers,
Jamie
Next
Reply
Map
View

Click here to load this message in the networking platform