Skip to main content

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', 
    (1, 0): 'i', (1, 1): 'w', (1, 2): 'c', (1, 3): 'e', (1, 4): 'x', 
    (2, 0): 'o', (2, 1): 'v', (2, 2): 'g', (2, 3): 'a', (2, 4): 'q', 
    (3, 0): 'n', (3, 1): 'i', (3, 2): 'n', (3, 3): 'i', (3, 4): 't', 
    (4, 0): 't', (4, 1): 'b', (4, 2): 'e', (4, 3): 'a', (4, 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


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.11.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

word_search_puzzle-1.11-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file word-search-puzzle-1.11.tar.gz.

File metadata

  • Download URL: word-search-puzzle-1.11.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.8.1

File hashes

Hashes for word-search-puzzle-1.11.tar.gz
Algorithm Hash digest
SHA256 a9463914f253706ff73a50465809c8296ffa73b7f2ca94d310be696374805d97
MD5 32da896bc483d36c332c1f39b8f31d29
BLAKE2b-256 54154f52b7d80e84fb318bb7383e30ffa76e87386d1bc1e13082189910767c2e

See more details on using hashes here.

File details

Details for the file word_search_puzzle-1.11-py3-none-any.whl.

File metadata

  • Download URL: word_search_puzzle-1.11-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.8.1

File hashes

Hashes for word_search_puzzle-1.11-py3-none-any.whl
Algorithm Hash digest
SHA256 23c9e6a60a83962e319cc48f44ed7593535bd65c1d3d218d0a2f490df114ba36
MD5 aad4f58f039eae0ab2afcde405342db8
BLAKE2b-256 e123df2d9f13c6a07cc496ce6f47d5ce57ed41e779e965f39419df0d3fb0d41f

See more details on using hashes here.

Supported by

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