Skip to content

Conversation

bharatagarwal
Copy link
Contributor

This is an opinionated suggestion, feel free to not merge.

I think the fact that height == 0 is the base case for the function is implicit, and maps slightly separately to the way the text talks about the base case.

By making a return explicit when height == 0, it helps to visualise how the call stack is being used.

@robot-dreams
Copy link
Collaborator

I agree this is a bit confusing. Is it also worth changing the text, which currently says "A tower of one disk will be our base case." (the base case should be a tower of zero disks)?

Alternatively, should we have something like:

if height == 1:
    move_disk(from_pole, to_pole)
else:
    move_tower(...)
    move_disk(...)
    move_tower(...)

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.

2 participants