diff --git a/challengers-list.md b/challengers-list.md index 2fb6f60ea..2f3077d77 100644 --- a/challengers-list.md +++ b/challengers-list.md @@ -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) \ No newline at end of file diff --git a/contributors/ShardulDS/ShardulDS.md b/contributors/ShardulDS/ShardulDS.md new file mode 100644 index 000000000..0a6c414f3 --- /dev/null +++ b/contributors/ShardulDS/ShardulDS.md @@ -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 +--- \ No newline at end of file diff --git a/contributors/ShardulDS/TOH.py b/contributors/ShardulDS/TOH.py new file mode 100644 index 000000000..b63cb8423 --- /dev/null +++ b/contributors/ShardulDS/TOH.py @@ -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") diff --git a/contributors/ShardulDS/gist-solutions.md b/contributors/ShardulDS/gist-solutions.md new file mode 100644 index 000000000..8b56eac33 --- /dev/null +++ b/contributors/ShardulDS/gist-solutions.md @@ -0,0 +1,4 @@ +# Challenge 18 + +[Software Development Topic](https://gist.github.com/ShardulDS/234943fa902a5a2f94a4397db2120a34) +[Code snippet](https://gist.github.com/ShardulDS/d2bfa0b9fdd7a21a19cf2a63fa312a47) \ No newline at end of file