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
import memoize from "lodash.meoize";
const MyFunction = (age) => {
return `Your are ${age} years old!`
}
const MyMemoizedFunction = memoize(MyFunction)

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

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) :
# 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))
# 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)
#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)
#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)
#Witness of The Tall People
def witnesses(heights):
max_height = float('-inf')
total = 0
for i in range(len(heights) - 1, -1, -1):
if heights[i] > max_height:
total += 1
max_height = max(heights[i], max_height)
return total
import React from 'react';
import styled, { ThemeProvider } from 'styled-componets';
const theme = {
text: '#ffff',
dark: '#0000'
}
const CustomButton = styled.button`
background-color: ${props => props.theme.dark};
import React from 'react';
import styled from 'styled-componets';
const Button = styled.button`
background: ${props => props.primary ? 'blue': 'white'};
color: ${props => props.primary ? 'white' : 'green}
cursor: pointer;
font-size: 16px;
border-radius: 3px;
border: 2px solid palevioletred;