Skip to content

Instantly share code, notes, and snippets.

View anirudhjayaraman's full-sized avatar
🏠
Working from home

Anirudh Jayaraman anirudhjayaraman

🏠
Working from home
View GitHub Profile
@anirudhjayaraman
anirudhjayaraman / sherlockandthebeast.py
Created December 12, 2015 01:49
Solution to HackerRank Problem - Sherlock and the Beast
#!/bin/python
import sys
def combinations_sum(n):
k = n/2
combs = []
answers = []
for i in range(0,k+1):
a,b = i, n-i
@anirudhjayaraman
anirudhjayaraman / countInversions.py
Created October 23, 2015 13:29
Counting the Number of Inversions In An Array
# load contents of text file into a list
# numList
NUMLIST_FILENAME = "IntegerArray.txt"
inFile = open(NUMLIST_FILENAME, 'r')
with inFile as f:
numList = [int(integers.strip()) for integers in f.readlines()]
count = 0
@anirudhjayaraman
anirudhjayaraman / julyTemps.txt
Created October 22, 2015 08:15
July Temperatures: Highs and Lows
Boston July Temperatures
-------------------------
Day High Low
------------
1 91 70
2 84 69
3 86 68
4 84 68
@anirudhjayaraman
anirudhjayaraman / withoutNumPy.py
Last active October 22, 2015 08:12
List Manipulation Without NumPy
import pylab
def loadfile():
inFile = open('julyTemps.txt', 'r')
high =[]; low = []
for line in inFile:
fields = line.split()
if len(fields) < 3 or not fields[0].isdigit():
pass
else:
@anirudhjayaraman
anirudhjayaraman / withNumPy.py
Last active October 29, 2015 22:47
Manipulating Lists with NumPy
import pylab
import numpy as np
def loadFile():
inFile = open('julyTemps.txt')
high = [];vlow = []
for line in inFile:
fields = line.split()
if len(fields) != 3 or 'Boston' == fields[0] or 'Day' == fields[0]:
continue
@anirudhjayaraman
anirudhjayaraman / mergesort.py
Last active August 5, 2020 19:51
Merge Sort Algorithm Implimentation
# Code for the merge subroutine
def merge(a,b):
""" Function to merge two arrays """
c = []
while len(a) != 0 and len(b) != 0:
if a[0] < b[0]:
c.append(a[0])
a.remove(a[0])
else:
@anirudhjayaraman
anirudhjayaraman / estherDufloDecrypted.txt
Created October 16, 2015 11:14
Decrypted Esther Duflo
5r ii*?} @?_ t@jie @e!f| i?qf^ f?rfq ir 5r ii*
i?q|e r|i? ? t?_i?fq@d ,_f?rf rei4 @? k? q @* i*r)
, qfe4f?|
,q| fe # i
t
abstract
between 4<:6 and 4<:;/ the indonesian government constructed over 94/333 primar|
schools throughout the countr|1 this is one of the largest school construction programs on
record1 i evaluate the eect of this program on education and wages b| combining dierences
across regions in the number of schools constructed with dierences across cohorts induced
@anirudhjayaraman
anirudhjayaraman / estherDuflo.txt
Last active October 16, 2015 11:13
Encrypted Esther Duflo
5U LL*?} @?_ w@MLh @h!i| L?ti^ i?Uit Lu 5U LL*
L?t|h U|L? ? W?_L?it@G ,_i?Ui uhL4 @? N? t @* L*U)
, Tih4i?|
,t| ih # L
W
Devwudfw
Ehwzhhq 4<:6 dqg 4<:;/ wkh Lqgrqhvldq Jryhuqphqw frqvwuxfwhg ryhu 94/333 sulpdu|
vfkrrov wkurxjkrxw wkh frxqwu|1 Wklv lv rqh ri wkh odujhvw vfkrro frqvwuxfwlrq surjudpv rq
uhfrug1 L hydoxdwh wkh hhfw ri wklv surjudp rq hgxfdwlrq dqg zdjhv e| frpelqlqj glhuhqfhv
dfurvv uhjlrqv lq wkh qxpehu ri vfkrrov frqvwuxfwhg zlwk glhuhqfhv dfurvv frkruwv lqgxfhg
@anirudhjayaraman
anirudhjayaraman / estherDuflo.py
Created October 16, 2015 11:05
Deciphering Text From Research Paper
from string import *
# create decipher dictionary
l = letters[:26]
decipher = "".join([l[(i+3)%26] for i in range(len(l))])
decipher = dict(zip(decipher,l))
# open and read encrypted text
filename = 'estherDuflo.txt'
f = open(filename, 'rw')
@anirudhjayaraman
anirudhjayaraman / karatsuba_pseudocode.txt
Created October 13, 2015 17:02
Pseudocode for Karatsuba Multiplication Algorithm
procedure karatsuba(num1, num2)
if (num1 < 10) or (num2 < 10)
return num1*num2
/* calculates the size of the numbers */
m = max(size_base10(num1), size_base10(num2))
m2 = m/2
/* split the digit sequences about the middle */
high1, low1 = split_at(num1, m2)
high2, low2 = split_at(num2, m2)
/* 3 calls made to numbers approximately half the size */