Path: csiph.com!news.swapon.de!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 16:12:24 -0400 Organization: A noiseless patient Spider Lines: 35 Message-ID: References: <768508de-3c08-4d46-8c68-8a5f8b7db533@googlegroups.com> <7eb8f161-ca45-489f-bfdb-4f96b534790d@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 20:08:51 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="2d081e2f7155c28005d4472f67c2f43d"; logging-data="19074"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19dOyMGEiMTXNJ+awQkKCdf" User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.0 In-Reply-To: <7eb8f161-ca45-489f-bfdb-4f96b534790d@googlegroups.com> Cancel-Lock: sha1:40VGVYqYvmmQj25YTLmoNFQwROE= Xref: csiph.com comp.lang.java.programmer:34334 On 5/17/2016 2:36 PM, Eric Douglas wrote: > On Tuesday, May 17, 2016 at 2:02:30 PM UTC-4, Eric Sosman wrote: >> Okay -- but if you're going to be any good at programming you'd >> better get at least *some* grounding. For example: Can you see the >> connection between your original question ("How many 8-char strings >> from an alphabet of 26 characters?") and the question of how many >> 8-digit base-62 numbers there are? If not, it may be time to re- >> examine your career choices ... :) > > What about fuzzy math? > ie What should be the minimum length of a string to use for an ID # for 30,000,000 government employees (military vets) using the standard upper and lower case alphabet and digits 0-9 and 8 special characters !@#$%^&* in order to create a unique ID for each current employee, allow for as many future employees, and not make it easy for someone to guess a valid employee ID? 30,000,000 ~= 2^5 * 10^6 ~= 2^5 * 2^20 = 2^25 individuals, so we need about 25 bits of "payload" to distinguish them. To obfuscate, we can arrange that there will be N non-ID's for each real ID, and then choose an N that fits our notion of "not make it easy." Let's suppose we choose "not easy" to be N = 1,000,000, that is, only one in a million potential ID strings is an actual ID. So N ~= 2^20 and we need 20 extra bits in addition to the payload, 45 bits in all. The alphabet you suggest has 70 ~= 2^6 characters, so each character is worth a little over 6 bits. 45 divided by "a little over 6" is 7, so strings of 7 characters should about do it. Check: 3E7 individuals times N=1E6 for "not too easy" = 3E13 potential ID strings. log(3E13)/log(70) ~= 7.3 (calculator), in good agreement with the back-of-the-envelope figure. For safety's sake, I'd round up to 8 instead of down to 7. See how it's done, "Duncan Idaho?" This sort of calculation is a programmer's bread and butter; better develop a taste for it. -- esosman@comcast-dot-net.invalid "Don't be afraid of work. Make work afraid of you." -- TLM