mpower Posted October 20, 2020 Share Posted October 20, 2020 Hi all, just looking to get some assistance with a tricky one: I have a list of 100 names with duplicates. I need to sort that list into evenly split sub-lists (2 or more, up to 5) whilst making sure the same name is never repeated in the same sub-list. E.g. Master list: Steve Koprowski Treasa Hartranft Trisha Mattie Trisha Mattie Teddy Wheat Preston Jetter Adrianne Manders Preston Jetter Shawnna Ullrich Nicolette Ruffner Aurelio Kells Steve Koprowski Marylyn Gilder Nicolette Ruffner Sorted into two sub-lists (no duplicates in any sub-list): Steve Koprowski Nicolette Ruffner Treasa Hartranft Steve Koprowski Nicolette Ruffner Trisha Mattie Trisha Mattie Preston Jetter Adrianne Manders Shawnna Ullrich Preston Jetter Aurelio Kells Marylyn Gilder Teddy Wheat Sorted into three sub-lists (no duplicates in any sub-list): Steve Koprowski Nicolette Ruffner Preston Jetter Treasa Hartranft Steve Koprowski Shawnna Ullrich Nicolette Ruffner Trisha Mattie Aurelio Kells Trisha Mattie Marylyn Gilder Teddy Wheat Adrianne Manders Preston Jetter Link to comment Share on other sites More sharing options...
spudw2k Posted October 21, 2020 Share Posted October 21, 2020 If you put the names into an array, you can use the _ArrayUnique function to eliminate duplicates. After that, you could use _ArrayExtract to create new arrays (lists) the sizes you want (Array Size / 2, Array Size /3, etc.) Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
mpower Posted October 21, 2020 Author Share Posted October 21, 2020 I want the duplicates to remain, they just cannot be repeated in the split lists. I.e. each person is only allocated to unique sub-lists. Anyway I think I figured out how to do it. The trick is to allocate all dupes randomly (but without repeating in the same sub-list) first. Then allocate the rest of the non-dupes to fill the rest of the sub lists. Cheers Link to comment Share on other sites More sharing options...
CYCho Posted October 21, 2020 Share Posted October 21, 2020 (edited) The following method divides the master list into 3 sublists. If you have 4 identical names in the master list and you divide it to 3 sublists, you cannot avoid duplicate in one of the sublists. expandcollapse popup#include <Array.au3> $sMaster = "Steve Koprowski" $sMaster &= @CR & "Treasa Hartranft" $sMaster &= @CR & "Trisha Mattie" $sMaster &= @CR & "Trisha Mattie" $sMaster &= @CR & "Teddy Wheat" $sMaster &= @CR & "Preston Jetter" $sMaster &= @CR & "Adrianne Manders" $sMaster &= @CR & "Preston Jetter" $sMaster &= @CR & "Shawnna Ullrich" $sMaster &= @CR & "Nicolette Ruffner" $sMaster &= @CR & "Aurelio Kells" $sMaster &= @CR & "Steve Koprowski" $sMaster &= @CR & "Marylyn Gilder" $sMaster &= @CR & "Nicolette Ruffner" $aMaster = StringSplit($sMaster, @CR) _ArraySort($aMaster, 0, 1) Dim $aList1[1], $aList2[1], $aList3[1] For $i = 1 To $aMaster[0] If Mod($i, 3) = 1 Then _ArrayAdd($aList1, $aMaster[$i]) $aList1[0] += 1 ElseIf Mod($i, 3) = 2 Then _ArrayAdd($aList2, $aMaster[$i]) $aList2[0] += 1 Else _ArrayAdd($aList3, $aMaster[$i]) $aList3[0] += 1 EndIf Next _ArrayDisplay($aList1) _ArrayDisplay($aList2) _ArrayDisplay($aList3) Edited October 21, 2020 by CYCho zPlayer - A Small Audio and Video Player Time Sync + SystemTimeAdjustment Link to comment Share on other sites More sharing options...
spudw2k Posted October 21, 2020 Share Posted October 21, 2020 2 hours ago, mpower said: I want the duplicates to remain Ah, I see. Sorry for missing that detail. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
JockoDundee Posted October 21, 2020 Share Posted October 21, 2020 3 hours ago, mpower said: The trick is to allocate all dupes randomly Imho, the best solution rarely involves randomness, especially when it comes to finite tasks, e.g. sorting... Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now