Ejemplo n.º 1
0
	def test_happiness(self):
		with open("test_input") as f:
			config = part1.readfile(f)
		arrangement = ["David", "Alice", "Bob", "Carol"]
		self.assertEqual(part1.happiness(config, arrangement), 330)
		# And the reverse order should give the same result.
		arrangement = ["Carol", "Bob", "Alice", "David"]
		self.assertEqual(part1.happiness(config, arrangement), 330)
Ejemplo n.º 2
0
	def test_readfile(self):
		f = StringIO("""David would lose 7 happiness units by sitting next to Bob.
David would gain 41 happiness units by sitting next to Carol.""")
		r = part1.readfile(f)
		self.assertEqual(r, {("David", "Bob"): -7, ("David", "Carol"): 41})