blob: f929b1dc46b651f818b0d0398cc6a9f2313a5299 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
def solveIt(inputData):
# Modify this code to run your optimization algorithm
# parse the input
lines = inputData.split('\n')
firstLine = lines[0].split()
nodeCount = int(firstLine[0])
edgeCount = int(firstLine[1])
edges = []
for i in range(1, edgeCount + 1):
line = lines[i]
parts = line.split()
edges.append((int(parts[0]), int(parts[1])))
# build a trivial solution
# every node has its own color
solution = range(0, nodeCount)
# prepare the solution in the specified output format
outputData = str(nodeCount) + ' ' + str(0) + '\n'
outputData += ' '.join(map(str, solution))
return outputData
import sys
if __name__ == '__main__':
if len(sys.argv) > 1:
fileLocation = sys.argv[1].strip()
inputDataFile = open(fileLocation, 'r')
inputData = ''.join(inputDataFile.readlines())
inputDataFile.close()
print solveIt(inputData)
else:
print 'This test requires an input file. Please select one from the data directory. (i.e. python solver.py ./data/gc_4_1)'
|