Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Algorithm to reduce string

Reply
Thread Tools

Algorithm to reduce string

 
 
Paulo Roberto Bianchi de Oliveira
Guest
Posts: n/a
 
      05-19-2010
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

 
Reply With Quote
 
 
 
 
Adrienne Boswell
Guest
Posts: n/a
 
      05-19-2010
Gazing into my crystal ball I observed "Paulo Roberto Bianchi de
Oliveira" <(E-Mail Removed)> writing in
news:(E-Mail Removed):

> 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

 
Reply With Quote
 
 
 
 
Evertjan.
Guest
Posts: n/a
 
      05-20-2010
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)
 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      05-20-2010
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)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Filtered Back Projection Algorithm (FBP Algorithm) Bapaiah Katepalli VHDL 1 06-23-2006 04:50 PM
Big O and algorithm to decide string A contains string B? usgog@yahoo.com C++ 15 04-10-2005 03:03 AM
better to compress the jpeg or reduce resolution or reduce pixel size? Mr.Will Digital Photography 8 10-08-2004 03:16 PM
How can I "reduce" the size of internal buffer used by std::string? CoolPint C++ 8 08-30-2004 05:56 PM
Key generation algorithm and Cipher algorithm Ahmed Moustafa Java 0 11-15-2003 06:35 AM



Advertisments