r,list,data.table,lapply,set-operations

This is kind of like a graph problem so I like to use the igraph library for this, using your sample data, you can do library(igraph) #build edgelist el <- do.call("rbind",lapply(data, embed, 2)) #make a graph gg <- graph.edgelist(el, directed=F) #partition the graph into disjoint sets split(V(gg)$name, clusters(gg)$membership) # $`1`...

c#,linq,iequalitycomparer,set-operations

The problem is your implementation of GetHashCode(Person p). As noted in MSDN: Implementations are required to ensure that if the Equals method returns true for two objects x and y, then the value returned by the GetHashCode method for x must equal the value returned for y. In your case,...

Here's one approach using data.table - provided that type only appears at most once per category: library(data.table) DT <- data.table(DF) ## R> DT[ ,list( nCat=.N ),by=type][ nCat==length(unique(DT$category)), type] [1] "green" All this does it aggregate the original data as a count of rows by type (nCat), and then subset that...