haha lol f o On Tue, Sep 6, 2011 at 8:51 AM, Yogesh Yadav <medu...@gmail.com> wrote:
> @all : > Thanks for correcting me. > > > On Tue, Sep 6, 2011 at 3:41 AM, Piyush Grover > <piyush4u.iit...@gmail.com>wrote: > >> Here's the pseudo code. I hope it should work. >> >> >> d = <date-string> (d[0]d[1]) >> m = <month-string> (m[0]m[1]) >> y = <year-string> (y[0]y[1]y[2]y[3]) >> dd = d; >> mm = m; >> yy = y; >> >> while(1){ >> if (strcmp(concat(dd,mm), reverse(yy)) >> return(dd,mm,yy) >> else if(isValidDateMonth(yy[3]yy[2], yy[1]yy[0] ,yy){ >> if(yy[3]yy[2] > d && yy[1]yy[0] >= m) >> return(yy[3]yy[2], yy[1]yy[0], yy); >> else if(yy[1]yy[0] > m) >> return(yy[3]yy[2], yy[1]yy[0], yy); >> }else if( !(01< yy[1]yy[0] <= 12) ){ >> t = (int) (yy + 1000)/1000 ; >> yy[0] = t; >> yy[1] = 0; >> yy[2] = 0; >> yy[3] = 1; >> return(10, strcat(0, t), yy); >> }else{ >> numdays = getDays(yy[1]yy[0], yy); >> if(yy[3]yy[2] > numDays) >> t = (yy+10)/10 >> t *= 10; >> yy = t+1; >> mm = yy[1]yy[0]; >> dd = yy[3]yy[2]; >> } >> } >> >> >> isValidDateMonth(d, m, y){ >> if(m belongsTo(jan, mar, may, jul, aug, oct, dec) && 0 < d <= 31) >> return true; >> else if(m belongsTo(apr, jun, sep, nov) && 0 < d <=30) >> return true; >> >> else if(m belongsTo(feb)){ >> if(0 < d <= 28) >> return true; >> else if(d == 29 && isLeapYear(y)) >> return true >> else return false; >> }else >> return false; >> } >> >> getDays(m, y){ >> >> if(m belongsTo(jan, mar, may, jul, aug, oct, dec)) >> return 31; >> else if(m belongsTo(apr, jun, sep, nov)) >> return 30; >> >> else if(m belongsTo(feb)){ >> if(isLeapYear(y)) >> return 29; >> else return 28; >> >> } >> >> >> } >> On Mon, Sep 5, 2011 at 11:50 PM, Piyush Grover <piyush4u.iit...@gmail.com >> > wrote: >> >>> One thing i would like to know is >>> >>> 01/02/2011 needs to be considered or 1/02/2011. >>> >>> thnx >>> >>> >>> On Mon, Sep 5, 2011 at 11:48 PM, Neha Singh >>> <neha.ndelhi.1...@gmail.com>wrote: >>> >>>> @yogesh: its stiil not correct. There r many test cases where ur >>>> solution will fail >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Algorithm Geeks" group. >>>> To post to this group, send email to algogeeks@googlegroups.com. >>>> To unsubscribe from this group, send email to >>>> algogeeks+unsubscr...@googlegroups.com. >>>> For more options, visit this group at >>>> http://groups.google.com/group/algogeeks?hl=en. >>>> >>> >>> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to algogeeks@googlegroups.com. >> To unsubscribe from this group, send email to >> algogeeks+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.