| Conditions | 7 |
| Total Lines | 19 |
| Code Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | from itertools import combinations |
||
| 12 | def checkio(data): |
||
| 13 | lands = [] |
||
| 14 | for i, v in enumerate(data): |
||
| 15 | for col, value in enumerate(v): |
||
| 16 | if value == 1: |
||
| 17 | lands.append([(i, col)]) |
||
| 18 | merged = True |
||
| 19 | while merged: |
||
| 20 | merged = False |
||
| 21 | for i, j in combinations(lands, 2): |
||
| 22 | ret = merge(i, j) |
||
| 23 | if ret != [i, j]: |
||
| 24 | lands.remove(i) |
||
| 25 | lands.remove(j) |
||
| 26 | lands.append(ret) |
||
| 27 | merged = True |
||
| 28 | break |
||
| 29 | lands = [len(i) for i in lands] |
||
| 30 | return sorted(lands) |
||
| 31 | |||
| 59 |