summary refs log tree commit diff homepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--2018/day07.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/2018/day07.c b/2018/day07.c
new file mode 100644
index 0000000..43dd786
--- /dev/null
+++ b/2018/day07.c
@@ -0,0 +1,27 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+typedef unsigned uint;
+
+int main() {
+	uint steps = 0;
+	uint deps[26] = {0};
+	while (!feof(stdin)) {
+		char dep, step;
+		scanf(
+			"Step %c must be finished before step %c can begin.\n",
+			&dep, &step
+		);
+		deps[step - 'A'] |= 1 << (dep - 'A');
+	}
+	while (steps != (1 << 26) - 1) {
+		for (uint i = 0; i < 26; ++i) {
+			if (steps & (1 << i)) continue;
+			if ((deps[i] & steps) != deps[i]) continue;
+			printf("%c", 'A' + i);
+			steps |= (1 << i);
+			break;
+		}
+	}
+	printf("\n");
+}
=1.8&id=b9a6d35b659e5eba69897d27cee0091821fbe897&follow=1'>Improve color fudgingJune McEnroe 2020-02-10Support all 99 IRC colorsJune McEnroe 2020-02-10Avoid coloring mentions if there are control codesJune McEnroe 2020-02-10Recalculate unreadLines on reflowJune McEnroe 2020-02-10Only make windows hotterJune McEnroe 2020-02-10Always increase unreadLinesJune McEnroe 2020-02-10Move scroll marker on resizeJune McEnroe 2020-02-10Update line count for words longer than linesJune McEnroe 2020-02-10Simplify mark, heat, unread trackingJune McEnroe 2020-02-10Update prompt when own nick changesJune McEnroe 2020-02-10Match URLs surrounded by parenthesesJune McEnroe 2020-02-10Fix M-a so it properly cycles back to where it startedJune McEnroe 2020-02-09Add M-lJune McEnroe 2020-02-09Add /whoisJune McEnroe 2020-02-09Add /msgJune McEnroe