Created
November 4, 2013 18:17
-
-
Save maryrosecook/7306915 to your computer and use it in GitHub Desktop.
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
block_size = 16 | |
blocks = [] | |
a_size = 128 | |
b_size = 32 | |
a = [0, 1, 2] | |
b = [0, 1, 2] | |
print a == b | |
def memoise(fn): | |
memo = {} | |
def runner(): | |
if hash(*args) not in memo: | |
value = fn(*args) | |
memo[hash(*args)] = value | |
return value | |
return runner | |
@memoise | |
def cumulative_file_sizes(file_sizes): | |
cumulative = [] | |
total = 0 | |
for file_size in file_sizes: | |
total += file_size | |
cumulative.append(total) | |
return cumulative | |
# memoised_cumulative_file_sizes = memoise(cumulative_file_sizes) | |
def which_file(block_num, file_sizes): | |
total_file_size = pass # | |
total_so_far = 0 | |
for i, file_size in enumerate(file_sizes): | |
total_so_far += file_size | |
if block_num * block_size <= total_so_far: | |
return i |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment