From: George Ogata Date: 2002-08-10T18:26:10+09:00 Subject: Re: Coding challenge (on Ruby Garden) Christoph wrote: > Your solution fails, i.e. it returns false, for > > items = [1,2,2] > row = [1,2] > rows = [ row, row, [1,3]] Good point. Hmm, I wonder if I can get away with it by being pedantic about the wording of the requirements. But this doesn't work: array: [1,2] a-of-as: [ [1,2,3,4], [5,6,7,8] ] because the 1 and the 2 both get placed in the same array; it's a many-to-one correspondence. In your example, the 1 and the 2 get "placed in the same array". The array just appears more than once. Or does it have to be a capitalized "Array" for this argument to hold? Oh well, if it's not acceptable, then: def one_in_each i,r;i==[]||r.find{|s|s.member?(i[0])&&one_in_each(i[1..-1],((d=r.dup).slice!r.index s;d))}!=nil;end (115 chars --- replace newlines with spaces.)