Skip to content

Instantly share code, notes, and snippets.

View LarryKarani's full-sized avatar
😀
Life is too short to write bad code

Larry karani LarryKarani

😀
Life is too short to write bad code
View GitHub Profile
#NB used python3
#2 Create a simple calculator
def eval_helper(expression, index=0):
result=0
op='+'
while index < len(expression):
char=expression[index]
if char.isdigit():
if op == '+':
result += int(char)
#NB used python 3
# 3 Maximum In A stack
class MaxStack:
def __init__(self):
self.elements = []
self.maximums = []
def push(self, val):
self.elements.append(val)
# 4 Add two numbers as a linked list
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
class Solution(object):
def addTwoNumbers(self, l1, l2):
result = ListNode(0)
# 5 Number of ways to Climb Stairs
def fib(n):
if n <= 1:
return n
return fib(n-1) + fib(n-2)
def staircase(n):
return fib(n + 1)
print(staircase(5))
def isMagicSquare( mat) :
# calculate the sum of
# the prime diagonal
s = 0
for i in range(0, N) :
s = s + mat[i][i]
# the secondary diagonal
s2 = 0
for i in range(0, N) :

Description Explain what you have changed, and why.

How can This be tested

  • Clone the repo
  • Setup project according to Readme.md
  • checkout to branch ``

Type of change

import memoize from "lodash.meoize";
const MyFunction = (age) => {
return `Your are ${age} years old!`
}
const MyMemoizedFunction = memoize(MyFunction)