Skip to content

Commit e13d3c9

Browse files
committed
Solve day 13 2015 part 2: Knights of the Dinner Table
1 parent da87247 commit e13d3c9

File tree

1 file changed

+13
-1
lines changed
  • src/main/java/com/sbaars/adventofcode/year15/days

1 file changed

+13
-1
lines changed

src/main/java/com/sbaars/adventofcode/year15/days/Day13.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public static void main(String[] args) {
2020
Day13 day = new Day13();
2121
day.printParts();
2222
new com.sbaars.adventofcode.network.Submit().submit(day.part1(), 2015, 13, 1);
23+
new com.sbaars.adventofcode.network.Submit().submit(day.part2(), 2015, 13, 2);
2324
}
2425

2526
private void parseInput() {
@@ -49,7 +50,18 @@ public Object part1() {
4950

5051
@Override
5152
public Object part2() {
52-
return 0; // Implement in next part
53+
// Add myself to the list with happiness 0 for all relationships
54+
String me = "Me";
55+
Map<String, Integer> myHappiness = new HashMap<>();
56+
for (String person : people) {
57+
myHappiness.put(person, 0);
58+
happinessMap.get(person).put(me, 0);
59+
}
60+
happinessMap.put(me, myHappiness);
61+
people.add(me);
62+
63+
List<String> peopleList = new ArrayList<>(people);
64+
return findMaxHappiness(peopleList);
5365
}
5466

5567
private int findMaxHappiness(List<String> peopleList) {

0 commit comments

Comments
 (0)