ARGS_COUNT = 0 if len(sys.argv) < ARGS_COUNT: print("Missing arguments") sys.exit(1) from task import parseLine, findOptimum, buildStructure, addAmbivalentPerson ## result = 0 seating = [] with open("in.txt") as file: for line in file: seating = seating + [parseLine(line)] # part 1 structure = buildStructure(seating) (result, permutation) = findOptimum(structure) print("The result of 'part 1' is '\033[1;33m{}\033[1;m' (seating is {})".format(result, permutation)) # part 2 structure = addAmbivalentPerson(buildStructure(seating)) (result, permutation) = findOptimum(structure) print("The result of 'part 2' is '\033[1;33m{}\033[1;m' (seating is {})".format(result, permutation)) ## sys.exit(0)
# part 1 happinessDeclaration = [ ("A", "B", -53), ("B", "A", 43), ("A", "C", 12), ("C", "A", -3), ("B", "C", 6), ("C", "B", -1), ("A", "D", 0), ("B", "D", 9), ("C", "D", -14), ("D", "A", -100), ("D", "B", 23), ("D", "C", 14), ] structure = buildStructure(happinessDeclaration) t.test( "David would lose 53 happiness units by sitting next to Carol.", parseLine("David would lose 53 happiness units by sitting next to Carol."), ("David", "Carol", -53), ) t.test( "David would gain 43 happiness units by sitting next to Alice.", parseLine("David would gain 43 happiness units by sitting next to Alice."), ("David", "Alice", 43), ) t.test( "generate permutations", generatePermutations(["a", "b", "c"]), [["a", "b", "c"], ["a", "c", "b"], ["b", "a", "c"], ["b", "c", "a"], ["c", "a", "b"], ["c", "b", "a"]],