This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def solution(N): | |
#remove trailing zeros | |
while N%2==0: | |
N=N>>1 | |
#remove trailing 1 | |
N=N>>1 | |
maxGap=0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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': |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |