functions

Tu sa nachádzajú funkcie, ktoré sa vedia hodiť počas hladanie hesiel a netreba ich tým pádom nanovo programovať.

from susi_lib.functions import *
# takto sa importujú všetky funkcie odtiaľto

Contains some useful functions

class susi_lib.functions.functions.Encoding(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Enum class to specify encoding for encode().

BRAILLE = 2

Encode to braille

MORSE = 1

Encode to morse

NUMBERS = 4

Encode to numbers

SEMAPHORE = 3

Encode to semaphore

susi_lib.functions.functions.decode(string: str) str[source]

Decodes a given value.

Supported encodings are Braille, Numbers, Morse and Semaphore. Encoding should be the same as the strings returned by __str__() method of classes in susi_lib.types.

Raises:

TypeError when invalid parameter types are passed

Parameters:

string (str) – The string to decode

Returns:

Decoded string

Return type:

str

susi_lib.functions.functions.encode(string: str, encoding: Encoding, base: int = 10) str[source]

Encode the given string into desired encoding

Parameters:
  • string (str) – The string to encode (should contain only alphabetical chars and spaces)

  • encoding (Encoding) – Desired encoding, see Encoding

  • base (int) – The base of the number system (2, 10, 16), needed only for Encoding.NUMBERS

Returns:

Encoded string

Return type:

str

susi_lib.functions.functions.find_anagrams(word: str, word_list: list[str]) list[str][source]

Function for finding anagrams of a word from a specified list.

Raises:

TypeError when invalid parameter types are passed

Parameters:
  • word (str) – Word for which it tries to find anagrams

  • word_list (list[str]) – List of strings against which it compares permutations of word

Returns:

List of anagrams for word

Return type:

list[str]

susi_lib.functions.functions.is_palindrome(word) bool[source]

Checks if a value is a palindrome (is the same from front and back).

Parameters:

word – value to check, it needs to have __getitem__(), __len__() and __ne__()

Returns:

True if it is a palindrome, False when it is not

Return type:

bool

susi_lib.functions.functions.unique_letters(word: str) bool[source]

Function for checking if given word contains only unique letters.

Raises:

TypeError when word is not str

Parameters:

word (str) – Word to check

Returns:

True if it contains unique letters, False otherwise

Return type:

bool