NiM Posted March 27, 2009 Posted March 27, 2009 So I am making this whole crazy program for my teacher and I have an array of clubs and I need to know which club shows up the most and how many times they show up. I got something working, not to sure how it works just that it works, horribly. So what I am asking is if there is an easier way/better way to do this. expandcollapse popup#Include <Array.au3> #Include <string.au3> dim $aClubs[11] = ["fighting mongoose", "fatdood", "fighting mongoose", "team awsome", "teem bad", "fighting mongoose", "teem gamming", "teem bad", "fighting mongoose", "fighting mongoose", "teem bad"] dim $club[UBound($aClubs)][2] ;~ $club[0][0] = $aClubs[0] ;~ _ArrayDelete($club, 0) ;~ _ArrayDisplay($club) for $u = 0 to UBound($aClubs)-1;i have no idea whats going on here for $y = 0 to UBound($aClubs)-1 if $aClubs[$u] = $aClubs[$y] Then if $club[$y][0] = "" then $club[$y][0] = $aClubs[$u] $club[$y][1] += 1 ;~ _ArrayDisplay($club, "added 1") EndIf Next Next ;~ _ArrayDisplay($club, "b4sort") _ArraySort($club) ;~ _ArrayDisplay($club, "baftersort") dim $last, $todelete for $i = 0 to UBound($club)-1 if $club[$i][0] = $last then $todelete &= $i&"," EndIf $last = $club[$i][0] Next ;~ MsgBox(0, "", $todelete) $todelete = StringTrimRight($todelete, 1) $todelete = _StringReverse($todelete) ;~ MsgBox(0, "", $todelete) $str = StringSplit($todelete, ",") ;~ _ArrayDisplay($str) for $i = 1 to $str[0] _ArrayDelete($club, $str[$i]) Next _ArrayDisplay($club, "DONE") ;then just go through like everything else and do ties but this is all i need right now
KaFu Posted March 27, 2009 Posted March 27, 2009 (edited) #Include <Array.au3> dim $aClubs[11] = ["fighting mongoose", "fatdood", "fighting mongoose", "team awsome", "teem bad", "fighting mongoose", "teem gamming", "teem bad", "fighting mongoose", "fighting mongoose", "teem bad"] dim $aResult[1][2] _ArraySort($aClubs) ;check element to next element, up to second last element against last element for $i = 0 to UBound($aClubs) - 2 if $aClubs[$i] <> $aClubs[$i+1] then if $aResult[UBound($aResult)-1][0] <> "" then ReDim $aResult[UBound($aResult)+1][2] $aResult[UBound($aResult)-1][0] = $aClubs[$i] $aResult[UBound($aResult)-1][1] = 0 endif Next ;check last element of $aClub against second last element if $aClubs[UBound($aClubs)-2] <> $aClubs[UBound($aClubs)-1] then if $aResult[UBound($aResult)-1][0] <> "" then ReDim $aResult[UBound($aResult)+1][2] $aResult[UBound($aResult)-1][0] = $aClubs[UBound($aClubs)-1] $aResult[UBound($aResult)-1][1] = 0 endif _ArrayDisplay($aResult) for $i = 0 to UBound($aClubs) - 1 for $y = 0 to UBound($aResult) - 1 if $aResult[$y][0] = $aClubs[$i] Then $aResult[$y][1] += 1 endif Next Next _ArrayDisplay($aResult) Edited March 27, 2009 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2025-May-18) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
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