.. _f-einsteinprolog: module ``special.einstein_prolog`` ================================== .. inheritance-diagram:: ensae_teaching_cs.special.einstein_prolog Short summary +++++++++++++ module ``ensae_teaching_cs.special.einstein_prolog`` This programs solves `Einstein's riddle `_ ou en Français `Intégramme `_. The algorithm is based on logic and its `clause `_. :githublink:`%|py|8` Classes +++++++ +--------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------+ | class | truncated documentation | +======================================================================================+====================================================================================================================+ | :class:`Enigma ` | this class solves the enigma | +--------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------+ | :class:`Rule ` | This class defines a constraint of the problem or a clause (see `http://en.wikipedia.org/wiki/Clause_(logic)`) ... | +--------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------+ | :class:`RuleAvant ` | p1 before p2 | +--------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------+ | :class:`RuleEnsemble ` | permutation of the elements of a category | +--------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------+ | :class:`RuleEquivalence ` | p1 equivalent to p2 | +--------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------+ | :class:`RulePosition ` | p1 at position | +--------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------+ | :class:`RuleVoisin ` | p1 and p2 are neighbors | +--------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------+ Functions +++++++++ +-----------------------------------------------------------------------------+---------------------------------------------------------------------+ | function | truncated documentation | +=============================================================================+=====================================================================+ | :func:`permutation ` | Compute all permutations of set [[ 1, 2, ..., nb ]]. Example for 3: | +-----------------------------------------------------------------------------+---------------------------------------------------------------------+ Methods +++++++ +-----------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+ | method | truncated documentation | +===========================================================================================================+================================================================================================================+ | :py:meth:`__init__ ` | we describe the enigma using the classes we defined above | +-----------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+ | :py:meth:`__init__ ` | | +-----------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+ | :py:meth:`__init__ ` | | +-----------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+ | :py:meth:`__init__ ` | | +-----------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+ | :py:meth:`__init__ ` | | +-----------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+ | :py:meth:`__init__ ` | | +-----------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+ | :py:meth:`__init__ ` | | +-----------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+ | :py:meth:`__str__ ` | usual | +-----------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+ | :py:meth:`__str__ ` | display | +-----------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+ | :py:meth:`__str__ ` | display | +-----------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+ | :py:meth:`__str__ ` | display | +-----------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+ | :py:meth:`__str__ ` | display | +-----------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+ | :py:meth:`__str__ ` | display | +-----------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+ | :py:meth:`__str__ ` | display | +-----------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+ | :meth:`combine ` | combine two clauses, two cases : 1. nothing in common or everything in common --> concatenation of clauses ... | +-----------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+ | :meth:`combine ` | combine two clauses, two cases : 1. nothing in common or everything in common --> concatenation of clauses ... | +-----------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+ | :meth:`combine ` | combine two clauses, two cases : 1. nothing in common or everything in common --> concatenation of clauses ... | +-----------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+ | :meth:`combine ` | combine two clauses, two cases : 1. nothing in common or everything in common --> concatenation of clauses ... | +-----------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+ | :meth:`combine ` | combine two clauses, two cases : 1. nothing in common or everything in common --> concatenation of clauses ... | +-----------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+ | :meth:`combine ` | combine two clauses, two cases : 1. nothing in common or everything in common --> concatenation of clauses ... | +-----------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+ | :meth:`combine_cross_sets ` | combines two sets of clauses | +-----------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+ | :meth:`combine_cross_sets ` | combines two sets of clauses | +-----------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+ | :meth:`combine_cross_sets ` | combines two sets of clauses | +-----------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+ | :meth:`combine_cross_sets ` | combines two sets of clauses | +-----------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+ | :meth:`combine_cross_sets ` | combines two sets of clauses | +-----------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+ | :meth:`combine_cross_sets ` | combines two sets of clauses | +-----------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+ | :meth:`find ` | finds a clause in the different sets of clause (houses, colors, ...) | +-----------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+ | :meth:`genere ` | Generates all possible clauses (list of lists) (l [0][0] et l [0][1]) ou (l [1][0] et l [1][1]), a clause ... | +-----------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+ | :meth:`genere ` | overrides method ``genere`` | +-----------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+ | :meth:`genere ` | overrides method ``genere`` | +-----------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+ | :meth:`genere ` | overrides method ``genere`` | +-----------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+ | :meth:`genere ` | overrides method ``genere`` | +-----------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+ | :meth:`genere ` | overrides method ``genere`` | +-----------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+ | :meth:`solve ` | Solves the enigma by eploring in deepness, the method is recursive | +-----------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+ Documentation +++++++++++++ .. automodule:: ensae_teaching_cs.special.einstein_prolog :members: :special-members: __init__ :show-inheritance: