Find missing and duplicates in a list

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Find missing and duplicates in a list

NetLogo-Users mailing list

 Hi All

 I could use some coding help and I am not sure how to approach this in NetLogo.
 I want to make sure all the characters in list1 are in reported in list2, there may be duplicates and missing characters. I want to count the characters in a valid list then in list 1 to match up characters to valid list

 Like PAVC= valid
     AVCC = list1


 Then I want to replace one of the duplicates with a missing character. Add it to the list then report the new list in list2




  I want to create a list, that gets two list and adds up the characters of two lists. If the count is 1 then that character is missing if the count is two that charcter is a duplicate. Then I want to replace the duplicate character with a missing, randomly or at the end of string. then report the new-string. I am not sure if this is the correct approach:



 to-report Legalize [list1 list2]
   show Legalize
   let NumberOfLetters (length list1)
   let list1 new generation
   let count-duplicates count i
   let count-missing count i
   let missing []
   let duplicates []
 while [i< NumberofLetters]
   [set NumberofLetters missing missing 1
    set NumberofLetters duplicates duplicates 2
 show "missing"
 show missing
 show "duplicates"
 show duplicates
 while [j<(lengthMissing)]
   [set lengthMissing lput [list2]
   report list2