Skip to content

Conversation

@Naman-Vasudev
Copy link

@Naman-Vasudev Naman-Vasudev commented Oct 21, 2025

Describe your change:

This pull request adds a new algorithm that converts a closed Hamiltonian
tour (path) into its ordinal representation based on a fixed reference
order of cities. Each position in the resulting list represents the
1-indexed position of the corresponding city in the reference list,
which shrinks as each city is removed — ensuring a unique and reversible
representation.

Key Features:

  • Implements ordinal_representation_closed() with descriptive variable names
  • Handles closed tours (last city conceptually connects back to the first)
  • Fully PEP-8 compliant (≤ 79 chars per line)
  • Includes doctests verified via python -m doctest -v
  • Uses modern Python type hints (list[str], int)
  • Includes a reference URL for background context

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Add or change doctests?
  • Documentation change?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All function and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms include at least one URL that points to Wikipedia or another similar explanation.
  • If this pull request resolves one or more open issues then the description above includes the issue number(s) with a closing keyword: "Fixes #ISSUE-NUMBER".

@algorithms-keeper algorithms-keeper bot added tests are failing Do not merge until tests pass and removed tests are failing Do not merge until tests pass labels Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant