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

Home > General > Word Problems
20 Word Lattice I (Posted on 2013-11-25) Difficulty: 3 of 5

No Solution Yet Submitted by brianjn    
No Rating

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

DECLARE SUB place (which!)
CLEAR , , 25000
DIM SHARED word(20) AS STRING * 5, grid(9, 9) AS STRING * 1, used(20)
FOR i = 1 TO 20: READ word(i): NEXT
DATA dance,donor,dress,enter,fight
DATA fleas,flood,hauls,hoist,rival
DATA shear,short,since,steel,their
DATA tough,tread,trial,truss,trust

DIM SHARED coord(20, 4), max
DATA 1,1,1,5
DATA 1,5,1,9
DATA 1,1,5,1
DATA 1,5,5,5
DATA 1,9,5,9
DATA 1,1,5,5
DATA 1,5,5,1
DATA 1,5,5,9
DATA 1,9,5,5
FOR i = 1 TO 9
 READ coord(i, 1), coord(i, 2), coord(i, 3), coord(i, 4)
 coord(i + 9, 1) = coord(i, 1) + 4
 coord(i + 9, 2) = coord(i, 2)
 coord(i + 9, 3) = coord(i, 3) + 4
 coord(i + 9, 4) = coord(i, 4)
NEXT
coord(19, 1) = 9: coord(19, 2) = 1
coord(19, 3) = 9: coord(19, 4) = 5
coord(20, 1) = 9: coord(20, 2) = 5
coord(20, 3) = 9: coord(20, 4) = 9

FOR row = 1 TO 9
FOR col = 1 TO 9
grid(row, col) = " "
NEXT
NEXT

CLS

place 1

PRINT max

END

SUB place (which)
  DIM sg$(5)
  IF which > max THEN max = which
  r1 = coord(which, 1)
  c1 = coord(which, 2)
  r5 = coord(which, 3)
  c5 = coord(which, 4)
  FOR i = 1 TO 20
   IF used(i) = 0 THEN
    used(i) = 1
    IF LEFT$(word(i), 1) = grid(r1, c1) OR grid(r1, c1) = " " THEN
    IF RIGHT$(word(i), 1) = grid(r5, c5) OR grid(r5, c5) = " " THEN
     deltaRow = SGN(r5 - r1): deltaCol = SGN(c5 - c1)
    IF MID$(word(i), 3, 1) = grid(r1 + 2 * deltaRow, c1 + 2 * deltaCol) OR grid(r1 + 2 * deltaRow, c1 + 2 * deltaCol) = " " THEN
      FOR j = 1 TO 5
        sg$(j) = grid(r1 + (j - 1) * deltaRow, c1 + (j - 1) * deltaCol)
        grid(r1 + (j - 1) * deltaRow, c1 + (j - 1) * deltaCol) = MID$(word(i), j, 1)
      NEXT
      IF which = 20 THEN
        FOR row = 1 TO 9
        FOR col = 1 TO 9
          IF grid(row, col) = " " THEN PRINT "-"; :  ELSE PRINT grid(row, col);
        NEXT
        PRINT
        NEXT
        PRINT
       ELSE
        place which + 1
      END IF
      FOR j = 1 TO 5
         grid(r1 + (j - 1) * deltaRow, c1 + (j - 1) * deltaCol) = sg$(j)
      NEXT

    END IF
    END IF
    END IF
    used(i) = 0
   END IF
  NEXT
END SUB

finds

fightough
ll-rrr-ao
o-e-u-u-i
oa-asl-ss
dresshort
ao-iht-hr
n-n-e-e-i
cc-oai-ea
enterival

  Posted by Charlie on 2013-11-25 17:56:11
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 (3)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

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