This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def matrixElementsSum(A): | |
| sum=0 | |
| j=0 | |
| while j<len(A)-1: | |
| j=j+1 | |
| for i in range(len(A[j])): | |
| if A[j-1][i]==0: | |
| A[j][i]=0 | |
| if A[j-1][i]!=0 and j<=len(A)-1 : |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def almostIncreasingSequence(a): | |
| def remov(a,i): | |
| return a[:i]+ a[i+1:] | |
| def creciente(a): | |
| j=0 | |
| while j<len(a)-1 and a[j]<a[j+1]: | |
| j=j+1 | |
| if j==len(a)-1: | |
| return(True) | |
| return (False) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def makeArrayConsecutive2(statues): | |
| m=(max(statues)-min(statues)-len(statues)+1) | |
| return(m) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def shapeArea(n): | |
| if n!=2: | |
| m = 2*(n**2)-2*n+1 | |
| return(m) | |
| else: | |
| return(5) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def adjacentElementsProduct(inputArray): | |
| m=[] | |
| for i in range(len(inputArray)-1): | |
| m.append(inputArray[i]*inputArray[i+1]) | |
| return(max(m)) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def checkPalindrome(inputString): | |
| if inputString==inputString[::-1]: | |
| return(True) | |
| else: | |
| return(False) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def centuryFromYear(year): | |
| m=year/100 | |
| if year%100==0: | |
| return(year/100) | |
| else: | |
| return(int(m)+1) | |