This file contains 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 can_map(numbers, letters): | |
# print "in can_map for {} and {}".format(numbers, letters) | |
if ( | |
len(numbers) > len(letters) or | |
numbers.count('0') > letters.count('A') or | |
('B' in letters and '0' not in numbers) | |
): | |
return False | |
if len(numbers) == 1: |
This file contains 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
from unittest import TestCase, main | |
def bin_s(search_space, thing): | |
low = 0 | |
high = len(search_space) - 1 | |
while low + 1 < high: | |
# this is python 2, so will round down | |
mid = (high - low) / 2 + low |
This file contains 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
import sys | |
def split_vert(vert): | |
""" strips surrounding brackets, splits on comma, casts to int | |
""" | |
return [int(c) for c in vert[1:-1].split(',')] | |
class Hole(object): |