Skip to content

Instantly share code, notes, and snippets.

View dereknheiley's full-sized avatar

Derek Nheiley dereknheiley

View GitHub Profile
def buyHouse(buyer):
startSearch = date()
while wantAHouse:
listings = getNewHouseListings()
houses = filterByCriteria(listings, beds > 2, garage=True, walkscore > 85, alreadyConsidered=False)
health -= sum( [1 for house in houses if house.price > 1,000,000] )
if health < 1:
findChocolate(buyer)
def solution(N):
#remove trailing zeros
while N%2==0:
N=N>>1
#remove trailing 1
N=N>>1
maxGap=0
def solution(S, P, Q):
N = len(S)
#how many of each are seen
count = [0]*4
#convert everything to ints for simplicity
d = [0]*N
for i in xrange(N):
if S[i] == 'A':
def isPalindrome(input_string):
def _string_iterator():
_len = len(input_string)
for i in xrange(_len / 2):
yield input_string[i], input_string[_len - i - 1]
for c1, c2 in _string_iterator():
if c1 != c2: