All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > General
Wordates (Posted on 2012-09-03) Difficulty: 2 of 5
Consider a valid English word without hyphens or spaces, which is not a proper noun. Assign the values a=0, b=1, c=2, d=3, e=4, f=5, g=6, h=7, i=8 and j=9.

A date corresponding to a valid English word in consonance with the above assignment in mm/dd/yy format is called a "spell date". For example,the word "deface" generates 34/50/24 which is not a valid date in the mm/dd/yy format, and consequently not a spell date.

(A) Determine the respective first and last spell dates in the period covering January 1, 2001 to December 31, 2100 inclusively.

(B) What would have been the respective answers to (A) if the definition of a spell date involved a dd/mm/yy format instead?

No Solution Yet Submitted by K Sengupta    
Rating: 5.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution | Comment 2 of 7 |

DECLARE FUNCTION isWord! (w$)

CLS

MO = 1: DA = 1: ye = 2001
GOSUB greg.to.jd: jdstart = jd
MO = 12: DA = 31: ye = 2100
GOSUB greg.to.jd: jdend = jd

FOR j = jdstart TO jdend
  jd = j
  GOSUB jd.to.greg
  mm$ = RIGHT$("0" + LTRIM$(STR$(MO)), 2)
  dd$ = RIGHT$("0" + LTRIM$(STR$(DA)), 2)
  yy$ = RIGHT$("0" + LTRIM$(STR$(ye MOD 100)), 2)
  w$ = mm$ + dd$ + yy$
  FOR i = 1 TO LEN(w$)
    MID$(w$, i, 1) = MID$("abcdefghij", VAL(MID$(w$, i, 1)) + 1)
  NEXT i
  IF isWord(w$) THEN
    PRINT mm$; "/"; dd$; "/"; yy$, w$
  END IF
NEXT
PRINT
FOR j = jdstart TO jdend
  jd = j
  GOSUB jd.to.greg
  mm$ = RIGHT$("0" + LTRIM$(STR$(MO)), 2)
  dd$ = RIGHT$("0" + LTRIM$(STR$(DA)), 2)
  yy$ = RIGHT$("0" + LTRIM$(STR$(ye MOD 100)), 2)
  w$ = dd$ + mm$ + yy$
  FOR i = 1 TO LEN(w$)
    MID$(w$, i, 1) = MID$("abcdefghij", VAL(MID$(w$, i, 1)) + 1)
  NEXT i
  IF isWord(w$) THEN
    PRINT dd$; "/"; mm$; "/"; yy$, w$
  END IF
NEXT
PRINT
FOR j = jdstart TO jdend
  jd = j
  GOSUB jd.to.greg
  mm$ = RIGHT$("0" + LTRIM$(STR$(MO)), 2)
  dd$ = RIGHT$("0" + LTRIM$(STR$(DA)), 2)
  yy$ = RIGHT$("0" + LTRIM$(STR$(ye MOD 100)), 2)
  w$ = yy$ + mm$ + dd$
  FOR i = 1 TO LEN(w$)
    MID$(w$, i, 1) = MID$("abcdefghij", VAL(MID$(w$, i, 1)) + 1)
  NEXT i
  IF isWord(w$) THEN
    PRINT yy$; "/"; mm$; "/"; dd$, w$
  END IF
NEXT
PRINT
FOR j = jdstart TO jdend
  jd = j
  GOSUB jd.to.greg
  mm$ = RIGHT$("0" + LTRIM$(STR$(MO)), 2)
  dd$ = RIGHT$("0" + LTRIM$(STR$(DA)), 2)
  yyyy$ = STR$(ye)
  w$ = yyyy$ + mm$ + dd$
  FOR i = 1 TO LEN(w$)
    MID$(w$, i, 1) = MID$("abcdefghij", VAL(MID$(w$, i, 1)) + 1)
  NEXT i
  IF isWord(w$) THEN
    PRINT yyyy$; "/"; mm$; "/"; dd$, w$
  END IF
NEXT
PRINT
                     


END

greg.to.jd:
10100 REM :greg mo/da/ye --> jd at noon
10110 GOSUB jul.to.jd
10120 jd = jd + 2 - INT(cw(1) / 100) + INT(cw(1) / 400)
10130 RETURN
jul.to.jd:
10150 REM :jul mo/da/ye --> jd at noon
10160 cw(0) = MO: cw(1) = ye: IF MO < 3 THEN cw(0) = MO + 12: cw(1) = ye - 1
10170 jd = INT(365.25 * cw(1)) + INT(30.61 * (cw(0) + 1)) + DA + 1720995!
10180 RETURN
jd.to.greg:
10200 REM:noon jd-->greg mo/da/ye
10210 cw(0) = INT((jd - 1867216.25#) / 36524.25)
10220 cw(0) = jd + 1 + cw(0) - INT(cw(0) / 4)
10230 GOTO common.from.jd
jd.to.jul:
10240 REM : noon jd-->jul mo/da/ye
10250 cw(0) = jd
common.from.jd:
10260 cw(0) = cw(0) + 1524
10265 cw(1) = INT((cw(0) - 122.1) / 365.25)
10270 cw(2) = INT(365.25 * cw(1))
10275 cw(3) = INT((cw(0) - cw(2)) / 30.6001)
10280 DA = cw(0) - cw(2) - INT(30.61 * cw(3))
10285 ye = cw(1) - 4716
10290 MO = cw(3) - 1: IF MO > 12 THEN MO = MO - 12: ye = ye + 1
10295 RETURN

FUNCTION isWord (w$)
 n = LEN(w$)
 w1$ = SPACE$(n)
 OPEN "\words\words" + LTRIM$(STR$(n)) + ".txt" FOR BINARY AS #2
 l = LOF(2) / n
 low = 1: high = l
 DO
  mid = INT((low + high) / 2)
  GET #2, (mid - 1) * n + 1, w1$
  IF w1$ = w$ THEN isWord = 1: CLOSE 2: EXIT FUNCTION
  IF w1$ < w$ THEN low = mid + 1:  ELSE high = mid - 1
 LOOP UNTIL low > high
 isWord = 0
 CLOSE 2
END FUNCTION

finds

10/22/04      baccae
02/24/34      accede
10/18/43      babied
10/27/43      bached
02/02/80      acacia

14/03/43      beaded
27/05/43      chafed
18/11/43      bibbed
20/11/43      cabbed
30/11/43      dabbed
02/02/80      acacia
20/11/84      cabbie

showing for part (A)
first: 10/22/04      baccae
last: 02/02/80      acacia

and for part (B)
first: 14/03/43      beaded
last: 20/11/84      cabbie

The program tried for yy/mm/dd and yyyy/mm/dd also, but did not find any results for these formats.


  Posted by Charlie on 2012-09-03 14:41:34
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (12)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information