Jump to content

Logic to Find Duplicate Number


vijayP

Recommended Posts

What should be the Logic to find out duplicate number from a nubmer series.

like 110 111 112 113 114 111 110 111 115 116 along with there (x,y)

 

For Ex. 110 is repeated 2 times

 

("110" ("1057.03 475.00" "821.46 436.99"))  ;;("num" ("1st x y" "2nd x y"))

 

111 is repeated 3 times

 

("111" ("614.88 467.76" "422.80 605.32" "1524.55 420.70"))  ;;("num" ("1st x y" "2nd x y" "3rd x y"))

 

 

so that we can put them in 2 tile list box. In first tile num and in second tile its all x y.

find dpli.JPG

Edited by vijayP
Link to comment
Share on other sites

This ... ?

 

(setq l '(110 111 112 113 114 111 110 111 115 116))
(foreach i l (if (not (member i lst)) (setq lst (cons i lst))))
(reverse lst)

Link to comment
Share on other sites

I believe that concerned list is the enumeration from OP's statement, Tharwat; below he/she just provided examples of items.

 

VijayP, to list the duplicates just parse your list using FOREACH and store each element into a new one; use MEMBER to check if current element is already there - if yes, then you have a duplicate.

Link to comment
Share on other sites

Tharwat; your code is returning list without duplicate but i need all duplicate and their x y. so that we can find them

Msasu; any example code?

Link to comment
Share on other sites

Can you be more specific to the point ?

 

Tharwat; your code is returning list without duplicate but i need all duplicate and their x y. so that we can find them

 

If you do not give a clear example of what you are after , people would keep on guessing and posting unneeded codes and maybe no one would follow your thread .

 

This is just for your information .

Link to comment
Share on other sites

find out duplicate numbers from a nubmer series.

like 110 111 112 113 114 111 110 111 115 116 along with there (x,y)

 

Tharwat; please see post #1 again

Link to comment
Share on other sites

As a "Demo"...

 

(setq lst '(("110" ("1.6 3.3" "2.0 3.5" "1.8 2.9"))
    ("111" ("1.5 3.2" "2.0 3.5" "1.8 2.9"))
    ("111" ("1.5 3.2" "2.0 3.5" "1.8 2.9"))
    ("112" ("1.8 3.8" "2.8 3.8" "1.0 2.0"))
    ("112" ("1.8 3.8" "2.8 3.8" "1.0 2.0"))
    ("113" ("1.5 3.2" "2.0 3.5" "1.8 2.9"))
    ("114" ("1.0 3.0" "2.6 3.6" "1.6 2.6"))
    ("114" ("1.0 3.0" "2.6 3.6" "1.6 2.6"))
    )
     )

(foreach x lst
 (if (member x tmplst)
   (setq dup-lst (cons x dup-lst));; dup-lst will retain all the duplicate
   )
 (setq tmplst (cons x tmplst))
 )

 

HTH

Henrique

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...