Skip to content

Commit fab5a02

Browse files
authored
Merge pull request Aishanipach#32 from proPrateekSahu/main
Python Project Which solve Tower Of Honi Problem
2 parents 9d1450f + 2a26f81 commit fab5a02

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

MatrixMultiplier.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
3+
# taking a 3x3 matrix
4+
A = [[12, 7, 3],
5+
[4, 5, 6],
6+
[7, 8, 9]]
7+
8+
# take a 3x4 matrix
9+
B = [[5, 8, 1, 2],
10+
[6, 7, 3, 0],
11+
[4, 5, 9, 1]]
12+
13+
# result will be 3x4
14+
result = [[sum(a * b for a, b in zip(A_row, B_col))
15+
for B_col in zip(*B)]
16+
for A_row in A]
17+
#Now displaying the result
18+
for r in result:
19+
print(r)

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,6 @@ Feel free to add basic python scripts/programs that helped you learn python. I h
3636
19. [Insertion Sort](https://github.com/musaibbatghar/Beginners-Python-Projects/blob/main/Insertion_Sort.py) - [Musaib Batghar](https://github.com/musaibbatghar)
3737
20. [Snake game](https://github.com/Aishanipach/Beginners-Python-Projects/compare/main...meanshkumar:Beginners-Python-Projects:main?expand=1)- [Ansh Kumar](https://github.com/meanshkumar)
3838
21. [Merge_Sort](https://github.com/proPrateekSahu/Beginners-Python-Projects/blob/main/MergeSort.py) - [Prateek Kumar Sahu](https://github.com/proPrateekSahu)
39+
22. [Binary_Search](https://github.com/proPrateekSahu/Beginners-Python-Projects/blob/main/BinarySearch) - [Prateek Kumar Sahu](https://github.com/proPrateekSahu)
40+
23. [TowerOfHoni](https://github.com/proPrateekSahu/Beginners-Python-Projects/blob/main/towerOfHoni.py) - [Prateek Kumar Sahu](https://github.com/proPrateekSahu)
41+
24. [Matrix_Multiplier](https://github.com/proPrateekSahu/Beginners-Python-Projects/blob/main/MatrixMultiplier.py) - [Prateek Kumar Sahu](https://github.com/proPrateekSahu)

towerOfHoni.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Recursive Code
2+
3+
def TowerOfHanoi(n , source, destination, auxiliary):
4+
if n==1:
5+
print ("Move disk 1 from source",source,"to destination",destination)
6+
return
7+
TowerOfHanoi(n-1, source, auxiliary, destination)
8+
print ("Move disk",n,"from source",source,"to destination",destination)
9+
TowerOfHanoi(n-1, auxiliary, destination, source)
10+
11+
#Test Input
12+
n = 4
13+
TowerOfHanoi(n,'A','B','C')
14+
# Consider A B and C as the names of rods
15+

0 commit comments

Comments
 (0)