Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #34334

Re: Mathematics, Java, good enough

From Eric Sosman <esosman@comcast-dot-net.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: Mathematics, Java, good enough
Date 2016-05-17 16:12 -0400
Organization A noiseless patient Spider
Message-ID <nhftoj$ik2$1@dont-email.me> (permalink)
References (5 earlier) <ff57f7e8-2d3a-4fb0-a9fe-763965a76af3@googlegroups.com> <nhfbce$6ii$1@dont-email.me> <nhfj31$509$1@dont-email.me> <nhfm4j$i8t$1@dont-email.me> <7eb8f161-ca45-489f-bfdb-4f96b534790d@googlegroups.com>

Show all headers | View raw


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

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Mathematics, Java, good enough Duncan Idaho <duncan@dunenoemail.com> - 2016-05-17 11:49 +0100
  Re: Mathematics, Java, good enough Eric Douglas <e.d.programmer@gmail.com> - 2016-05-17 04:55 -0700
  Re: Mathematics, Java, good enough Nigel Wade <nmw@ion.le.ac.uk> - 2016-05-17 12:56 +0100
    Re: Mathematics, Java, good enough Nigel Wade <nmw@ion.le.ac.uk> - 2016-05-17 13:06 +0100
    Re: Mathematics, Java, good enough Duncan Idaho <duncan@dunenoemail.com> - 2016-05-17 13:29 +0100
      Re: Mathematics, Java, good enough Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-05-17 09:54 -0400
        Re: Mathematics, Java, good enough FredK <fred.l.kleinschmidt@gmail.com> - 2016-05-17 07:17 -0700
          Re: Mathematics, Java, good enough FredK <fred.l.kleinschmidt@gmail.com> - 2016-05-17 07:29 -0700
            Re: Mathematics, Java, good enough Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-05-17 10:58 -0400
              Re: Mathematics, Java, good enough Duncan Idaho <duncan@dunenoemail.com> - 2016-05-17 18:10 +0100
                Re: Mathematics, Java, good enough Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-05-17 14:02 -0400
                Re: Mathematics, Java, good enough Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-05-17 14:10 -0400
                Re: Mathematics, Java, good enough Eric Douglas <e.d.programmer@gmail.com> - 2016-05-17 11:36 -0700
                Re: Mathematics, Java, good enough Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-05-17 16:12 -0400
                Re: Mathematics, Java, good enough Eric Douglas <e.d.programmer@gmail.com> - 2016-05-17 13:56 -0700
                Re: Mathematics, Java, good enough Gene Wirchenko <genew@telus.net> - 2016-05-17 14:13 -0700
                Re: Mathematics, Java, good enough Duncan Idaho <duncan@dunenoemail.com> - 2016-05-18 05:06 +0100
  Re: Mathematics, Java, good enough Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-05-17 08:25 -0400
  Re: Mathematics, Java, good enough Martin Gregorie <martin@address-in-sig.invalid> - 2016-05-17 12:24 +0000
  Re: Mathematics, Java, good enough Duncan Idaho <duncan@dunenoemail.com> - 2016-05-17 18:15 +0100
    Re: Mathematics, Java, good enough Jerry Stuckle <jstucklex@attglobal.net> - 2016-05-17 13:33 -0400
    Re: Mathematics, Java, good enough Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-05-17 14:09 -0400
      Re: Mathematics, Java, good enough Gene Wirchenko <genew@telus.net> - 2016-05-17 14:17 -0700
        Re: Mathematics, Java, good enough Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-05-17 17:49 -0400

csiph-web