Ejemplo n.º 1
0
from operator import itemgetter

if __name__ == "__main__":
    k = int(input("Enter k: "))
    Generator.boy_generator('boys.csv', 100)
    Generator.girl_generator('girls.csv', 10)
    Generator.gift_generator('gifts.csv', 100)

    boys = Reader.readfile('boys.csv')
    girls = Reader.readfile('girls.csv')
    gifts = Reader.readfile('gifts.csv')

    for gift in gifts:
        for key in gift:
            if key != 'category':
                gift[key] = int(gift[key])

    coupler = CoupleMaker()
    couples = []
    for girl in girls:
        coupler.make_couple(girl, boys, gifts, couples)

    couples.sort(key=itemgetter('happiness'), reverse=True)
    print(str(k) + ' Happiest couples')
    for couple, i in zip(couples, range(k)):
        print(couple)

    couples.sort(key=itemgetter('compatibility'), reverse=True)
    print(str(k) + ' Most compatible couples')
    for couple, i in zip(couples, range(k)):
        print(couple)
Ejemplo n.º 2
0
    Generator.boy_generator('boys.csv', 100)
    Generator.girl_generator('girls.csv', 10)
    Generator.gift_generator('gifts.csv', 100)

    boys = Reader.readfile('boys.csv')
    boys.sort(key=itemgetter('attrac'), reverse=True)
    girls = Reader.readfile('girls.csv')
    girls.sort(key=itemgetter('cost'))
    gifts = Reader.readfile('gifts.csv')

    for gift in gifts:
        for key in gift:
            if key != 'category':
                gift[key] = int(gift[key])

    coupler = CoupleMaker()
    couples = []
    i = j = 0
    while i < len(girls) and j < len(boys):
        if girls[i]['status'] == 'False':
            coupler.make_couple(girls[i], boys, gifts, couples)
        i = i + 1

        if boys[j]['status'] == 'False':
            coupler.find_girl(boys[i], girls, gifts, couples)
        j = j + 1

    couples.sort(key=itemgetter('happiness'), reverse=True)
    print(str(k) + ' Happiest couples')
    for couple, i in zip(couples, range(k)):
        print(couple)