Word Search Puzzle Generator
Project description
Word Search Puzzle Generator
Introduction
The mission of this package is to generate a word search puzzle. The requirements are a list of the word and the dimensions of the puzzle.
For example:
- Given list of words
['Cat', 'Bear', 'Tiger', 'Lion']
- Generated panel:
# _________________________
# | [L] w m e [r] |
# | [i] w [C] [e] x |
# | [o] v [g] [a] q |
# | [n] [i] n i [t] |
# | [T] [B] [e] [a] [r] |
# -------------------------
panel.cells = {
(0, 0): 'l', (0, 1): 'w', (0, 2): 'm', (0, 3): 'e', (0, 4): 'r',
(0, 0): 'i', (0, 1): 'w', (0, 2): 'c', (0, 3): 'e', (0, 4): 'x',
(0, 0): 'o', (0, 1): 'v', (0, 2): 'g', (0, 3): 'a', (0, 4): 'q',
(0, 0): 'n', (0, 1): 'i', (0, 2): 'n', (0, 3): 'i', (0, 4): 't',
(0, 0): 't', (0, 1): 'b', (0, 2): 'e', (0, 3): 'a', (0, 4): 'r',
}
- With the corresponding hidden words:
{
"words": [
{
"value": "cat",
"positions": [
{ "r": 1, "c": 2 },
{ "r": 2, "c": 3 },
{ "r": 3, "c": 4 }
]
},
{
"value": "bear",
"positions": [
{ "r": 4, "c": 1 },
{ "r": 4, "c": 2 },
{ "r": 4, "c": 3 },
{ "r": 4, "c": 4 }
]
},
{
"value": "tiger",
"positions": [
{ "r": 4, "c": 0 },
{ "r": 3, "c": 1 },
{ "r": 2, "c": 2 },
{ "r": 1, "c": 3 },
{ "r": 0, "c": 4 }
]
},
{
"value": "lion",
"positions": [
{ "r": 0, "c": 0 },
{ "r": 1, "c": 0 },
{ "r": 2, "c": 0 },
{ "r": 3, "c": 0 }
]
}
]
}
Install
You can install it using pip tool word-search-puzzle.
Generate a puzzle
All what you need is de define a list of words and provide the dimensions of the panel. Please make sure that the number and the length of the words fit the dimensions of the panel.
from word_search_puzzle.utils import display_panel
from word_search_puzzle.algorithms import create_panel
words = ['Cat', 'Bear', 'Tiger', 'Lion']
result = create_panel(height=5, width=5, words_value_list=words)
print('Attempts: {}'.format(result.get('attempts')))
print('Solution took: {} ms'.format(result.get('elapsed_time')))
display_panel(result.get('panel'))
# Output:
# Attempts: 2
# Solution took: 31 ms
#
# l w m e r
# i w c e x
# o v g a q
# n i n i t
# t b e a r
Project details
Release history Release notifications | RSS feed
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-puzzle-1.6.tar.gz
(7.0 kB
view hashes)
Built Distribution
Close
Hashes for word_search_puzzle-1.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0712339eb1347e60d2d5f7f31453509b67132dc232c808d00d75e34eecc0ca49 |
|
MD5 | e44928b66240c91a1c95a7d10579d27b |
|
BLAKE2b-256 | ed427e8e79d544467d0f0fbfe760f46f40578a36c3cc302607e1955cfadd13e7 |