in reply to Re^2: Help thinking about an alternate algorithm
in thread Help thinking about an alternate algorithm

> Each kid is told that the next day they must all wear a hat, a shirt, a pair of pants, a belt and a pair of shoes.

So each kid has a coordinate in a 5 dimensional space

 hat X shirt X pants X belt X shoes

You want to know the maximum Hamming Distance between of two kids.

> I was hoping there would be a way to say I currently have found two students with at least 3 things different so I shouldn't consider students who have at least 2 thing ...

One naive approach is to sort is to partition all students according to each dimension such that

 union ( @hat{ qw/red white blue/ } ) == @all_students and so on.

those partitions are the layers in a 5-dimensional cube.

for one student A=(a_1,a_2,a_3,a_4,a_5) the maximum distance students are those in the intersection of  @Not(a_n) for the smallest n.

> current high water mark.

well n has to be greater than your current maximum.

I'm not very keen to code this, just wanna give you pointers for keywords to find appropriate algorithms.

Another thing which comes to mind are implication bases.

Something like "all kids with red hat and yellow shirt wear green pants" is an implication.

The minimal set of implications which can be used to derive all other possible implications is called an "implication base".

If all other students are in a 3 distance to A. this means that any 3 features A doesn't have already imply a feature A has.

There are many algorithms effectively calculating such implications for a given point set, I wouldn't be surprised if they already lead to the maximum hamming distance as a side effect.

AFAIK "Implication bases" are used for DB optimization.

I'd start looking there.¹

HTH! =)

Cheers Rolf

( addicted to the Perl Programming Language)

¹)I wouldn't be surprised if modifying next closure-algorithm of Bernhard Ganter can already be used for this.