Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: Mathematics, Java, good enough Date: Tue, 17 May 2016 10:58:44 -0400 Organization: A noiseless patient Spider Lines: 29 Message-ID: References: <768508de-3c08-4d46-8c68-8a5f8b7db533@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 17 May 2016 14:55:10 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="2d081e2f7155c28005d4472f67c2f43d"; logging-data="6738"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Enhuvs+w++31fuME8SQq3" User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.0 In-Reply-To: Cancel-Lock: sha1:xkQbdynTyg1BFoKt9I3eLUx86tE= Xref: csiph.com comp.lang.java.programmer:34324 On 5/17/2016 10:29 AM, FredK wrote: > On Tuesday, May 17, 2016 at 7:17:23 AM UTC-7, FredK wrote: >> The question arises whether you really want to know how many distinguishable strinmgs there are, which is much smaller if the original set contains duplicate entries. > For example, if the set it "AAB" there are only 3 distinguishable strings of length 2: AA, AB, and BA What happened to "BB"? I think you're writing about a situation that doesn't match the O.P.'s question. The O.P. wrote that he had a "set of characters," and went on to mention its "cardinality" -- from this, I understood him to mean that he actually had a "set." {A A B} is not a set. (It's a multiset, yes, but not a set.) import java.util.HashSet; public class TryMe { public static void main(String[] unused) { HashSet set = new HashSet<>(); set.add('A'); set.add('A'); set.add('B'); System.out.println(set.size()); } } If the output is "3", your Java is broken. ;) -- esosman@comcast-dot-net.invalid "Don't be afraid of work. Make work afraid of you." -- TLM