2018 d7 p1
This commit is contained in:
parent
62e4120448
commit
de804608ef
101
2018/7/input.txt
Normal file
101
2018/7/input.txt
Normal file
|
@ -0,0 +1,101 @@
|
||||||
|
Step J must be finished before step K can begin.
|
||||||
|
Step N must be finished before step X can begin.
|
||||||
|
Step S must be finished before step G can begin.
|
||||||
|
Step T must be finished before step R can begin.
|
||||||
|
Step H must be finished before step L can begin.
|
||||||
|
Step V must be finished before step W can begin.
|
||||||
|
Step G must be finished before step U can begin.
|
||||||
|
Step K must be finished before step A can begin.
|
||||||
|
Step D must be finished before step Z can begin.
|
||||||
|
Step C must be finished before step E can begin.
|
||||||
|
Step X must be finished before step P can begin.
|
||||||
|
Step Y must be finished before step U can begin.
|
||||||
|
Step R must be finished before step O can begin.
|
||||||
|
Step W must be finished before step U can begin.
|
||||||
|
Step O must be finished before step Q can begin.
|
||||||
|
Step A must be finished before step P can begin.
|
||||||
|
Step B must be finished before step E can begin.
|
||||||
|
Step F must be finished before step E can begin.
|
||||||
|
Step Q must be finished before step U can begin.
|
||||||
|
Step M must be finished before step E can begin.
|
||||||
|
Step P must be finished before step U can begin.
|
||||||
|
Step L must be finished before step Z can begin.
|
||||||
|
Step Z must be finished before step U can begin.
|
||||||
|
Step U must be finished before step E can begin.
|
||||||
|
Step I must be finished before step E can begin.
|
||||||
|
Step H must be finished before step G can begin.
|
||||||
|
Step X must be finished before step I can begin.
|
||||||
|
Step K must be finished before step X can begin.
|
||||||
|
Step Z must be finished before step I can begin.
|
||||||
|
Step S must be finished before step M can begin.
|
||||||
|
Step L must be finished before step U can begin.
|
||||||
|
Step A must be finished before step M can begin.
|
||||||
|
Step W must be finished before step A can begin.
|
||||||
|
Step N must be finished before step A can begin.
|
||||||
|
Step S must be finished before step E can begin.
|
||||||
|
Step W must be finished before step Q can begin.
|
||||||
|
Step J must be finished before step L can begin.
|
||||||
|
Step Q must be finished before step L can begin.
|
||||||
|
Step M must be finished before step U can begin.
|
||||||
|
Step H must be finished before step E can begin.
|
||||||
|
Step D must be finished before step E can begin.
|
||||||
|
Step V must be finished before step P can begin.
|
||||||
|
Step Q must be finished before step M can begin.
|
||||||
|
Step X must be finished before step W can begin.
|
||||||
|
Step K must be finished before step I can begin.
|
||||||
|
Step T must be finished before step H can begin.
|
||||||
|
Step Y must be finished before step L can begin.
|
||||||
|
Step G must be finished before step O can begin.
|
||||||
|
Step M must be finished before step Z can begin.
|
||||||
|
Step F must be finished before step Z can begin.
|
||||||
|
Step Q must be finished before step E can begin.
|
||||||
|
Step H must be finished before step C can begin.
|
||||||
|
Step Q must be finished before step P can begin.
|
||||||
|
Step D must be finished before step U can begin.
|
||||||
|
Step Z must be finished before step E can begin.
|
||||||
|
Step O must be finished before step M can begin.
|
||||||
|
Step L must be finished before step I can begin.
|
||||||
|
Step J must be finished before step A can begin.
|
||||||
|
Step Q must be finished before step Z can begin.
|
||||||
|
Step P must be finished before step I can begin.
|
||||||
|
Step K must be finished before step O can begin.
|
||||||
|
Step R must be finished before step E can begin.
|
||||||
|
Step W must be finished before step F can begin.
|
||||||
|
Step D must be finished before step Q can begin.
|
||||||
|
Step R must be finished before step U can begin.
|
||||||
|
Step W must be finished before step P can begin.
|
||||||
|
Step S must be finished before step Z can begin.
|
||||||
|
Step T must be finished before step P can begin.
|
||||||
|
Step B must be finished before step Q can begin.
|
||||||
|
Step S must be finished before step T can begin.
|
||||||
|
Step R must be finished before step A can begin.
|
||||||
|
Step K must be finished before step R can begin.
|
||||||
|
Step N must be finished before step G can begin.
|
||||||
|
Step C must be finished before step W can begin.
|
||||||
|
Step T must be finished before step A can begin.
|
||||||
|
Step B must be finished before step Z can begin.
|
||||||
|
Step C must be finished before step P can begin.
|
||||||
|
Step D must be finished before step P can begin.
|
||||||
|
Step B must be finished before step P can begin.
|
||||||
|
Step F must be finished before step U can begin.
|
||||||
|
Step V must be finished before step X can begin.
|
||||||
|
Step K must be finished before step W can begin.
|
||||||
|
Step Y must be finished before step I can begin.
|
||||||
|
Step C must be finished before step B can begin.
|
||||||
|
Step X must be finished before step L can begin.
|
||||||
|
Step X must be finished before step M can begin.
|
||||||
|
Step H must be finished before step P can begin.
|
||||||
|
Step S must be finished before step F can begin.
|
||||||
|
Step J must be finished before step Y can begin.
|
||||||
|
Step Y must be finished before step Z can begin.
|
||||||
|
Step B must be finished before step I can begin.
|
||||||
|
Step S must be finished before step C can begin.
|
||||||
|
Step K must be finished before step E can begin.
|
||||||
|
Step N must be finished before step Q can begin.
|
||||||
|
Step A must be finished before step Z can begin.
|
||||||
|
Step J must be finished before step I can begin.
|
||||||
|
Step Y must be finished before step O can begin.
|
||||||
|
Step Y must be finished before step F can begin.
|
||||||
|
Step S must be finished before step U can begin.
|
||||||
|
Step D must be finished before step W can begin.
|
||||||
|
Step V must be finished before step D can begin.
|
22
2018/7/part1.js
Normal file
22
2018/7/part1.js
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
const fs = require('fs');
|
||||||
|
let rules = fs.readFileSync('input.txt', 'utf-8').split('\n');
|
||||||
|
steps = [];
|
||||||
|
for (let rule of rules) {
|
||||||
|
[_, step1, step2] = rule.match(/Step (\w) must be finished before step (\w) can begin./);
|
||||||
|
if (!steps[step1])
|
||||||
|
steps[step1] = []
|
||||||
|
if (!steps[step2])
|
||||||
|
steps[step2] = []
|
||||||
|
steps[step2].push(step1)
|
||||||
|
}
|
||||||
|
let ans = '';
|
||||||
|
|
||||||
|
while (Object.entries(steps).length > 0) {
|
||||||
|
let step = Object.entries(steps).filter(v => v[1].length == 0).map(v => v[0]).sort()[0]
|
||||||
|
delete steps[step];
|
||||||
|
for (let step_ in steps) {
|
||||||
|
steps[step_] = steps[step_].filter(v => v != step)
|
||||||
|
}
|
||||||
|
ans += step
|
||||||
|
}
|
||||||
|
console.log(ans)
|
1
2018/8/input.txt
Normal file
1
2018/8/input.txt
Normal file
File diff suppressed because one or more lines are too long
|
@ -1,22 +1,25 @@
|
||||||
# [2018](https://adventofcode.com/2018 "2018 puzzle calendar")
|
# [2018](https://adventofcode.com/2018 "2018 puzzle calendar")
|
||||||
1. [js :star: :star:](https://adventofcode.com/2018/day/1 "see puzzle")
|
1. [js :star: :star:](https://adventofcode.com/2015/day/1 "see puzzle")
|
||||||
1. [py :star: :star:](https://adventofcode.com/2018/day/2 "see puzzle")
|
1. [py :star: :star:](https://adventofcode.com/2015/day/2 "see puzzle")
|
||||||
1. [js :star: :star:](https://adventofcode.com/2018/day/3 "see puzzle")
|
1. [js :star: :star:](https://adventofcode.com/2015/day/3 "see puzzle")
|
||||||
1. [js :star: :star:](https://adventofcode.com/2018/day/4 "see puzzle")
|
1. [js :star: :star:](https://adventofcode.com/2015/day/4 "see puzzle")
|
||||||
1. [js :star: :star:](https://adventofcode.com/2018/day/5 "see puzzle")
|
1. [js :star: :star:](https://adventofcode.com/2015/day/5 "see puzzle")
|
||||||
1. [js :star: :star:](https://adventofcode.com/2018/day/6 "see puzzle")
|
1. [js :star: :star:](https://adventofcode.com/2015/day/6 "see puzzle")
|
||||||
|
1. [js :star:](https://adventofcode.com/2015/day/7 "see puzzle")
|
||||||
|
1. [-](https://adventofcode.com/2015/day/8 "see puzzle")
|
||||||
|
|
||||||
# Languages Used
|
# Languages Used
|
||||||
### Python
|
### Python
|
||||||
1. [-](https://adventofcode.com/2018/day/1 "see puzzle")
|
1. [-](https://adventofcode.com/2018/day/1 "see puzzle")
|
||||||
1. [:star: :star:](https://adventofcode.com/2018/day/2 "see puzzle")
|
1. [:star: :star:](https://adventofcode.com/2018/day/2 "see puzzle")
|
||||||
1. [-](https://adventofcode.com/2018/day/3 "see puzzle")
|
1. [-](https://adventofcode.com/2018/day/3 "see puzzle")
|
||||||
1. [...](https://adventofcode.com/2018/day/4 "see puzzle")
|
1. ...
|
||||||
|
|
||||||
### Node JS
|
### Node JS
|
||||||
1. [js :star: :star:](https://adventofcode.com/2018/day/1 "see puzzle")
|
1. [:star: :star:](https://adventofcode.com/2018/day/1 "see puzzle")
|
||||||
1. [-](https://adventofcode.com/2018/day/2 "see puzzle")
|
1. [-](https://adventofcode.com/2018/day/2 "see puzzle")
|
||||||
1. [js :star: :star:](https://adventofcode.com/2018/day/3 "see puzzle")
|
1. [:star: :star:](https://adventofcode.com/2018/day/3 "see puzzle")
|
||||||
1. [js :star: :star:](https://adventofcode.com/2018/day/4 "see puzzle")
|
1. [:star: :star:](https://adventofcode.com/2018/day/4 "see puzzle")
|
||||||
1. [js :star: :star:](https://adventofcode.com/2018/day/5 "see puzzle")
|
1. [:star: :star:](https://adventofcode.com/2018/day/5 "see puzzle")
|
||||||
1. [js :star: :star:](https://adventofcode.com/2018/day/6 "see puzzle")
|
1. [:star: :star:](https://adventofcode.com/2018/day/6 "see puzzle")
|
||||||
|
1. [:star:](https://adventofcode.com/2018/day/7 "see puzzle")
|
||||||
|
|
|
@ -22,8 +22,10 @@ if (advent) {
|
||||||
1. [js :star: :star:](https://adventofcode.com/2015/day/3 "see puzzle")
|
1. [js :star: :star:](https://adventofcode.com/2015/day/3 "see puzzle")
|
||||||
1. [js :star: :star:](https://adventofcode.com/2015/day/4 "see puzzle")
|
1. [js :star: :star:](https://adventofcode.com/2015/day/4 "see puzzle")
|
||||||
1. [js :star: :star:](https://adventofcode.com/2015/day/5 "see puzzle")
|
1. [js :star: :star:](https://adventofcode.com/2015/day/5 "see puzzle")
|
||||||
1. [js :star: :star: :point_left:](https://adventofcode.com/2015/day/6 "see puzzle")
|
1. [js :star: :star:](https://adventofcode.com/2015/day/6 "see puzzle")
|
||||||
|
1. [js :star:](https://adventofcode.com/2015/day/7 "see puzzle")
|
||||||
|
1. [-](https://adventofcode.com/2015/day/8 "see puzzle")
|
||||||
|
|
||||||
## Languages Used
|
## Languages Used
|
||||||
* Python 8×:star:
|
* Python 8×:star:
|
||||||
* Node JS 12×:star:
|
* Node JS 13×:star:
|
Loading…
Reference in a new issue