From 4ee070a3053a391b27faf96a9ba676fdc5258745 Mon Sep 17 00:00:00 2001 From: JLo'w Date: Thu, 11 Feb 2016 19:55:30 +0100 Subject: [PATCH] Use append() method for lists --- read.py | 45 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/read.py b/read.py index f77592e..99cd4e7 100644 --- a/read.py +++ b/read.py @@ -1,5 +1,34 @@ #Read the input file +X = 0 # Nb rows +Y = 0 # Nb columns +D = 0 # Nb drones +T = 0 # Deadline +M = 0 # Maximum load +P = 0 # Nb products +W = 0 # Nb warehouses +C = 0 # Nb customers + +Dp = []; # Positions of drones +# (x, y) +Di = []; # Items of drones +# {product number: qt} +Dd = []; # Turn avaibility of drone +# int + +Pw = []; # Weight of products +# int + +Wp = []; # Positions of warehouses +# (x, y) +Wi = []; # Items of warehouses +# {product number: qt} + +Cp = []; # Positions of customers +# (x, y) +Ci = []; # Needs of customers +# {product number: qt} + def Read_input_file(file): f = open(file, 'r') @@ -17,7 +46,7 @@ def Read_input_file(file): line = f.readline() info = line.split(' ') for i in range(0, P): - Pw[i] = int(info[i]) + Pw.append(int(info[i])) line = f.readline() W = int(line) @@ -25,13 +54,13 @@ def Read_input_file(file): for i in range(0, W): line = f.readline() info = line.split(' ') - Wp[i] = (int(info[0]), int(info[1])) + Wp.append((int(info[0]), int(info[1]))) line = f.readline() info = line.split(' ') productQ = {} - for j in range(1, info.size())+1: - productQ[j] = int(info[j]) - Wi[i] = productsQ + for j in range(0, info.size()): + productQ.append(int(info[j])) + Wi.append(productsQ) line = f.readline() nbC = int(line) @@ -39,14 +68,14 @@ def Read_input_file(file): for i in range(0, nbC): line = f.readline() info = line.split(' ') - Cp[i] = (int(info[0]), int(info[1])) + Cp.append((int(info[0]), int(info[1]))) line = f.readline() nbP = int(line) line = f.readline() info = line.split(' ') orderQ = {} for j in range(0, nbP): - orderQ[j] = int(info[j]) - Ci[i] = orderQ + orderQ.append(int(info[j])) + Ci.append(orderQ) return