|
Post by B+ on Oct 16, 2018 18:58:29 GMT
Count the number of times BAT appears in the puzzle below, remember it could appear in any of 8 directions.
ABBBBBATBTAABTABTBBB TTTTAATATTTBTATABTAA BBAATTTBBTTAABBAAATT AATBAAAABTTBATBABAAT ABATTBATBTTTATTTTBTT BBTBATABTAAAAATTTTBA BBBATBAABTTTTBBBBABA TABABTTTABAATABTATBT TABBTTBBBBTATBTTTTBT TBAABTBBTAABBTTTAATT BAABBTTTAAABTBATBATA ATBBBABAABTBABTABTBB TTTTAABAAAAATTATBBBA TABTBAABABBABBAABBAA TBATTABABTTTATATTTBT BTBTTTTTBBBATTABAABB BBBTAABTBBATTAATAABT TTATBATTATBATATBBABT TTTBBBBBTBTATABTTBBA TBABBAATATTABTBATBBA
This might be a job for Batman.
|
|
|
Post by B+ on Oct 17, 2018 0:14:14 GMT
Here is what I found in my Halloween bag.
KTIREKITRATECCCRTIAKIRTTTTRRAR CTKRAAKCAIERIECITCRTTCTRKRITCT TTCARTTACIKKIKTRERETIKCTCICRER ERRTTATTTCTCTKIETAITTRKKCIECET AIEATREAIRRIRITRTTTTAKTIEREKTR ATTRATIECTREATTITARETRICKTIATI TTTRERTRTIRTRICKCAEKRITITTKARR TRRIRRETTTRICKTATEAITCCETARTIC RIATTERTKARATTTIRTATRTCRCRTKRE TETCATRTAETREATKTRICKKTREATRCI KTRRTRTCTETRTEKAATCTCIECTRKTCT TKKTTEIRAITTIEERERRITCCTTRRERR CATATRICKKCTKTETIRRTERTKTRCRTA TTTERCATTTKTITRKTAERTEERRTAERE RCIAKERRATARKRRRRCCTCRTIRTETKK TTRACRRCRCTEIRATCCREETRKTKTCRR EEIRITKTCTCARCRTTTKTITTTIRRRCK IIEETKETEARTTATRTRTRTRECTETEET ITREIREETACETECAITKIRKTKTKARTR CRRRTTIRITERTIRERRKATTCTRIRKAR
How many tricks and how many treats can you find with your Word Search code?
|
|
|
Post by B+ on Oct 18, 2018 13:07:50 GMT
Judging from responses at other forums to this challenge, some instructions might be helpful.
First, I did NOT know Rosetta actually had a Word Search challenge, This part of their description was followed in my puzzle: Quote
zigzag probably means start going one direction and then changing course mid-word.
Here is my BASIC strategy for finding words:
For each word in search list 1. Take the first letter and run through the grid of letters for a match. 2. For a matching first letter, check each of 8 directions and see if the length of the word will fit the grid in that direction. 3. If so, build the word from the grid in that direction and length (or check letter by letter and bug out if mismatch). 4. See if it matches the word being searched, if so, count it, display it and/or record the find. 5. Repeat until all words have been searched over the entire grid ie continue with remaining directions then continue with remaining grid, unless you know there is only one word positioned in the puzzle (but my challenge is a twist on the this standard newspaper puzzle).
A BASIC strategy for the 8 directions: I set up two arrays (or use one of vectors). I called them DX() and DY() because they are the changes (D is for Delta which is Geek for change) of position when added to (x, y) coordinate of a location.
A normal word direction (say direction 1) is from left to right due East change X by +1 and Y by 0 DX(1) = 1, DY(1) = 0 SouthEast call direction 2, DX(2) = 1, DY(2) = 1 AKA diagonal down to the right South call direction 3, DX(3) = 0, DY(3) = 1 AKA down vertically SouthWest call direction 4, DX(4) = -1, DY(4) = 1 AKA diagonal down to left ... DX(1) = 1 : DY(1) = 0 DX(2) = 1 : DY(2) = 1 DX(3) = 0 : DY(3) = 1 DX(4) = -1 : DY(4) = 1 DX(5) = -1 : DY(5) = 0 DX(6) = -1 : DY(6) = -1 DX(7) = 0 : DY(7) = -1 DX(8) = 1 : DY(8) = -1
There's a good chunk of the code done for you now!
Now there is another challenge, find the words by rotating and/or reflecting the grid of letters. Sound like fun? Eh, probably not for Beginner's ASIC.
Ha! maybe only B+ thinks that might be fun?
|
|
|
Post by B+ on Nov 9, 2018 15:51:58 GMT
I give up, 94 bats! Here watch a bat fly around the screen as we count them, just hold down the enter button after the first few finds: 'Bat counter from word search.txt for JB [B+=MGA] 2018-10-16 ' Happy Halloween! Here is your trick! ' Treat me with the correct count of BAT
global xy 'for square block of letters xy is one side of square xy = 20 dim L$(xy, xy) DX(1) = 1 : DY(1) = 0 DX(2) = 1 : DY(2) = 1 DX(3) = 0 : DY(3) = 1 DX(4) = -1 : DY(4) = 1 DX(5) = -1 : DY(5) = 0 DX(6) = -1 : DY(6) = -1 DX(7) = 0 : DY(7) = -1 DX(8) = 1 : DY(8) = -1
open "bat count word search.txt" for input as #1 for y = 1 to xy input #1, fline$ for x = 1 to xy L$(x, y) = mid$(fline$, x, 1) next next close #1 call showPuzzle for y = 1 to xy for x = 1 to xy if L$(x, y) = "B" then for d = 1 to 8 'will BAT fit? from "B" at x, y b$ = "" b1 = 2 * DX(d) + x > 0 and 2 * DX(d) + x <= xy b2 = 2 * DY(d) + y > 0 and 2 * DY(d) + y <= xy if b1 and b2 then b$ = "B" : xx = x + DX(d) : yy = y + DY(d) for i = 2 to 3 b$ = b$ + L$(xx, yy) xx = xx + DX(d) : yy = yy + DY(d) next if b$ = "BAT" then 'show our result cls xx = x : yy = y for i = 1 to 3 locate 2 * xx - 1, yy : print L$(xx,yy); xx = xx + DX(d) : yy = yy + DY(d) next batCount = batCount + 1 locate 5, xy + 2 : print "Bat at (";x;", ";y;"), bat count = ";batCount locate 5, xy + 4 : input "OK, press enter when ready... ";wate$ 'call showPuzzle end if end if next end if next next locate 5, xy + 6 : print "Total BATs found = ";batCount end
sub showPuzzle cls locate 1, 1 for y = 1 to xy for x = 1 to xy print L$(x, y);" "; next print next locate 5, xy + 2 : input "OK, press enter when ready... ";wate$ end sub
Easy right? The Trick and Treat puzzle (6 Tricks and 7 Treats) is so poorly built I wrote a puzzle builder app that satisfies Rosetta Code challenge specs and a Word Search Puzzle Editor. Output: 0 1 2 3 4 5 6 7 8 9
0 t a x i e d k R u e 1 s a O y e l a d p e 2 r e b d e s k S b l 3 e p g E e v e w r g 4 k T z a i b t a a T 5 a A e z n a o a i i 6 C m u p g l n l d o 7 y u s O u i e s v h 8 o i l D r t b a r c 9 l r E p i y x i n u
Directions >>>---> 0 = East, 1 = SE, 2 = South, 3 = SW, 4 = West, 5 = NW, 6 = North, 7 = NE
These are the items from unixdict.txt used to build the puzzle:
1) ketone (6, 2) >>>---> 2 2) upbraid (8, 0) >>>---> 2 3) taxied (0, 0) >>>---> 0 4) waals (7, 3) >>>---> 2 5) ova (9, 6) >>>---> 3 6) bed (5, 4) >>>---> 5 7) daley (7, 1) >>>---> 4 8) akers (0, 5) >>>---> 6 9) unix (9, 9) >>>---> 4 10) lit (5, 6) >>>---> 2 11) yip (5, 9) >>>---> 4 12) crab (9, 8) >>>---> 4 13) zeus (2, 4) >>>---> 2 14) glee (9, 3) >>>---> 6 15) egan (1, 2) >>>---> 1 16) viz (5, 3) >>>---> 3 17) ali (5, 5) >>>---> 2 18) muir (1, 6) >>>---> 2 19) loy (0, 9) >>>---> 6 20) bat (2, 2) >>>---> 5 21) rug (4, 8) >>>---> 6 22) hoi (9, 7) >>>---> 6 23) sea (5, 2) >>>---> 1 24) pea (1, 3) >>>---> 6 25) elk (4, 2) >>>---> 7 26) oil (0, 8) >>>---> 0 27) psi (3, 6) >>>---> 3
These are the items from unixdict.txt found embedded in the puzzle:
1) age (3, 4) >>>---> 5 2) aid (8, 4) >>>---> 2 3) akers (0, 5) >>>---> 6 4) ale (6, 1) >>>---> 4 5) ali (5, 5) >>>---> 2 6) ani (7, 5) >>>---> 3 7) arc (7, 8) >>>---> 0 8) bali (5, 4) >>>---> 2 9) bar (6, 8) >>>---> 0 10) bat (2, 2) >>>---> 5 11) bed (5, 4) >>>---> 5 12) ben (6, 8) >>>---> 6 13) big (6, 8) >>>---> 5 14) braid (8, 2) >>>---> 2 15) bye (2, 2) >>>---> 7 16) crab (9, 8) >>>---> 4 17) dale (7, 1) >>>---> 4 18) daley (7, 1) >>>---> 4 19) des (3, 2) >>>---> 0 20) desk (3, 2) >>>---> 0 21) eel (9, 0) >>>---> 2 22) egan (1, 2) >>>---> 1 23) eli (6, 7) >>>---> 7 24) elk (4, 0) >>>---> 1 25) elk (4, 2) >>>---> 7 26) eve (4, 3) >>>---> 0 27) eve (6, 3) >>>---> 4 28) glee (9, 3) >>>---> 6 29) hoi (9, 7) >>>---> 6 30) ian (4, 4) >>>---> 1 31) ieee (4, 4) >>>---> 6 32) ketone (6, 2) >>>---> 2 33) lab (5, 6) >>>---> 6 34) lad (5, 1) >>>---> 0 35) lea (5, 6) >>>---> 1 36) lean (5, 6) >>>---> 1 37) lee (9, 2) >>>---> 6 38) let (7, 6) >>>---> 3 39) lisp (0, 9) >>>---> 7 40) lit (5, 6) >>>---> 2 41) lob (7, 6) >>>---> 5 42) lobe (7, 6) >>>---> 5 43) loy (0, 9) >>>---> 6 44) muir (1, 6) >>>---> 2 45) nag (4, 5) >>>---> 5 46) not (6, 6) >>>---> 6 47) note (6, 6) >>>---> 6 48) oar (6, 5) >>>---> 7 49) oil (0, 8) >>>---> 0 50) one (6, 5) >>>---> 2 51) ova (9, 6) >>>---> 3 52) pea (1, 3) >>>---> 6 53) psi (3, 6) >>>---> 3 54) put (3, 6) >>>---> 1 55) raid (8, 3) >>>---> 2 56) reb (0, 2) >>>---> 0 57) rug (4, 8) >>>---> 6 58) sea (5, 2) >>>---> 1 59) sea (5, 2) >>>---> 3 60) sue (2, 7) >>>---> 6 61) suez (2, 7) >>>---> 6 62) tab (0, 0) >>>---> 1 63) tad (6, 4) >>>---> 1 64) tag (6, 4) >>>---> 3 65) tax (0, 0) >>>---> 0 66) taxi (0, 0) >>>---> 0 67) taxied (0, 0) >>>---> 0 68) tel (5, 8) >>>---> 7 69) til (5, 8) >>>---> 6 70) ton (6, 4) >>>---> 2 71) tone (6, 4) >>>---> 2 72) unix (9, 9) >>>---> 4 73) upbraid (8, 0) >>>---> 2 74) uri (4, 7) >>>---> 2 75) viz (5, 3) >>>---> 3 76) waals (7, 3) >>>---> 2 77) yip (5, 9) >>>---> 4 78) zeus (2, 4) >>>---> 2
|
|