예제 #1
0
파일: domain.py 프로젝트: Mark-Seaman/Brain
def put_domain_doc(doc):
    write_file(map_doc_path(doc), read_input())
예제 #2
0
def put_page(host,user,path,text=None):
    log_page('put '+host+' '+user+' '+path)
    if text:
        write_file(doc_path(host,user,path), text.split('\n'))
    else:
        write_file(doc_path(host,user,path), read_input())
예제 #3
0
파일: doc.py 프로젝트: Mark-Seaman/Brain
def doc_put(doc):
    write_file(doc_path(doc), read_input())
예제 #4
0
파일: page.py 프로젝트: Mark-Seaman/Brain
def put_page(host,user,path,text=None):
    log_page('put '+host+' '+user+' '+path)
    if text:
        write_file(doc_path(host,user,path), text.split('\n'))
    else:
        write_file(doc_path(host,user,path), read_input())
예제 #5
0
def put_domain_doc(doc):
    write_file(map_doc_path(doc), read_input())
예제 #6
0
def main(args):
    # if len(args) != 1:
    #     print('One argument expected: id of problem to solve (a, b, c, ...)')
    #     sys.exit(-1)

    problem = args[0]

    lines = read_input(problem)

    dur, n_intersections, n_streets, n_cars, n_bonus, streets, cars = parse_input(lines)

    # distances = [(id, sum([streets[edge]['time'] for edge in car['path'] ])) for id, car  in enumerate(cars)]
    # distances.sort(key= lambda x: x[1]) 

    street_car_count = {}

    for street_name in streets:
        street_car_count[street_name] = []

    for car in cars:
        for street_name in car['path']:
            street_car_count[street_name].append(car)

    intersections = {}

    for i in range(n_intersections):

        semaphores = []

        streets_total_car_dist = {}

        for street_name in streets:
            if streets[street_name]['int_end'] == i:
                if len(street_car_count[street_name]) != 0:
                    semaphores.append((street_name, math.ceil(len(street_car_count[street_name]) * 0.01))) 

        #             total_car_dist = 0
        #             for car in street_car_count[street_name]:
        #                 dist_to_int = 0

        #                 for rua in car['path']:
        #                     if rua != street_name:
        #                         dist_to_int += streets[rua]['time']
        #                     else:
        #                         break

        #                 dist_to_int += streets[street_name]['time']
        #                 total_car_dist += dist_to_int
                    
        #             streets_total_car_dist[street_name] = total_car_dist

        # dist_sum = 0
        # for street in streets_total_car_dist:
        #     dist_sum += streets_total_car_dist[street]

        # for j, sem in enumerate(semaphores):

        #     if dist_sum != 0:
        #         semaphores[j] = (sem[0],math.ceil(sem[1] * (2 + streets_total_car_dist[street]/dist_sum)))
        
        if semaphores:
            intersections[i] = random.shuffle(semaphores)

    write_output(problem, intersections)
예제 #7
0
def doc_put(doc):
    write_file(doc_path(doc), read_input())