def test_num_visible_large(self): f = open('ten/data_large.txt') asteroids = create_map(f) v = {s: num_visible(s, asteroids) for s in asteroids} (max_position, count) = max(v.items(), key=lambda (k, v): v) self.assertEqual(max_position, Position(11, 13)) self.assertEquals(count, 210)
def test_vaporized(self): f = open('ten/data_large.txt') asteroids = create_map(f) v = vaporised(Position(11, 13), asteroids) self.assertEqual(v[0], Position(11, 12)) self.assertEqual(v[49], Position(16, 9)) self.assertEqual(v[198], Position(9, 6)) self.assertEqual(v[199], Position(8, 2))
def test_num_visible_puzzle(self): f = open('ten/data_puzzle.txt') asteroids = create_map(f) f.close() v = {s: num_visible(s, asteroids) for s in asteroids} (max_position, count) = max(v.items(), key=lambda (k, v): v) self.assertEqual(max_position, Position(13, 17)) self.assertEquals(count, 269)
def test_create_map(self): f = open('ten/data_short.txt') asteroids = create_map(f) self.assertEqual(asteroids[0].x, 1) self.assertEqual(asteroids[0].y, 0) self.assertEqual(asteroids[1].x, 4) self.assertEqual(asteroids[1].y, 0) self.assertEqual(len(asteroids), 10)
def test_num_visible(self): f = open('ten/data_short.txt') asteroids = create_map(f) v = {s: num_visible(s, asteroids) for s in asteroids} (max_position, count) = max(v.items(), key=lambda (k, v): v) (min_position, count) = min(v.items(), key=lambda (k, v): v) self.assertEqual(max_position.x, 3) self.assertEqual(max_position.y, 4) self.assertEqual(min_position.x, 4) self.assertEqual(min_position.y, 2)
def test_vaporized_puzzle(self): f = open('ten/data_puzzle.txt') asteroids = create_map(f) v = vaporised(Position(13, 17), asteroids) self.assertEqual(v[199], Position(6, 12)) self.assertEqual((v[199].x * 100) + v[199].y, 612)