Ejemplo n.º 1
0
    water_count = 0
    still_water = 0
    for w in water:
        if min_y <= w.y <= max_y:
            water_count += 1
            if water[w] == '~':
                still_water += 1

    # for y in range(min_y, max_y + 1):
    #     for x in range(min_x-50, max_x + 50):
    #         if Point(x, y) in water:
    #             water_count += 1

    # print_state(clay, water, min_x, max_x, min_y, max_y)

    if still:
        return still_water
    else:
        return water_count


if __name__ == '__main__':
    points = parse_real_input('input.txt')
    r = solve_17(points)
    print('Water squares: {}'.format(r))

    points = parse_real_input('input.txt')
    r = solve_17(points, still=True)
    print('Still water squares: {}'.format(r))

    # 37530, 38472, 38451
 def test_edge_case_2(self):
     points = parse_real_input(path(__file__, 'edge-cases/2.txt'))
     r = solve_17(points)
     self.assertEqual(628, r)
 def test_input(self):
     points = parse_real_input(path(__file__, 'test-input.txt'))
     r = solve_17(points)
     self.assertEqual(57, r)
 def test_input_2(self):
     points = parse_real_input(path(__file__, 'test-input.txt'))
     r = solve_17(points, still=True)
     self.assertEqual(29, r)