Algorithm to reduce string

Discussion in 'ASP General' started by Paulo Roberto Bianchi de Oliveira, May 19, 2010.

  1. Hi, if I have some string like: "2010051912101" can it be reduced to as min
    numbers as possible?

    Because it's the "date+hour+milsec+etc" generated on the DB, but on the doc
    that will be impressed it must be reduced because the operator will inform
    it via phone... So minimizes errors typing on tel keyboard

    Do you know if there's any algorithm? And I need to be able to get the
    inverse too, the reduced to the original string...

    Is it possible? Thanks
    Paulo Roberto Bianchi de Oliveira, May 19, 2010
    #1
    1. Advertising

  2. Gazing into my crystal ball I observed "Paulo Roberto Bianchi de
    Oliveira" <> writing in
    news::

    > Hi, if I have some string like: "2010051912101" can it be reduced to
    > as min numbers as possible?
    >
    > Because it's the "date+hour+milsec+etc" generated on the DB, but on
    > the doc that will be impressed it must be reduced because the operator
    > will inform it via phone... So minimizes errors typing on tel keyboard
    >
    > Do you know if there's any algorithm? And I need to be able to get the
    > inverse too, the reduced to the original string...
    >
    > Is it possible? Thanks
    >
    >


    I'm not quite sure I understand what you want to do. AFAICS that IS the
    minimum, unless you want parts of the date, then you could do something
    like:

    thedate = "2010051912101"

    datetotest = mid(thedate,5,2) & "-" & mid(thedate,7,2) & "-" & left
    (thedate,4) & " " & mid(thedate,9,2) & ":" & mid(thedate,11,2) & ":" &
    mid(thedate,12)

    theyear = datepart("y",datetotest)
    themonth = datepart("m",datetotest)
    theday = datepart("d",datetotest)
    thehour = datepart("h",datetotest)
    thesecond = datepart("s",datetotest)

    Then you could put it all back together again, or do datediff, dateadd,
    etc.

    --
    Adrienne Boswell at Home
    Arbpen Web Site Design Services
    http://www.cavalcade-of-coding.info
    Please respond to the group so others can share
    Adrienne Boswell, May 19, 2010
    #2
    1. Advertising

  3. Paulo Roberto Bianchi de Oliveira

    Evertjan. Guest

    Paulo Roberto Bianchi de Oliveira wrote on 19 mei 2010 in
    microsoft.public.inetserver.asp.general:

    > Hi, if I have some string like: "2010051912101" can it be reduced to
    > as min numbers as possible?
    >
    > Because it's the "date+hour+milsec+etc" generated on the DB, but on
    > the doc that will be impressed it must be reduced because the operator
    > will inform it via phone... So minimizes errors typing on tel keyboard
    >
    > Do you know if there's any algorithm? And I need to be able to get the
    > inverse too, the reduced to the original string...


    All redusing reduces diversity,
    but if you do not mind that,
    you could reduce to a 1 character string:

    function reduce(s){
    return (s=='2010051912101')?'1':'0';
    };

    function expand(s){
    return (s=='1')?'2010051912101':'';
    };


    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
    Evertjan., May 20, 2010
    #3
  4. Paulo Roberto Bianchi de Oliveira

    Evertjan. Guest

    Evertjan. wrote on 20 mei 2010 in
    microsoft.public.inetserver.asp.general:

    > Paulo Roberto Bianchi de Oliveira wrote on 19 mei 2010 in
    > microsoft.public.inetserver.asp.general:
    >
    >> Hi, if I have some string like: "2010051912101" can it be reduced to
    >> as min numbers as possible?
    >>
    >> Because it's the "date+hour+milsec+etc" generated on the DB, but on
    >> the doc that will be impressed it must be reduced because the operator
    >> will inform it via phone... So minimizes errors typing on tel keyboard
    >>
    >> Do you know if there's any algorithm? And I need to be able to get the
    >> inverse too, the reduced to the original string...

    >
    > All redusing reduces diversity,
    > but if you do not mind that,
    > you could reduce to a 1 character string:
    >
    > function reduce(s){
    > return (s=='2010051912101')?'1':'0';
    >};
    >
    > function expand(s){
    > return (s=='1')?'2010051912101':'';
    >};


    More:

    This is no "Reductio ad absurdum" but the concequence of your failing to
    define constraints of that string, like:

    Is only one string possible, either it is or empty?
    Must the string always have the same length?
    Can there be only figures in the string?
    Does the string contain a date/time sequence?

    If the string can have any content, so has no constraints,
    no reduction is possible.

    If the string is concidered to be a base-10 number,
    you could convert it to a base 26+26+10= 62 number,
    and use A-Z a-z 0-9 to depict that.



    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
    Evertjan., May 20, 2010
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ahmed Moustafa
    Replies:
    0
    Views:
    776
    Ahmed Moustafa
    Nov 15, 2003
  2. CoolPint
    Replies:
    8
    Views:
    463
    Alf P. Steinbach
    Aug 30, 2004
  3. Replies:
    15
    Views:
    878
    Charles Richmond
    Apr 10, 2005
  4. Bapaiah Katepalli
    Replies:
    1
    Views:
    1,495
    Mike Treseler
    Jun 23, 2006
  5. Tung Chau
    Replies:
    0
    Views:
    375
    Tung Chau
    Aug 6, 2004
Loading...

Share This Page