Skip to content
This repository was archived by the owner on Aug 30, 2023. It is now read-only.

Challenge 5 - 22 #1090

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion challengers-list.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# List of challengers
1. [Mrinal](https://github.com/mrinal1224)
2. [Shivay](https://github.com/shivaylamba)
3. [Raghav](https://github.com/raghavdhingra)
3. [Shardul](https://github.com/ShardulDS)
4. [Raghav](https://github.com/raghavdhingra)
8 changes: 8 additions & 0 deletions contributors/ShardulDS/ShardulDS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
name: Shardul Sajnekar
github_user_name: ShardulDS
url_of_github_issue: https://github.com/scaleracademy/scaler-september-open-source-challenge/issues/102#issue-1358537066
my-favourite-programming-language: Python
your_hosted_github_pages_link: shardulds.github.io
your_hosted_github_pages_repository_link: https://github.com/ShardulDS/ShardulDS.github.io
---
25 changes: 25 additions & 0 deletions contributors/ShardulDS/TOH.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""Tower of Hanoi is a mathematical puzzle where we have three rods
(A, B, and C) and N disks. Initially, all the disks are stacked in decreasing
value of diameter i.e., the smallest disk is placed on the top and they are on
rod A. The objective of the puzzle is to move the entire stack to another rod
(here considered C), obeying the following simple rules:
- Only one disk can be moved at a time.
- Each move consists of taking the upper disk from one of the stacks and
placing it on top of another stack i.e. a disk can only be moved if it
is the uppermost disk on a stack.
- No disk may be placed on top of a smaller disk."""


def TowerOfHanoi(n, from_rod, to_rod, aux_rod, y):
if n == 0:
return y
y = TowerOfHanoi(n - 1, from_rod, aux_rod, to_rod, y)
print("Move disk", n, "from rod", from_rod, "to rod", to_rod)
y += 1
y = TowerOfHanoi(n - 1, aux_rod, to_rod, from_rod, y)
return y


if __name__ == "__main__":
temp = TowerOfHanoi(int(input("No. of disks: ")), "A", "C", "B", 0)
print(f"{temp} moves")
4 changes: 4 additions & 0 deletions contributors/ShardulDS/gist-solutions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Challenge 18

[Software Development Topic](https://gist.github.com/ShardulDS/234943fa902a5a2f94a4397db2120a34)
[Code snippet](https://gist.github.com/ShardulDS/d2bfa0b9fdd7a21a19cf2a63fa312a47)