Skip to content

xpuz.td ¤

Custom types for type annotation in the source code of xpuz.

CrosswordData ¤

Bases: TypedDict

The JSON serialised definitions and info of a base crossword.

Parameters:

Name Type Description Default
definitions Dict[str, str]

The crossword's definitions.

required
info Dict[str, Union[str, int, None]]

The crossword's info.

required

CrosswordInfo ¤

Bases: TypedDict

A crossword's information.

Example
    {
        "total_definitions": 23,
        "difficulty": 3,
        "symbol": "0x1f331",
        "name": "Biology",
        "translated_name": "Biologie",
        "category": "science"
    }

Parameters:

Name Type Description Default
total_definitions int

The total amount of definitions available for the crossword.

required
difficulty int

An integer ranging from 0-3 (Easy, Medium, Hard, Extreme)

required
symbol str

A hexadecimal stored in a string, representing the crossword's symbol. This value is converted to an integer at runtime.

required
name str

The crossword's english name.

required
translated_name str

The crossword's translated name.

required
category str

The crossword's category (Geography, Computer Science, Mathematics, Science, or User))

required

IPuzV2 ¤

Bases: TypedDict

The ipuz v2 structure (JSON).

Parameters:

Name Type Description Default
version str

The version of the ipuz format, stored as a url. Defaults to ipuz.org/v2

required
kind List[str]

The puzzle format. Defaults to crossword#1

required
origin str

A link to the puzzle's origin. Default to the xpuz repository

required
author str

The puzzle's author.

required
date str

The puzzle's date of creation.

required
title str

The puzzle's title.

required
difficulty str

The puzzle's difficulty. Not the same as the inbuilt xpuz difficulties.

required
dimensions Dict[str, int]

The dimensions of the puzzle.

required
puzzle List[List[Union[int, None]]]

The puzzle itself.

required
solution List[List[Union[str, None]]]

The solution to the puzzle.

required
clues Dict[str, List[List[Union[int, str]]]]

The puzzle's clues.

required

create classmethod ¤

create(
    version: str = "http://ipuz.org/v2",
    kind: List[str] = ["http://ipuz.org/crossword#1"],
    origin: str = PROJECT_URL,
    author: str = "xpuz Crossword Generator",
    **kwargs: Dict[str, Any]
) -> IPuzV2

Return an instance of IPuzV2 with the standard parameters already defined through the method's default arguments.

Parameters:

Name Type Description Default
version str

The puzzle's version.

'http://ipuz.org/v2'
kind List[str]

The puzzle's kind.

['http://ipuz.org/crossword#1']
origin str

The puzzle's source of creation.

PROJECT_URL
author str

The puzzle's author.

'xpuz Crossword Generator'
**kwargs Dict[str, Any]

Remaining arguments that are covered in IPuzV2

{}
Source code in src/xpuz/td.py
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
@classmethod
def create(
    cls,
    version: str = "http://ipuz.org/v2",
    kind: List[str] = ["http://ipuz.org/crossword#1"],
    origin: str = PROJECT_URL,
    author: str = "xpuz Crossword Generator",
    **kwargs: Dict[str, Any],
) -> "IPuzV2":
    """Return an instance of `IPuzV2` with the standard parameters already
    defined through the method's default arguments.

    Args:
        version: The puzzle's version.
        kind: The puzzle's kind.
        origin: The puzzle's source of creation.
        author: The puzzle's author.
        **kwargs: Remaining arguments that are covered in
                  [IPuzV2](td.md#xpuz.td.IPuzV2)
    """
    return cls(
        version=version, kind=kind, origin=origin, author=author, **kwargs
    )

Placement ¤

Bases: TypedDict

A dictionary specifying the placement information of word at pos in the grid.

Parameters:

Name Type Description Default
word str

The word.

required
direction Union[ACROSS, DOWN]

The direction of the word.

required
pos Tuple[int, int]

The position of the word in (row, column) form.

required
intersections Union[List[None], List[Tuple[int, int]]]

The intersecting points that word has with a grid array in (row, column) form.

required