Disk

A disk is a sized element on a Rod where: 1 <= size <= rod_height

class towers.core.disk.Disk[source]

An immutable representation of a sized disk that sits on a Rod.

static __new__(cls, original_position, height=1)[source]
Parameters:
  • original_position (int) – The position on the Rod that this disks originally sat. Zero = The bottom of the Rod.
  • height (int) – The maximum position of this Disk on a Rod.
Return type:

Disk

Raises:
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:Disk
Raises:See Disk.__new__.
to_json()[source]

Return a json serializable representation of this instance.

Return type:object
validate()[source]

Perform self validation

Raises:
width

Obtain the width of the disk

Return type:int