Last active
April 2, 2020 12:23
-
-
Save ruchej/133310a1232da7062b754e0499d7c54c to your computer and use it in GitHub Desktop.
This file contains 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
table = [(593, 586, 487, '800400'), (594, 593, 487, '800800'), (595, 594, 487, '060000'), (596, 593, 487, '800800'), (592, 591, 487, '060000'), (578, 575, 487, '800800'), (581, 580, 487, '800800'), (570, 488, 487, '010100'), (627, 487, 487, '040000'), (571, 570, 487, '050000'), (572, 570, 487, '050000'), (573, 570, 487, '050000'), (574, 570, 487, '050000'), (575, 570, 487, '800400'), (576, 575, 487, '800800'), (580, 570, 487, '800400'), (579, 578, 487, '060000'), (591, 588, 487, '800800'), (582, 581, 487, '060000'), (583, 580, 487, '800800'), (584, 583, 487, '060000'), (585, 487, 487, '110101'), (586, 585, 487, '010100'), (587, 586, 487, '050000'), (588, 586, 487, '800400'), (589, 588, 487, '800800'), (590, 589, 487, '060000'), (577, 576, 487, '060000'), (569, 565, 487, '050000'), (617, 615, 487, '050000'), (618, 615, 487, '050000'), (619, 487, 487, '040000'), (620, 487, 487, '040000'), (621, 620, 487, '800500'), (622, 621, 487, '800800'), (625, 624, 487, '060000'), (624, 621, 487, '800800'), (614, 611, 487, '050000'), (626, 487, 487, '040000'), (560, 549, 487, '010300'), (628, 627, 487, '800500'), (629, 628, 487, '800800'), (630, 629, 487, '060000'), (631, 628, 487, '800800'), (632, 631, 487, '060000'), (623, 622, 487, '060000'), (607, 606, 487, '800800'), (598, 585, 487, '010300'), (599, 585, 487, '010100'), (600, 599, 487, '050000'), (601, 599, 487, '800400'), (602, 601, 487, '800800'), (603, 602, 487, '060000'), (604, 601, 487, '800800'), (616, 615, 487, '050000'), (606, 599, 487, '800400'), (615, 585, 487, '010200'), (608, 607, 487, '060000'), (609, 606, 487, '800800'), (610, 609, 487, '060000'), (611, 585, 487, '010200'), (612, 611, 487, '050000'), (613, 611, 487, '050000'), (597, 596, 487, '060000'), (605, 604, 487, '060000'), (508, 507, 487, '060000'), (568, 565, 487, '050000'), (517, 494, 487, '800400'), (516, 515, 487, '060000'), (515, 514, 487, '800800'), (514, 513, 487, '800500'), (513, 512, 487, '060000'), (512, 506, 487, '800800'), (511, 510, 487, '060000'), (521, 520, 487, '800800'), (509, 508, 487, '800500'), (519, 518, 487, '060000'), (507, 506, 487, '800800'), (506, 494, 487, '800400'), (505, 504, 487, '060000'), (504, 503, 487, '800800'), (503, 502, 487, '800500'), (502, 501, 487, '060000'), (501, 495, 487, '800800'), (500, 499, 487, '060000'), (499, 498, 487, '800800'), (510, 509, 487, '800800'), (533, 494, 487, '800400'), (522, 521, 487, '060000'), (523, 517, 487, '800800'), (524, 523, 487, '060000'), (525, 524, 487, '800500'), (526, 525, 487, '800800'), (527, 526, 487, '060000'), (528, 517, 487, '800800'), (529, 528, 487, '060000'), (530, 529, 487, '800500'), (518, 517, 487, '800800'), (532, 531, 487, '060000'), (562, 560, 487, '050000'), (534, 533, 487, '800800'), (535, 534, 487, '060000'), (536, 535, 487, '800500'), (537, 536, 487, '800800'), (538, 537, 487, '060000'), (539, 533, 487, '800800'), (540, 539, 487, '060000'), (520, 519, 487, '800500'), (496, 495, 487, '800800'), (531, 530, 487, '800800'), (556, 555, 487, '050000'), (546, 545, 487, '800500'), (498, 497, 487, '800500'), (548, 547, 487, '060000'), (549, 493, 487, '620000'), (550, 549, 487, '010300'), (551, 550, 487, '050000'), (552, 550, 487, '050000'), (553, 550, 487, '050000'), (497, 496, 487, '060000'), (555, 549, 487, '010300'), (545, 544, 487, '060000'), (557, 555, 487, '050000'), (558, 555, 487, '050000'), (559, 555, 487, '050000'), (561, 560, 487, '050000'), (563, 560, 487, '050000'), (564, 560, 487, '050000'), (565, 549, 487, '010300'), (566, 565, 487, '050000'), (567, 565, 487, '050000'), (554, 550, 487, '050000'), (488, 487, 487, '111101'), (495, 494, 487, '800400'), (494, 493, 487, '010300'), (493, 489, 487, '500201'), (492, 489, 487, '040600'), (491, 489, 487, '040600'), (490, 489, 487, '040100'), (547, 546, 487, '800800'), (489, 488, 487, '230100'), (544, 533, 487, '800800'), (541, 540, 487, '800500'), (542, 541, 487, '800800'), (543, 542, 487, '060000')] | |
unitpos = 560 | |
def get_tree_parents(unitpos, table): | |
"""Возвращает список связанных родителей""" | |
tree = [] | |
el = [i for i in table if i[0] == unitpos] | |
if el: | |
tree.extend(el) | |
tree.extend(get_tree_parents(el[0][1], table)) | |
return tree | |
else: | |
return tree |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment