I realized having to host this potentially indefinitely might not be the best idea, so I am going to shut down this gitea instance eventually.
You’ll have time, at least until the end of 2022, probably longer, but please just get all your stuff somewhere safe in case we ever disappear.
If any of your build scripts rely on my (kageru’s) projects hosted here, check my Github or IEW on Github for encoding projects. If you can’t find what you’re looking there, tell me to migrate it.

day 7 part 1 done, day6 seems to have an error

master
attila 4 years ago
parent c9c3c17302
commit 940ccdedbb

4
day6/Cargo.lock generated

@ -0,0 +1,4 @@
[[package]]
name = "day6"
version = "0.1.0"

@ -0,0 +1,6 @@
[package]
name = "day6"
version = "0.1.0"
authors = ["attila <daf276@gmx.de>"]
[dependencies]

@ -0,0 +1,50 @@
135, 127
251, 77
136, 244
123, 169
253, 257
359, 309
100, 247
191, 323
129, 323
76, 284
69, 56
229, 266
74, 216
236, 130
152, 126
174, 319
315, 105
329, 146
288, 51
184, 344
173, 69
293, 80
230, 270
279, 84
107, 163
130, 176
347, 114
133, 331
237, 300
291, 283
246, 297
60, 359
312, 278
242, 76
81, 356
204, 291
187, 335
176, 98
103, 274
357, 144
314, 118
67, 196
156, 265
254, 357
218, 271
118, 94
300, 189
290, 356
354, 91
209, 334

@ -0,0 +1,66 @@
use std::fs;
use std::collections::HashSet;
use std::collections::HashMap;
fn main() {
let file = fs::read_to_string("input").expect("Unable to read file");
let lines = file.split("\n").collect::<Vec<&str>>();
let mut anchorpoints = HashSet::new();
let mut points_nearest_to_anchor = HashMap::new();
let mut min_x = std::i32::MAX;
let mut min_y = std::i32::MAX;
let mut max_x = 0;
let mut max_y = 0;
for line in lines {
let coords = line.split(|c| c == ',' || c == ' ').collect::<Vec<&str>>();
let x = coords[0].parse::<i32>().unwrap();
let y = coords[2].parse::<i32>().unwrap();
anchorpoints.insert((x,y));
if x < min_x { min_x = x.clone(); }
if y < min_y { min_y = y.clone(); }
if x > max_x { max_x = x.clone(); }
if y > max_y { max_y = y.clone(); }
}
for i in min_x..(max_x+1) {
for j in min_y..(max_y+1) {
let mut winning_x = 0;
let mut winning_y = 0;
let mut min_dist = std::i32::MAX;
let mut second_min_dist = std::i32::MAX;
for (x,y) in &anchorpoints{
let dist = (x - i + y - j).abs();
if dist < min_dist{
min_dist = dist;
winning_x = x.clone();
winning_y = y.clone();
} else if dist < second_min_dist {
second_min_dist = dist;
}
}
if min_dist != second_min_dist {
*points_nearest_to_anchor.entry((winning_x,winning_y)).or_insert(1) += 1;
}
}
}
let mut largest_area = 0;
for area in points_nearest_to_anchor.values() {
if *area > largest_area {
largest_area = *area;
}
println!("{}", *area);
}
println!("{}", largest_area);
}

4
day7/Cargo.lock generated

@ -0,0 +1,4 @@
[[package]]
name = "day7"
version = "0.1.0"

@ -0,0 +1,6 @@
[package]
name = "day7"
version = "0.1.0"
authors = ["attila <daf276@gmx.de>"]
[dependencies]

@ -0,0 +1,101 @@
Step A must be finished before step R can begin.
Step J must be finished before step B can begin.
Step D must be finished before step B can begin.
Step X must be finished before step Z can begin.
Step H must be finished before step M can begin.
Step B must be finished before step F can begin.
Step Q must be finished before step I can begin.
Step U must be finished before step O can begin.
Step T must be finished before step W can begin.
Step V must be finished before step S can begin.
Step N must be finished before step P can begin.
Step P must be finished before step O can begin.
Step E must be finished before step C can begin.
Step F must be finished before step O can begin.
Step G must be finished before step I can begin.
Step Y must be finished before step Z can begin.
Step M must be finished before step K can begin.
Step C must be finished before step W can begin.
Step L must be finished before step W can begin.
Step W must be finished before step S can begin.
Step Z must be finished before step O can begin.
Step K must be finished before step S can begin.
Step S must be finished before step R can begin.
Step R must be finished before step I can begin.
Step O must be finished before step I can begin.
Step A must be finished before step Q can begin.
Step Z must be finished before step R can begin.
Step T must be finished before step R can begin.
Step M must be finished before step O can begin.
Step Q must be finished before step Z can begin.
Step V must be finished before step C can begin.
Step Y must be finished before step W can begin.
Step N must be finished before step F can begin.
Step J must be finished before step D can begin.
Step D must be finished before step N can begin.
Step B must be finished before step M can begin.
Step P must be finished before step I can begin.
Step W must be finished before step Z can begin.
Step Q must be finished before step V can begin.
Step V must be finished before step K can begin.
Step B must be finished before step Z can begin.
Step M must be finished before step I can begin.
Step G must be finished before step C can begin.
Step K must be finished before step O can begin.
Step E must be finished before step O can begin.
Step C must be finished before step I can begin.
Step X must be finished before step G can begin.
Step B must be finished before step T can begin.
Step B must be finished before step I can begin.
Step E must be finished before step F can begin.
Step N must be finished before step K can begin.
Step D must be finished before step W can begin.
Step R must be finished before step O can begin.
Step V must be finished before step I can begin.
Step T must be finished before step O can begin.
Step B must be finished before step Q can begin.
Step T must be finished before step L can begin.
Step M must be finished before step C can begin.
Step A must be finished before step M can begin.
Step F must be finished before step L can begin.
Step X must be finished before step T can begin.
Step G must be finished before step K can begin.
Step C must be finished before step L can begin.
Step D must be finished before step Z can begin.
Step H must be finished before step L can begin.
Step P must be finished before step Z can begin.
Step A must be finished before step V can begin.
Step G must be finished before step R can begin.
Step E must be finished before step G can begin.
Step D must be finished before step P can begin.
Step X must be finished before step L can begin.
Step U must be finished before step C can begin.
Step Z must be finished before step K can begin.
Step E must be finished before step W can begin.
Step B must be finished before step Y can begin.
Step J must be finished before step I can begin.
Step U must be finished before step P can begin.
Step Y must be finished before step L can begin.
Step N must be finished before step L can begin.
Step L must be finished before step S can begin.
Step H must be finished before step P can begin.
Step P must be finished before step S can begin.
Step J must be finished before step S can begin.
Step J must be finished before step U can begin.
Step H must be finished before step T can begin.
Step L must be finished before step I can begin.
Step N must be finished before step Z can begin.
Step A must be finished before step G can begin.
Step H must be finished before step S can begin.
Step S must be finished before step I can begin.
Step H must be finished before step E can begin.
Step W must be finished before step R can begin.
Step B must be finished before step G can begin.
Step U must be finished before step Y can begin.
Step J must be finished before step G can begin.
Step M must be finished before step L can begin.
Step G must be finished before step Z can begin.
Step N must be finished before step W can begin.
Step D must be finished before step E can begin.
Step A must be finished before step W can begin.
Step G must be finished before step Y can begin.

@ -0,0 +1,35 @@
use std::fs;
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
fn main() {
let file = fs::read_to_string("input").expect("Unable to read file");
let lines = file.split("\n").collect::<Vec<&str>>();
let mut prerequisites = HashMap::<char, Vec<char>>::new();
let mut queue = Vec::new();
for line in lines{
let words: Vec<char> = line.chars().collect();
prerequisites.entry(words[36] as char).or_default().push(words[5]);
prerequisites.entry(words[5]).or_default();
}
let mut todo = prerequisites.keys().cloned().collect::<BTreeSet<_>>();
let mut prereq_done = HashSet::new();
while !todo.is_empty() {
for c in todo.clone().into_iter() {
if prerequisites.get(&c).is_none() || prerequisites.get(&c).unwrap().into_iter().all(|prerequisit| prereq_done.contains(prerequisit)){
queue.push(c);
prereq_done.insert(c);
todo.remove(&c);
break;
}
}
}
println!("{}", queue.into_iter().collect::<String>());
}
Loading…
Cancel
Save