Algorithm to reduce string

  • Thread starter Paulo Roberto Bianchi de Oliveira
  • Start date
P

Paulo Roberto Bianchi de Oliveira

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
 
A

Adrienne Boswell

Gazing into my crystal ball I observed "Paulo Roberto Bianchi de
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.
 
E

Evertjan.

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':'';
};
 
E

Evertjan.

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:


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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,794
Messages
2,569,641
Members
45,355
Latest member
SJLChristi

Latest Threads

Top