Rods

Rods is a collection of Rod‘s, one representing the start, end and intermediary rods for the tower.

class towers.core.rods.Rods[source]

A collection of 3 Rod’s that form the Tower.

Parameters:
  • start (Rod) – The rod containing the disks at their start position.
  • end (Rod) – The rod containing the disks at their end position.
  • tmp (Rod) – The intermediary rod.
  • height (int) – The height of the tower.
Raises:
__bool__()[source]

A Rods is considered True if it contains any disks on any rods.

Return type:bool
__copy__()[source]

Return a shallow copy of this instance.

Return type:Rods
__deepcopy__(*a)[source]

Return a deep copy of this instance.

Return type:Rods
__iter__()[source]

Iterate over all the rods.

Return type:Rod
__len__()[source]

Obtain the number of Rods.

Return type:int
__nonzero__()[source]

A Rods is considered non-zero if it contains any disks on any rods.

Return type:bool
classmethod from_json(d)[source]

Return a class instance from a json serializable representation.

Parameters:d (str|dict) – The json or decoded-json from which to create a new instance.
Return type:Rods
Raises:See Rods.__new__.
height

Retrieve the height of the rods (ie: max number of disks each one can hold).

Return type:int
to_json()[source]

Return a json serializable representation of this instance.

Return type:object
validate()[source]

Perform self validation.

Raises: