| Conditions | 4 |
| Total Lines | 16 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | def convert_bin(ip): |
||
| 13 | def checkio(data): |
||
| 14 | bin_data = [] |
||
| 15 | for i in data: |
||
| 16 | bin_data.append(convert_bin(i)) |
||
| 17 | |||
| 18 | # find the longest match for all bin string |
||
| 19 | mask_length = 0 |
||
| 20 | while mask_length <= 32: |
||
| 21 | if len(set([i[mask_length] for i in bin_data])) == 1: |
||
| 22 | mask_length += 1 |
||
| 23 | else: |
||
| 24 | break |
||
| 25 | |||
| 26 | # 'cut off' the unmasked part |
||
| 27 | summaried_bin = bin_data[0][:mask_length] + '0' * (32 - mask_length) |
||
| 28 | return convert_dec(summaried_bin) + '/' + str(mask_length) |
||
| 29 | |||
| 45 |