Skip to content

Commit

Permalink
day 6 two programs
Browse files Browse the repository at this point in the history
  • Loading branch information
yozaam committed Oct 27, 2020
1 parent aa6d772 commit 0ebf03a
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 31 deletions.
13 changes: 13 additions & 0 deletions day6_keyword_args_maximum.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Required concepts: https://www.w3schools.com/python/python_intro.asp unpacking functions
print('Question: function to return max of all keyword arguments')

def findMax(**nums):
val = float('-inf')
name = ''
for n,v in nums.items():
if v > val:
# if the value is smaller update the answer
name,val = n,v
print(name,'is biggest with value ',val)

findMax(n1=3,n4=34)
15 changes: 15 additions & 0 deletions day6_reverse_number_without_string.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Required concepts: https://www.w3schools.com/python/python_intro.asp while loop and maths
print('Question: reverse number without using strings')


def getReverse(num):
res = 0
while num > 0:
# take last digit and put in the front of res
digit = num % 10
num //= 10
res = res * 10 + digit
return res


print(getReverse(1234))
43 changes: 12 additions & 31 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,12 @@
# Required concepts: https://www.w3schools.com/python/python_intro.asp lists and functions

print('Question: Element which is min in row and max in column')
matrix = [[1,2,3],
[4,5,6],
[7,8,9]]

def rowMinColMax(matrix):
rowMin,colMax = [],[]
for row in matrix:
rowMin.append(min(row))
for i in range(len(matrix[0])):
maxi = matrix[0][i]
for j in range(len(matrix)):
maxi = max(maxi,matrix[j][i])
colMax.append(maxi)

#now find the overlap
for i in range(len(matrix)):
for j in range(len(matrix[0])):
if rowMin[i] == colMax[j] == matrix[i][j]:
return matrix[i][j]
return False

print('Answer:')
print(rowMinColMax(matrix))





# Required concepts: https://www.w3schools.com/python/python_intro.asp while loop and maths
print('Question: reverse number without using strings')

def getReverse(num):
res = 0
while num > 0:
# take last digit and put in the front of res
digit = num%10
num //=10
res = res*10 + digit
return res
print(getReverse(1234))

0 comments on commit 0ebf03a

Please sign in to comment.