Ted Roche wrote on 2016-07-18:
Hey, spoiler alert!
Guess you'll need to subscribe to Gene's newspapers to find the solution.
By inspection, I can come up with at least one date closer than that.
So, let's think about the *algorithm* to solve the problem in minimal time, rather than the answer.
There are many ways to code searching for this. Here is my solution:
LOCAL ldDate, lnStart, lnStop lnStart = SECONDS() ldDate = DATE() llFound = .F. DO WHILE NOT llFound ldDate = ldDate + 1 llFound = NOT HasDuplicates(ldDate) ENDDO lnStop = SECONDS() ?ldDate ?lnStop - lnStart
FUNCTION HasDuplicates LPARAMETERS tdTestDate LOCAL lcTestDate, llDuplicate lcTestDate = DTOS(tdTestDate) llDuplicate = .F. FOR ii = 0 TO 9 IF LEN(CHRTRAN(lcTestDate, TRANSFORM(ii), ""))<7 llDuplicate = .T. EXIT ENDIF NEXT RETURN llDuplicate ENDFUNC
Tracy Pearson PowerChurch Software