check out my new blog at

Friday, April 29, 2005

Longest Common Sequence

Ok, i've been striving for few hours to get this working...
It searches Longest Common Sequence within 2 ordered sets.
So here's the code:


* @Algorithm : LongestCommonSequence
* @Author : mrix
* @Date : 28.04.2005
* @Ver : 1.1

function searchLCS($big,$small){

if (0 == strlen($big) || 0 == strlen($small))
return '';

$resultl = $resultr = '';

if ( false !== strchr($big,$small{0}))
$resultl = $small{0}.searchLCS(
substr($big,strpos($big,$small{0})+ 1),

$resultr = searchLCS($big,substr($small,1));
return ((strlen($resultl) > strlen($resultr)) ? $resultl:$resultr);
echo searchLCS("cocacola","cosdfla");
# yelds : cola


 check out my new blog at

Tuesday, April 05, 2005


From Dissecting a C# Application:

For each method, we attempted to find a good name that explains what the method does. If someone
doesn't understand a method, it is either a sign of a bad name or a too lengthy method, which should be
further broken down.

That's what i'm talking about...

 check out my new blog at

Friday, April 01, 2005

debug window in Visual Studio .Net

It might be handy to see debug output while debugging.
using System.Diagnostics it can be achieved.


Debug.Listeners.Add(new TextWriterTraceListener(Console.Out));
// Note Console.Out is set as output stream
Debug.AutoFlush = true;
Debug.WriteLine("Entering Main");
Console.WriteLine("Hello World.");
Debug.WriteLine("Exiting Main");

works just fine if app is started in Debug(!) mode.
To see output you should CTRL-ALT-O (View/OtherWindows/Output) and choose Debug from listbox