Implement greedy solution. Reaches 35/80, 56 needed to pass.

This commit is contained in:
2020-01-05 20:48:51 -05:00
parent 42611d79a5
commit 590e6713d1
3 changed files with 209 additions and 6 deletions

View File

@@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-
from collections import namedtuple
from facility import solve_it
import math
Point = namedtuple("Point", ['x', 'y'])
@@ -11,7 +12,7 @@ Customer = namedtuple("Customer", ['index', 'demand', 'location'])
def length(point1, point2):
return math.sqrt((point1.x - point2.x)**2 + (point1.y - point2.y)**2)
def solve_it(input_data):
def solve_it_example(input_data):
# Modify this code to run your optimization algorithm
# parse the input
@@ -20,7 +21,7 @@ def solve_it(input_data):
parts = lines[0].split()
facility_count = int(parts[0])
customer_count = int(parts[1])
facilities = []
for i in range(1, facility_count+1):
parts = lines[i].split()
@@ -63,8 +64,6 @@ def solve_it(input_data):
return output_data
import sys
if __name__ == '__main__':
import sys
if len(sys.argv) > 1: