Skip to main content

Make awesome Word Search puzzles.

Project description

Word-Search-Generator

Word-Search-Generator is a Python module for generating fun Word Search Puzzles.

Like most of my programming endeavors, Word-Search-Generator was born out of necessity. I needed an easy way to generate a bunch of word search puzzles for kid's food menus at the day job.

🤦‍♂️ Does the world need this? Probably not.
⏰ Did I spend way too much time on it? Yep!
✅ Does it come in handy? Heck yeah!
👍 Did I have fun making it? Absofreakinglutly!

Installation

Install Word-Search-Generator with pip:

$ pip install word-search-generator

Usage

Just import the WordSearch class from the package, supply it with a list of words and you're set. 🧩

from word_search_generator import WordSearch

puzzle = WordSearch("dog, cat, pig, horse, donkey, turtle, goat, sheep")

👀 Wanna see it? puzzle.show()

** WORD SEARCH **

B T Z L K J C G E H
X O N D G S W X M B
W H P V O E H Q D N
K G D I S G D C J G
C J Y R G W F A H O
M K O X N U K T F A
C H T U R T L E I T
D O N K E Y H C R M
V R T U X G O L W H
H J D G S H E E P Y

Find these words: CAT, DOG, DONKEY, GOAT, HORSE, PIG, SHEEP, TURTLE
* Words can go NE, E, SE, and S.

Puzzle words can be provided as a string variable or directly as above. Words can be separated by spaces, commas, or new lines and Word-Search-Generator will sort them out for you.

🤷‍♂️ Can't finding all the words? Try, puzzle.key.

{'TURTLE': {'start': (7, 3), 'dir': 'E'},
 'PIG': {'start': (3, 3), 'dir': 'SE'},
 'HORSE': {'start': (7, 2), 'dir': 'NE'},
 'GOAT': {'start': (4, 10), 'dir': 'S'},
 'DOG': {'start': (2, 4), 'dir': 'SE'},
 'DONKEY': {'start': (8, 1), 'dir': 'E'},
 'SHEEP': {'start': (10, 5), 'dir': 'E'},
 'CAT': {'start': (4, 8), 'dir': 'S'}}

You can also show the key with the puzzle with puzzle.show(key=True).

** WORD SEARCH **

B T Z L K J C G E H
X O N D G S W X M B
W H P V O E H Q D N
K G D I S G D C J G
C J Y R G W F A H O
M K O X N U K T F A
C H T U R T L E I T
D O N K E Y H C R M
V R T U X G O L W H
H J D G S H E E P Y

Find these words: CAT, DOG, DONKEY, GOAT, HORSE, PIG, SHEEP, TURTLE
* Words can go NE, E, SE, and S.

Answer Key: CAT S @ (4, 8), DOG SE @ (2, 4), DONKEY E @ (8, 1), GOAT S @ (4, 10), HORSE NE @ (7, 2), PIG SE @ (3, 3), SHEEP E @ (10, 5), TURTLE E @ (7, 3)

ℹ️ The output answer key uses a 1-based index as that's more familiar with non-programmers. First number is the row, second is the column. Directions are cardinal from first letter to last. The stored puzzle.key is 0-based.

🍰 Too easy? Up the difficulty level with puzzle.level = 3.

** WORD SEARCH **

Q B O I U A D G I P S I L N
V G U Z G O N C V C O Q D T
R I S B G O D U W M G V K R
K X O H W P A Z D J U H E T
H T B K R Y K T O X N O L Y
F I G E P D Q Z N W Y R T A
T B R H W R M U K O J S R S
O S X N F I J W E N X E U W
G A U S X T G N Y V A F T Y
I T O W J I V P A T J G O W
O B I Y D S E C L W C V T R
I H E O Q E P F J A K H C I
F Y W Z H Z Y L T L R U T A
I Z U S T M Q V O K W F E F

Find these words: CAT, DOG, DONKEY, GOAT, HORSE, PIG, SHEEP, TURTLE
* Words can go N, NE, E, SE, S, SW, W, and NW.

😓 Too hard? Go the easy route with puzzle.level = 1.

Settings

Word-Search-Generator offers two main options for puzzle generation, level and size.

# Set the difficulty level to 2
puzzle.level = 2

# Set the puzzle size to 25
puzzle.size = 25

It's easy to set setting when creating a puzzle too...

words = "dog, cat, pig, horse, donkey, turtle, goat, sheep"
puzzle = WordSearch(words, level=3, size=25)

⚠️ Anytime puzzle settings are adjusted, an entirely new puzzle will be generated!

Difficulty Level

The difficulty level controls whether words can go forward or backward, the cardinal direction they can go, and the size of the puzzle (unless size is explicitly set). Difficulty level defaults to 2.

  • Level 1 (Easy): Words can go forward in directions EAST (E), or SOUTH (S). Puzzle size is small by default.
  • Level 2 (Intermediate): Words can go forward in directions NORTHEAST (NE), EAST (E), SOUTHEAST (SE), or (S). Puzzle size is medium by default.
  • Level 3 (Expert): Words can go forward and backward in directions NORTH (N), NORTHEAST (NE), EAST (E), SOUTHEAST (SE), SOUTH (S), SOUTHWEST (SW), WEST (W), or NORTHWEST (NW). Puzzle size is large by default.

Puzzle Size

By default, the puzzle (characters) size is determined by the amount of words provided and the difficulty level. Need a puzzle an exact size, override the default with puzzle.size = x (integer >= 10). All puzzles are square so size` will be the width and height.

** WORD SEARCH **

P I G O Z D U M Y D A F C N
T F L Q T P X I Q O W L A W
B P D K U Y M W Z N G S T B
L C L O R O Q G A K O H U P
M G S Z T J R N U E A E M H
Y T R I L W E Q S Y T E F N
I N K U E X D C U D X P B A
B F B F P V K I J P O E Y S
A L N I L H F G R S W Q M R
X Y Q E S C V W B E J X F K
Z D S T A J E X U C Y M I J
L I H G X W U N S D O G K E
S W D W C D G K A U N B T H
P M F V T W J L H O R S E P

Find these words: CAT, DOG, DONKEY, GOAT, HORSE, PIG, SHEEP, TURTLE
* Words can go E, and S.

⚠️ All provided words may not fit a specified puzzle size!

Editing Puzzle Words

Word-Search-Generator makes it easy to edit the words in the current puzzle.

🤦‍♂️ Leave out a word?

puzzle.add_words("new, words, to, add")

❌ Need to remove a word?

puzzle.remove_words("words, to, delete")

🗑 Wanna replace all words?

puzzle.replace_words("replace, current, words, with, new, words")

⚠️ When words are added, removed, or replaced, an entirely new puzzle will be generated!

Saving Puzzles

Word-Search-Generator can save puzzles as PDF and CSV files.

💾 Save a PDF to a specific directory with default filename.

puzzle.save(path="~/Desktop", format='pdf')
'.../Desktop/Word Search 2021-01-01T000000.pdf'

💾 Save a CSV with to the current directory with a specific filename.

puzzle.save(path="puzzle.csv", format='csv')
'.../projects/word-search/puzzle.csv'

ℹ️ Using the Word-Search-Generator CLI Integration and redirections in your terminal you can also save the puzzle to a text file.

$ word-search -w dog, cat, pig, horse -k > puzzle.txt

📁 View Sample Files: Word-Search PDF, Word-Search CSV, Word-Search TXT

CLI Integration

Word-Search-Generator works in your terminal too! 🙌

$ word-search -h
usage: word-search [-h] [-w WORDS [WORDS ...]] [-l {1,2,3}] [-s SIZE] [-k] [-t] [-e {csv,pdf}] [-p PATH]

Generate a Word Search Puzzles!

optional arguments:
  -h, --help            show this help message and exit
  -w WORDS [WORDS ...], --words WORDS [WORDS ...]
                        words to hide in the puzzle
  -l {1,2,3}, --level {1,2,3}
                        difficulty level (1) beginner, (2) intermediate, (3) expert
  -s SIZE, --size SIZE  puzzle size >=10
  -k, --key             show answer key
  -t, --tabs            use tabs as character separator
  -e {csv,pdf}, --export {csv,pdf}
                        export puzzle as 'csv' or 'pdf' file
  -p PATH, --path PATH  export path for '-e', '--export' flag

💻 Generate a puzzle.

$ word-search -w works, in, the, terminal, too

💻 Generate a puzzle 20 characters wide with difficulty level 1.

$ word-search -w works, in, the, terminal, too -l 1 -s 20

💻 Generate a puzzle and save as a pdf.

$ word-search -w works, in, the, terminal, too -e pdf -p ~/Desktop

💻 Generate a puzzle and save as a csv.

$ word-search -w works, in, the, terminal, too -e csv -p ~/Desktop/puzzle.csv

ℹ️ You can also use words from a file...

$ word-search -w "$(cat words.txt)"

This really came in handy for those kid's food menus. I was able to take a folder full of .txt documents with themed words and generate dozens of level 1 Word Search Puzzles at exactly 15 characters in size super fast...

$ for f in ~/.../words*.txt; word-search -w "$(cat $f)" -l 1 -s 15 -e pdf -p ~/.../puzzles/"$(basename $f)".pdf; done;
Puzzle saved: ~/.../puzzles/words-theme01.txt
...
Puzzle saved: ~/.../puzzles/words-theme99.txt

Resources

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

word-search-generator-1.0.1.post0.tar.gz (16.3 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file word-search-generator-1.0.1.post0.tar.gz.

File metadata

  • Download URL: word-search-generator-1.0.1.post0.tar.gz
  • Upload date:
  • Size: 16.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.2

File hashes

Hashes for word-search-generator-1.0.1.post0.tar.gz
Algorithm Hash digest
SHA256 e0760fe85f916c4b413c67f469d5bddcc30f103da8b930074eff50e08e9fe4cc
MD5 7c7a85a52e9079f19ce6ee9cdd939452
BLAKE2b-256 2dc540c0f603009f8fc4f596f7f7d2659eff43a5823bcf7efc9f2f7f1dd8e19b

See more details on using hashes here.

File details

Details for the file word_search_generator-1.0.1.post0-py3-none-any.whl.

File metadata

  • Download URL: word_search_generator-1.0.1.post0-py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.2

File hashes

Hashes for word_search_generator-1.0.1.post0-py3-none-any.whl
Algorithm Hash digest
SHA256 c70bd7b2e358550a8de6af71f169bcfc05285c73a1ff792e0358e12375b8ed97
MD5 3f5d7ba9648225810f0a9f0fcaa92fdd
BLAKE2b-256 6f0f71d15242b11b89d2f2fb6a82c524799e284c7105e6785cf4de045f10489c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page