Created
May 3, 2019 09:10
-
-
Save grocid/1bdc70b041df6ab53b5064ce4f3d321e to your computer and use it in GitHub Desktop.
INS'HACK - Hack the code
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
import copy | |
import random | |
def find_coverage(g, G): | |
cnt = 0 | |
for gg in G: | |
if g in gg: | |
cnt += 1 | |
return cnt | |
Gref = [] | |
with open("routes.txt","r") as f: | |
for line in f: | |
lr = line.strip().split(",") | |
Gref.append(lr) | |
Gref.sort(key=len) | |
while True: | |
taps = [] | |
G = copy.copy(Gref) | |
Gp = G[:200] | |
random.shuffle(Gp) | |
G =Gp+G[200:] | |
while len(G) != 0: | |
coverage = {} | |
g = None | |
if random.randint(0, 100) > 3: | |
for g in G[0]: | |
coverage[g] = find_coverage(g, G) | |
max_cov = max(coverage.values()) | |
for g in G[0]: | |
if coverage[g] == max_cov: | |
break | |
else: | |
random.shuffle(G[0]) | |
g = G[0][0] | |
taps.append(g) | |
idx = 0 | |
G.pop(idx) | |
while idx < len(G): | |
if g in G[idx]: | |
G.pop(idx) | |
else: | |
idx += 1 | |
if len(taps) <= 126: | |
break | |
for tap in taps: | |
print tap | |
print len(taps) | |
82006b0b | |
d42ed823 | |
3d6fa6dd | |
ae9bf0c7 | |
f1d2d613 | |
3d3452f2 | |
32be7184 | |
67846f20 | |
20779a55 | |
32696a91 | |
da06c64f | |
366b0fc2 | |
01de1787 | |
05b646cb | |
a656ec74 | |
5daefe0d | |
0f386ce7 | |
9cefa7a2 | |
8c89de99 | |
5070956c | |
453d437e | |
e5a10f35 | |
8c93b33d | |
100284b7 | |
e6608890 | |
dec18abb | |
dc17e12d | |
2a11dff7 | |
1ee2d70f | |
bb7d6e5c | |
7b4e5e8e | |
060679b2 | |
a77b6514 | |
435b85ac | |
859b2713 | |
5923cc6c | |
2da67070 | |
45df9dfc | |
2c45df3b | |
326ceb8a | |
72213ae3 | |
c90eb424 | |
dbffb4f3 | |
763d8f7c | |
71651baa | |
35baf228 | |
d75d5106 | |
4301b2e9 | |
1eb38c6d | |
68deebf4 | |
ed83bae6 | |
8c15eb99 | |
ad493644 | |
57e483e5 | |
628a7eb9 | |
4fe2ab99 | |
1ccb4ad0 | |
6dc19d5b | |
87d74a03 | |
ab16a2fc | |
65aadb0f | |
83c7ddd8 | |
756d687b | |
cb9101fa | |
0f13b66f | |
f8f62aff | |
b36267f7 | |
62d05ae0 | |
c633d389 | |
be83d735 | |
8f97501f | |
94adaf5c | |
917b943f | |
fc55d2bc | |
5cc167e0 | |
bdfe9853 | |
61e4803f | |
ddad739d | |
7e2465d2 | |
0cd1f825 | |
74439dae | |
64685dc0 | |
d126ef39 | |
214c89b0 | |
8417d624 | |
bfb54ff8 | |
3e777083 | |
e1df8c8a | |
ae43a954 | |
0b950b5d | |
de354f47 | |
bcfb104f | |
85ea0d43 | |
abc7a89c | |
fffce5b2 | |
556f8572 | |
9c965aaa | |
286b5ca8 | |
19e34302 | |
912962dd | |
b70a9235 | |
b51e4382 | |
40ee0a0b | |
f0abb6bc | |
2ce01a6d | |
2d036ecb | |
7aeba76a | |
67a6921e | |
2e6ec4fe | |
61cb28ef | |
b5e69d6e | |
a8b8fb5f | |
803958b4 | |
fc3094b2 | |
bdae8a7a | |
e6fb4688 | |
936c9d0a | |
1f30daa4 | |
c41cb9f6 | |
9efd8555 | |
019a4f1c | |
46eef43f | |
bee0fd64 | |
dc98dc28 | |
bc8ef5a3 | |
a350a1ab | |
126 | |
[Finished in 3.2s] | |
INSA{Master_of_0pt1mizatioN} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment