..MindWrite..

Archive for the ‘uncategorized’ Category

Remove first word using sed

Posted by guptaradhesh on April 2, 2014

cat filename | sed -e 's/^ *[^ ]* //'

Rating: 4.5

Posted in uncategorized | Tagged: , | Leave a Comment »

Maximum subarray in an array

Posted by guptaradhesh on March 26, 2014

         /*
	 * Returns a maximum sum value in an array of integers
	 */
	public int maxScan(int[] array)
	{
		if(array.length == 0) return -1;
		else if(array.length == 1) 
			return array[0];
		else
		{	
			int maxSum = array[0];
			int current_max = array[0];
			for(int i = 1; i < array.length; i++)
			{
				current_max = Math.max(array[i], current_max + array[i]); 
				maxSum = Math.max(maxSum, current_max);
			}
			return maxSum;
		}
	}

Posted in uncategorized | Tagged: , | Leave a Comment »

Which linux distribution version and distribution are you using?

Posted by guptaradhesh on February 3, 2014

To find which linux version and distribution you are using:

# uname -a

# cat /proc/version

Posted in uncategorized | Tagged: , , , | Leave a Comment »

Paul Simon’s Tune

Posted by guptaradhesh on October 5, 2010

Paul Simon’s Tune

One of the questions I learned in my algorithms assignment talked about Paul Simon’s tune; as in, given a mathematical equation, which Paul Simon’s tune does it represent. Surely an intersting problem. One might think of going through all songs of nowhere heard Paul Simon.

Lately realised, this tune esp. the lyrics are simply awesome. The meaning is so philosophical, practial and yet so mathematical. It says: “One man’s ceiling is another man’s floor

Mathematically written as,  ∀x∃y⌈x⌉ = ⌊y⌋

Posted in puzzles/ algorithms, uncategorized | Tagged: , | Leave a Comment »