You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

36 lines
650 B

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
point_mask = 0b11100000
points = [
(75, 32),
(111, 213),
(79, 33),
(1, 33),
(80, 35),
(12, 254),
(215, 78),
(211, 121)
]
x0, y0 = (78, 33)
tmp_out_mask = 0
cur_pt_mask = 1
min_dist = 0xFF
if __name__ == "__main__":
for x, y in points:
if not cur_pt_mask & point_mask:
cur_pt_mask <<= 1
continue
dist = abs(x - x0) + abs(y - y0)
if dist < min_dist:
min_dist = dist
tmp_out_mask = cur_pt_mask
elif dist == min_dist:
tmp_out_mask |= cur_pt_mask
cur_pt_mask <<= 1