Skip to main content
Commonmark migration
Source Link

#The Challenge

The Challenge

#Example Test Cases

Example Test Cases

#Rules

Rules

#The Challenge

#Example Test Cases

#Rules

The Challenge

Example Test Cases

Rules

Post Closed as "Duplicate" by mbomb007 code-golf
removed GOOSE
Source Link
Beefster
  • 10k
  • 34
  • 97

The result would be [DOG, DUCK, GOOSE, PUMPKIN]

The result would be [DOG, DUCK, GOOSE, PUMPKIN]

The result would be [DOG, DUCK, PUMPKIN]

Tweeted twitter.com/StackCodeGolf/status/992756911354368001
Post Reopened by lynn code-golf
Post Closed as "Duplicate" by lynn code-golf
Source Link
Beefster
  • 10k
  • 34
  • 97

Word Search on a Torus

#The Challenge

Given a list of words and a grid of letters, your job is to determine which of the given words can be found on the grid in all 8 directions (forward, backward, up, down, and the 4 diagonal directions), much like a word search. The grid is toroidal, so the grid wraps around on the edges. Letters can be reused with this wrap-around property.

Wrapping around for diagonals behaves as you might expect. On a 4x6 grid going diagonally down and right, you would expect movement to look like this:

9 . 5 . 1 .
. . . 6 . 2
3 . . . 7 .
. 4 . . . 8

For an example of a wrap-around reuse word:

S E A H O R

Would be able to make SEAHORSE

#Example Test Cases

Given this grid and the word list [ANT, COW, PIG]:

A N T
W C O
P G I

The result would be [ANT, COW, PIG]


Given this grid and the word list [CAT, DOG, DUCK, GOOSE, PUMPKIN]:

N O O D M E
O I O C U U
P G K O T C
K A U P S K

The result would be [DOG, DUCK, GOOSE, PUMPKIN]


Given this grid and the word list [TACO, BEEF, PORK]:

T A C B
A P O R
K E E F
B F C P

The result would be an empty list


Given this grid and the word list [ACHE, ASK, BAD, BOOK, COOK, CROW, GAS, GOOD, LESS, MARK, MASK, MEAL, SAME, SEAHORSE, SELL, SHOW, SLACK, WOOD]:

G S L A C K 
H A E S R O
C M S K O O
A K S D W B

The result would be [ASK, BOOK, COOK, CROW, GAS, GOOD, LESS, MASK, SEAHORSE, SHOW, SLACK]


Given this grid and a list of all English words that are at least 3 letters long:

A R T U P
N T U B O
E S R O H
Q E T I U
E A T D P

The result would be [AEQ, AES, ANE, ART, ARTS, ATRIP, BOID, BON, BREE, BUD, BUT, DUB, DUE, DUET, EAN, EAR, EAT, EER, EST, HES, HIT, HOP, HOR, HORS, HORSE, HUP, NAE, NOB, NOBUT, ONT, OOT, OPP, ORS, OUR, OUT, PAR, PART, PAT, PEA, PEAT, PEE, PEER, PIR, POH, PUT, QAT, QUI, QUIT, QUITE, RAP, REE, RIP, RIPA, RTI, RUT, SEA, SEAR, STD, STR, STRA, STRAE, SUU, TAA, TAE, TAP, TAPIR, TEE, TIU, TOO, TRA, TRAP, TRI, TRIP, TUB, TUP, TUR, UDI, UIT, URE, UTE]

#Rules

  • No exploiting standard loopholes
  • This is , so shortest code wins
  • Input and output may be in any convenient format
  • You may assume that both the grid and the words list will use only capital letters
  • The output order of the words does not matter
  • You do not have to, but may, filter out duplicates