From: Daniel Finnie Date: 2007-01-16T09:01:22+09:00 Subject: Re: newbie question about sets You shouldn't really have to avoid this. The 6 letter word should be 6 unique letters, otherwise how would there be 6 letters for the user to guess? Dan Jason Mayer wrote: > I'm just curious if there's any way to duplicate values in a set. After > quiz 108, I modified my submission so that it was a fully functional game. > I then passed around my finished program to some of my coworkers who are > interested in ruby. After a few days, someone came back to me with a bug, > and this appears to be the root cause of that bug. > > irb(main):001:0> target = "stuff" > => "stuff" > irb(main):002:0> a = target.split(//).sort > => ["f", "f", "s", "t", "u"] > irb(main):003:0> require 'Set' > => true > irb(main):004:0> s1 = Set.new(a) > => # > > As it stands, if the word ffffuuuuussssstttt existed, it would be > considered > a subset of a. How do you avoid this using sets? >