Some of the most interesting & Shocking In formations about Cricket.

Hello Guys this is my first non-technical post, I would love to share some of the most shocking, interesting information about Cricket History.

1. Sanath Jayasuriya has more ODI wickets than Shane Warne : Yes it’s correct Shane warne took 293 wickets in his ODI career and Sanath took 321 wickets. It was shoking for me too.


2. On 12th January 1964, Indian spinner Bapu Nadkarni bowled 21 consecutive maiden overs vs England at Chennai. His figures were 32-27-5-0 which is an economy rate of 0.15 per over which is the lowest of all bowlers where 10 or more overs were bowled.


3. Wilfred Rhodes took 4,204 wickets in First Class cricket. No, it’s not a typo. He actually did take more than Four Thousand wickets. He also happened to score 39, 969 runs.


4. Sachin is not the highest Centuries hitter, Sir Jack Hobbs scored 199 centuries in his First Class career.


5. In a World Cup Match, chasing 335, Sunil Gavaskar scored an unbeaten 36 off 174 balls. In the Prudential World Cup of 1975, in the match between India and England, England set the target of 335 runs in 60 overs. Sunil Gavaskar batted throughout the innings and scored only 36 runs of 174 balls. India managed to score only 132 runs in 60 overs with 7 wickets in hand.


6. Sachin + Zaheer = (Almost) Kallis.


7. Sir Don Bradman has just hit 6 sixes in his entire career.

8. The England Cricket Team is the only team in ODI history to lose a 60 over ODI Final (1979 World Cup), a 50 over ODI Final (1992 World Cup and 2004 Champions Trophy) and a 20 over ODI Final (2013 Champions Trophy) in ICC tournaments.

Regex to validate the Email

Here i am sharing a regex to validate the Email.

This is an standard version of regex.


It can validate email like

Valid Emails

Invalid Emails


Vmware Problem with ubuntu 13.10

I installed Vmware it was working well, i updated/upgraded OS firmware, now it’s not working. i googled it and found the solution. before telling the solution i wanna tell why this is coming.

VMware Player has a nice auto-detection of kernel changes, and requests the user to compile the required modules in order to load them. This happens from time to time after a regular update of your system. Usually, the dialog of VMware Kernel Module Updater pops up, asks for root access authentication, and completes the compilation.

In theory this is supposed to work flawlessly but in reality there are pitfalls occassionally. With the recent upgrade to Ubuntu 13.04 Raring Ringtail and the latest kernel 3.8.0-21 the actual VMware Kernel Module Updater simply disappeared and the application wouldn’t start as expected. When you launch VMware Player as super user (root) the dialog would stall.

Solution is :

sudo vmware-modconfig --console --install-all

This solution worked for me.

My machine was VMware Player 5.0.2 build-1031769

Counting Digits from given Range

Imagine you sell those metallic digits used to number houses, locker doors, hotel rooms, etc. You need to find how many of each digit to ship when your customer needs to number doors/houses:
1 to 100
51 to 300
1 to 2,000 with zeros to the left
The obvious solution is to do a loop from the first to the last number, convert the counter to a string with or without zeros to the left, extract each digit and use it as an index to increment an array of 10 integers.
I wonder if there is a better way to solve this, without having to loop through the entire integers range.
GitHub Link
Thanx to mathematician’s Post that helped me to understand the complexity of problem, i just understood the equation and converted it to code. Enjoy !

Bash script not working with `sh`

I was testing a simple script and I was wondering why it works fine when executed from directory: ./ but when I try with “sh” command sh it’s not working: 3: [[: not found 7: [[: not found

#!/usr/bin/env bash

if [[ $1 = one ]]
        printf "%b" "two\n" >&2
        exit 0
elif [[ $1 = two ]]
        printf "%b" "one\n" >&2
        exit 0
        printf "%b" "Specify argument: one/two\n"
        exit 1

I goggled and found this link

sh is a different program than bash.


The problem is that the Bourne shell (sh) is not the Bourne Again shell (bash). Namely, sh doesn’t understand the [[ pragma. In fact, it doesn’t understand [ either. [ is an actual program or link to /bin/test (or /usr/bin/[, /usr/bin/test).

$ which [
$ ls -lh /bin/[
-r-xr-xr-x  2 root  wheel    42K Feb 29 17:11 /bin/[

When you execute your script directly through ./, you’re calling the script as the first argument to the program specified in the first line. In this case:
#!/usr/bin/env bash
Often, this is directly the interpreter (/bin/bash, or any number of other script interpreters), but in your case you’re using env to run a program in a modified environment — but that follow argument is still bash. Effectively, ./ is bash
Because sh and bash are different shells with different syntax interpretations, you’re seeing that error. If you run bash, you should see what is expected.
More info
Others have pointed out in comments that /bin/sh can be a link or other shell. Historically, sh was the Bourne shell on the old AT&T Unix, and in my mind the canonical descent. However, that is different in BSD variations and has diverged in other Unix based systems and distributions over time. If you’re really interested in the inner workings (including how /bin/sh and /bin/bash can be the same program and behave totally differently), read the following:
[1] [2]

As noted: /bin/sh typically (though not always) invokes a POSIX-compliant Bourne shell. Bash is Not Bourne.
Bash will attempt to emulate Bourne when invoked as ‘sh’ (as when /bin/sh symlinks or links to /bin/bash), or if $POSIXLY_CORRECT is defined in the invoking environment, when invoked with the –posix invocation option, or when ‘set -o posix’ has been executed. This enables testing a Bourne shell script / command for POSIX compliance.
Alternately, invoke scripts / test commands with a known POSIX-compliant shell. ‘dash’ is close, the Korn shell (ksh) IIRC offers a POSIX compliant option as well.

Minimum cost flow House coloring with three colors

There are a row of houses, each house can be painted with three colors red, blue and green. The cost of painting each house with a certain color is different. You have to paint all the houses such that no two adjacent houses have the same color. You have to paint the houses with minimum cost. How would you do it?

Note: Painting house-1 with red costs different from painting house-2 with red. The costs are different for each house and each color.

Dynamic Programming solution:
we can paint the i’th house with blue, red or green.

Enter No. of Houses to paint : 6
1 4 5
1 3 9
6 7 2
9 6 4
3 5 2
6 7 4

Minimum Cost to paint all houses are 20
#include <stdio.h>
#include <stdarg.h>
#define COLOR 3
#define MAX(a,b) ((a) > (b) ? a : b)
#define MIN(a,b) ((a) < (b) ? a : b)
#define R 0
#define B 1
#define G 2
#define Color 3

int min( int num, ... )
    va_list arguments;
    int min=0;
    int tmp=0;
    /* Initializing arguments to store all values after num */
    va_start ( arguments, num );
    /* Sum all the inputs; we still rely on the function caller to tell us how
     * many there are */
    min = va_arg ( arguments, int );
    for ( int x = 1; x < num; x++ )
		tmp = va_arg(arguments,int);
		min = MIN(min,tmp);
    va_end ( arguments );
    // Cleans up the list
	//printf("\nMin is %d", min);
    return min;
typedef struct {
    int  color;
    int cost;
    //struct nodee *root;
int main()
	node cost[3];
	int house = 3;
	printf("Enter No. of Houses to paint : ");
	int color[house][COLOR];
//	int ji=0;
	for(int i=0; i<house;++i){
		for(int j=0; j<COLOR;++j){
//				color[i][j]= ++ji;

	for(int i= 0; i< Color ;i++){
			cost[i].color = i;
		} // Initial Submission of values, and colour
//	printf("\nA.cost\t%d(%d)\tB.cost\t%d(%d)\tC.cost\t%d(%d)\n",cost[0].cost,cost[0].color,cost[1].cost,cost[1].color,cost[2].cost,cost[2].color);
	//A.color = R; B.color = B; C.color = G;
	int tmp_B=0,tmp_G=0,tmp_R=0;
	for(int i=1; i<house;++i)
			for(int j= 0; j< Color ;j++){
				if(cost[j].color == R){
						if(color[i][B] < color[i][G]){
							cost[j].cost = cost[j].cost + color[i][B];
							cost[j].color = B;
							//cost[j].root = malloc(sizeof(struct node));
							//cost[j].root->next = 0;
							//cost[j].root->x = color[i][B];
								cost[j].cost = cost[j].cost + color[i][G];
								cost[j].color = G;
					}else if(cost[j].color == B){
							if(color[i][R] < color[i][G]){
								cost[j].cost = cost[j].cost + color[i][R];
								cost[j].color = R;
									cost[j].cost = cost[j].cost + color[i][G];
									cost[j].color = G;
								//Case for G
								if(color[i][R] < color[i][B]){
									cost[j].cost = cost[j].cost + color[i][R];
									cost[j].color = R;
											cost[j].cost = cost[j].cost + color[i][B];
											cost[j].color = B;
//			printf("\nA.cost\t%d(%d)\tB.cost\t%d(%d)\tC.cost\t%d(%d)\n",cost[0].cost,cost[0].color,cost[1].cost,cost[1].color,cost[2].cost,cost[2].color);
			if(A.color == )
			//R_cost = min(2,color[i][B],color[i][G])+R_cost;
			if(color[i][B] < color[i][G]){

				tmp_B = R_cost + color[i][B];
						tmp_G = R_cost + color[i][G];

			//B_cost = min(2,color[i][R],color[i][G])+B_cost;
			if(color[i][R] < color[i][G]){

				tmp_R = B_cost + color[i][R];
						tmp_G = B_cost + color[i][G];
			//G_cost = min(2,color[i][B],color[i][R])+G_cost;
			if(color[i][R] < color[i][B]){

				tmp_R = G_cost + color[i][R];
						tmp_B = G_cost + color[i][B];
			R_cost = tmp_R;
			B_cost = tmp_B;
			G_cost = tmp_G;
			//printf("\n G %d:%d",color[i][B],color[i][R]);
//			printf("\nA.cost\t%d(%d)\tB.cost\t%d(%d)\tC.cost\t%d(%d)\n",cost[0].cost,cost[0].color,cost[1].cost,cost[1].color,cost[2].cost,cost[2].color);
	printf("\nMinimum Cost to paint all houses are %d\n",min(3,cost[0].cost,cost[1].cost,cost[2].cost));

First Version of RegextoWord

Hello Guys. I have been working in Perl from last 5 moths and while writing Regular Expressions i face difficulty to understand or write the Regular expressions. Well now it’s ok, but i thought can we covert the RegEx to understandable language.
So i started an project, here is the first version of the RegExtowordV1.0.

It can accept(Parse) Strings like


Basically in first version it can parse string (any word , digit special character, ^ ,[] () ).
please do give some feedback about it.

Increment decrement problem in c

Hello guys let's we have an syntax and related values let's see how this works. Evaluate the given syntax 
z = ++x + y-- - ++y - x-- - x-- - ++y - x--
where x = 7 y = -3
z = ((((((++x + y--) - ++y) - x--) - x--) - ++y) - x--)
so first(++x + y--) will be evaluated
 (++x + y--)
   8 + (-3)        x=8 y = -4
 z = (((((5 - ++y) - x--) - x--) - ++y) - x--)
 (5 - ++y)
  5 - ( -3)  x=8 y = -3

 z = ((((8 - x--) - x--) - ++y) - x--)
 (8 - x--)
  8 - 8      x =7 y = -3 
 z = (((0- x--) - ++y) - x--)
 (0- x--)
  0 - 7      x =6 y = -3
 z = (((-7 - ++y) - x--)
 (-7 - ++y)
  -7 - (-2)  x = 6 y = -2
 z = (-5 - x--)
 -5 -6       x =5 y -2
 z = -11

So answer is -11

Date difference with Time in (Perl)

Function validateDateDifference() can validate date difference with time also.

Validation Range is from 1900-01-01 00:00:00 to 2199-12-31 23:59:59


validateDateDifference(“Startdate time”,”Enddate time”,”dateformat”)

date format are : mmddyyyy or ddmmyyyy or yyyymmdd
(this function can support these time formats only)

Start date syntax : mm-dd-yyyy or dd-mm-yyyy or yyyy-mm-dd
you can replace “-” with “.” or “/”
for Ex. mm.dd.yyyy or mm/dd/yyyy
time syntax is : HH:MM:SS
EX. 19:10:59

Test cases :
validateDateDifference(“12.12.2013 12:12:58″,”12.12.2013 12:12:59″,”ddmmyyyy”)
validateDateDifference(“2013-01-31 12:12:58″,”2013-12-02 12:12:59″,”yyyymmdd”)

If you want to validate date only then you can use function validateDateFormat()

validateDateFormat(“date” , “dateformat”)

syntax same as above

If you want to validate time only then you can use function isvalidtime()


time syntax same as above

sub validateDateFormat{
$regexmmddyyyy='^(0[1-9]|1[012])[-/.](0[1-9]|[12][0-9]|3[01])[- /.]((?:19|20|21)\d\d)$';
$regexddmmyyyy='^(0[1-9]|[12][0-9]|3[01])[-/.](0[1-9]|1[012])[- /.]((?:19|20|21)\d\d)$';
$regexyyyymmdd='^((?:19|20|21)\d\d)[- /.](0[1-9]|1[012])[-/.](0[1-9]|[12][0-9]|3[01])$';
$format = shift;
if($format eq 'ddmmyyyy'){
if(eval $date=~$regexddmmyyyy){
$date = $1;
$month = $2;
$year = $3;
if(isvaliddate($date,$month,$year) eq "true"){
return $year.$month.$date; # Valid date
return "false"; # Not a valid date
}elsif($format eq 'mmddyyyy'){
if(eval $date=~$regexmmddyyyy){
$date = $2;
$month = $1;
$year = $3;
if(isvaliddate($date,$month,$year) eq "true"){
return $year.$month.$date; # Valid date
return "false"; # Not a valid date
}elsif($format eq 'yyyymmdd'){
if(eval $date=~$regexyyyymmdd){
$date = $3;
$month = $2;
$year = $1;
if(isvaliddate($date,$month,$year) eq "true"){
return $year.$month.$date; # Valid date
return "false"; # Not a valid date
return "false"; # Not a valid date
## HH:MM:SS is allowed only
sub isvalidtime{
$time = shift;
if(eval $time=~$regexhhmmss){
return "true";
return "false";
sub isvaliddate{
$date = shift;
$month = shift;
$year = shift;
if ($date == 31 and ($month == 4 or $month == 6 or $month == 9 or $month == 11)) {
return "false"; # 31st of a month with 30 days
}elsif ($date >= 30 and $month == 2) {
return "false"; # February 30th or 31st
} elsif ($month == 2 and $date == 29 and not ($year % 4 == 0 and ($year % 100 != 0 or $year % 400 == 0))) {
return "false"; # February 29th outside a leap year
} else {
return "true"; # Valid date
sub validateDateDifference{
$startdate = shift;
$enddate = shift;
$format =shift;
# Trimming dates and time " 20-01-2013 12.58.1 " --> "20-01-2013 12.59.32"
$startdate =~ s/^\s+|\s+$//g;
$enddate =~ s/^\s+|\s+$//g;
$format=~ s/^\s+|\s+$//g;
($startdate, $startdate_time) = split(/ +/, $startdate);
($enddate, $enddate_time) = split(/ +/, $enddate);
$startdate = validateDateFormat($startdate,$format);
if($startdate eq "false"){
return "false"; # invalid date difference
$enddate = validateDateFormat($enddate,$format);
if($enddate eq "false"){
return "false"; # invalid date difference
#converting into YYYYMMDD format
if($enddate == $startdate ){

if(isvalidtime($startdate_time) eq "false"){
print "reached";
return "false";
if(isvalidtime($enddate_time) eq "false"){
print "reached";
return "false";
$startdate_time =~ s/://g;
$enddate_time =~ s/://g;
if($startdate_time < $enddate_time){ return "true"; # Valid date difference }else{ return "false"; # invalid date difference } } elsif($enddate > $startdate ){
return "true"; # Valid date difference
return "false"; # invalid date difference
print 'validateDateDifference("12.12.2013 12:12:58","12.12.2013 12:12:59","ddmmyyyy")\t'.validateDateDifference("12.12.2013 12:12:58","12.12.2013 12:12:59","ddmmyyyy")."\n";
print 'validateDateDifference("12.12.2014 12:12:58","12.12.2014 12:12:12","ddmmyyyy")\t'.validateDateDifference("12.12.2014 12:12:58","12.12.2014 12:12:12","ddmmyyyy")."\n";
print 'validateDateDifference("12.12.2013 12:12:58","12.12.2013 12:12:59","mmddyyyy")\t'.validateDateDifference("12.12.2013 12:12:58","12.12.2013 12:12:59","mmddyyyy")."\n";
print 'validateDateDifference("12.12.2013 12:12:58","12.12.2013 12:12:59","mmmmyyyy")\t'.validateDateDifference("12.12.2013 12:12:58","12.12.2013 12:12:59","mmmmyyyy")."\n";
print 'validateDateDifference("2013-01-31 12:12:58","2013-12-02 12:12:59","yyyymmdd")\t'.validateDateDifference("2013-01-31 12:12:58","2013-12-02 12:12:59","yyyymmdd")."\n";
print 'validateDateDifference("2013-01-31 12:12:58","2013-12-02 12:12:59","yyyymmdd")\t'.validateDateDifference("2013-01-31 12:12:58","2013-12-02 12:12:59","yyyymmdd")."\n";