def main (filename): inputFile = open(filename, 'r') # list of lists, indexed like matrix. rows then cols grid = [ [ int(d) for d in list(s.strip()) ] for s in inputFile.readlines() ] inputFile.close() return "".join([str(d) for d in bigops.sum_sequence(grid)])
def test_sum_sequence_resolve_carries(self): """An interesting side effect of the implementation, is that carries can be stored in the digit cells as numbers bigger than 10, and propagated afterwards.""" result = 56088 convolution = [ 4, 13, 28, 27, 18 ] self.assertEqual(result, bigops.list_to_int(\ bigops.sum_sequence(\ [ convolution, [0] ] ) ) )
def test_sum_sequence_trivial(self): self.assertEqual(0, bigops.list_to_int(bigops.sum_sequence([]))) for num in xrange(0, 1000, 13): self.assertEqual(num, bigops.list_to_int(\ bigops.sum_sequence(\ [bigops.int_to_list(num)] ) ) )
def test_sum_sequence_triangle(self): n = 100 # 100th triangle number self.assertEqual(seriesutils.partial_sum(n), bigops.list_to_int(\ bigops.sum_sequence(\ ( bigops.int_to_list(x) for x in xrange(1, n+1) ) ) ) )
def main (lastNum): # calculate factorial digits = bigops.sum_sequence( gen_sequence(lastNum) ) return bigops.list_to_str(digits[-10:])