From: Matthew Pounsett Date: 2010-07-19T12:00:14+09:00 Subject: Re: Infinite Loop in Code -- Logic Error On 2010/07/17, at 06:38, James Rasmussen wrote: > I'm having a problem with my code. It's attached, and if someone could > look at it, that would be great. I can't figure out what I'm doing > wrong. I think it's something wrong with my for loop. Basically, the > code is supposed to find "spies" for all the entries, but someone cannot > "spy" on a person with their same last name, or themselves. The goal is > to print the list of spies all out. Thank you in advance! This won't help with your logic problem as it stands .. but it looks like others have commented on that. As another approach, Array.permutation (ruby 1.9) might be of some use in solving your problem. The method will give you all permutations of the elements of an array (which doesn't include matching an element with itself) ... if you've got an array of arrays, then all you need to do is reject permutations where the last-name position in both arrays contain the same name... same deal if it's an array of hashes. I started to insert some sample code here, but then realized that would probably defeat the purpose of your exercise. :) If you're not using 1.9, then I'm sure you can find a quick way to implement the equivalent. HTH, Matt