Skip to content
Merged
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
28 changes: 25 additions & 3 deletions functions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
#!/usr/bin/python
def islandPerimeter(grid):
"""
The solution to today's leetcode challenge.
:type grid: List[List[int]]
:rtype: int
"""

leni = len(grid)
lenj = len(grid[0])

def countCell(i,j):
if not grid[i][j]:
return 0
borders = 4
if i>0 and grid[i-1][j]: borders -= 1
if i<(leni-1) and grid[i+1][j]: borders -= 1
if j<(lenj-1) and grid[i][j+1]: borders -= 1
if j>0 and grid[i][j-1]: borders -= 1
return borders

return sum([countCell(i,j) for i in range(leni) for j in range(lenj)])


"""This program uses scipy to integrate and plot the results of a basic SIR model"""

Expand All @@ -8,7 +30,7 @@
from pylab import *

#Define Constants
Beta=2.0
beta=2.0
gamma=.8
init=array([0.95,0.05,0.0])
finalTime=20.0
Expand All @@ -18,8 +40,8 @@ def derv(x,t):
"""Computes the derv operator for the basic sir model"""

y=zeros(3);
y[0]=-Beta*x[0]*x[1]
y[1]=Beta*x[0]*x[1]-gamma*x[1]
y[0]=-beta*x[0]*x[1]
y[1]=beta*x[0]*x[1]-gamma*x[1]
y[2]=gamma*x[1]
return(y)

Expand Down