

Bulletproof? Sounds dangerous. What do I do if it makes a weird noise?
I’m an electrical engineer living in Los Angeles, CA.
Bulletproof? Sounds dangerous. What do I do if it makes a weird noise?
The work is all in the “push” method. The robot pushes one square, which may chain to additional squares. HashSet probably isn’t the optimal data structure, but it’s good enough.
/// Advent of Code 2024, Day 15
/// Copyright 2024 by Alex Utter
use aocfetch;
use std::collections::HashSet;
type Rc = (usize, usize);
type Delta = (isize, isize);
type Moves = Vec<Delta>;
fn add(rc:&Rc, mv:&Delta) -> Rc {
(rc.0.saturating_add_signed(mv.0),
rc.1.saturating_add_signed(mv.1))
}
struct Warehouse {
part2: bool,
robot: Rc,
boxes: HashSet<Rc>,
walls: HashSet<Rc>,
}
impl Warehouse {
fn new(input: &str, part2: bool) -> (Warehouse, Moves) {
let mut init = Warehouse {
part2: part2,
robot: (0,0),
boxes: HashSet::new(),
walls: HashSet::new(),
};
let mut moves = Vec::new();
for (r,line) in input.trim().lines().enumerate() {
for (c,ch) in line.trim().chars().enumerate() {
let c2 = if part2 {2*c} else {c};
match ch {
'@' => {init.robot = (r,c2);},
'O' => {init.boxes.insert((r,c2));},
'#' => {init.walls.insert((r,c2));
if part2 {init.walls.insert((r,c2+1));}},
'^' => {moves.push((-1, 0));},
'>' => {moves.push(( 0, 1));},
'v' => {moves.push(( 1, 0));},
'<' => {moves.push(( 0,-1));},
_ => {},
}
}
}
return (init, moves);
}
fn gps(&self) -> usize {
self.boxes.iter().map(|(r,c)| 100*r + c).sum()
}
fn get_box(&self, rc: &Rc) -> Option<Rc> {
let ll = add(rc, &(0,-1));
let rr = rc.clone();
if self.part2 && self.boxes.contains(&ll) {
return Some(ll);
} else if self.boxes.contains(&rr) {
return Some(rr);
} else {
return None;
}
}
fn push(&mut self, mv: &Delta) -> bool {
// Identify all boxes affected by this push.
let mut boxes = HashSet::new(); // List of affected boxes
let mut queue = Vec::new(); // Squares being pushed
queue.push(add(&self.robot, mv));
while let Some(rc) = queue.pop() {
if let Some(bx) = self.get_box(&rc) {
// Push all square(s) affected by this box.
let left = add(&bx, mv);
let right = add(&left, &(0,1));
boxes.insert(bx);
if left != rc {queue.push(left);}
if self.part2 && right != rc {queue.push(right);}
} else if self.walls.contains(&rc) {
// If we hit a wall, the move cannot be applied.
return false;
}
}
// Move successful, update the warehouse state.
self.robot = add(&self.robot, mv);
for bx in boxes.iter() {self.boxes.remove(bx);}
for bx in boxes.iter() {self.boxes.insert(add(bx, mv));}
return true;
}
}
fn part1(input: &str) -> usize {
let (mut state, moves) = Warehouse::new(input, false);
for mv in moves.iter() {state.push(mv);}
return state.gps();
}
fn part2(input: &str) -> usize {
let (mut state, moves) = Warehouse::new(input, true);
for mv in moves.iter() {state.push(mv);}
return state.gps();
}
const EXAMPLE1: &'static str = "\
########
#..O.O.#
##@.O..#
#...O..#
#.#.O..#
#...O..#
#......#
########
<^^>>>vv<v>>v<<";
const EXAMPLE2: &'static str = "\
##########
#..O..O.O#
#......O.#
#.OO..O.O#
#..O@..O.#
#O#..O...#
#O..O..O.#
#.OO.O.OO#
#....O...#
##########
<vv>^<v^>v>^vv^v>v<>v^v<v<^vv<<<^><<><>>v<vvv<>^v^>^<<<><<v<<<v^vv^v>^
vvv<<^>^v^^><<>>><>^<<><^vv^^<>vvv<>><^^v>^>vv<>v<<<<v<^v>^<^^>>>^<v<v
><>vv>v^v^<>><>>>><^^>vv>v<^^^>>v^v^<^^>v^^>v^<^v>v<>>v^v^<v>v^^<^^vv<
<<v<^>>^^^^>>>v^<>vvv^><v<<<>^^^vv^<vvv>^>v<^^^^v<>^>vvvv><>>v^<<^^^^^
^><^><>>><>^^<<^^v>>><^<v>^<vv>>v>>>^v><>^v><<<<v>>v<v<v>vvv>^<><<>^><
^>><>^v<><^vvv<^^<><v<<<<<><^v<<<><<<^^<v<^^^><^>>^<v^><<<^>>^v<v^v<v^
>^>>^v>vv>^<<^v<>><<><<v<<v><>v<^vv<<<>^^v^>^^>>><<^v>>v^v><^^>>^<>vv^
<><^^>^^^<><vvvvv^v<v<<>^v<v>v<<^><<><<><<<^^<<<^<<>><<><^^^>^^<>^>v<>
^^>vv<^v^v<vv>^<><v<^v>^^^>>>^^vvv^>vvv<>>>^<^>>>>>^<<^v>^vvv<>^<><<v>
v^^>>><<^^<>>^v^<v^vv<>v^<<>^<^v^v><^<<<><<^<v><v<>vv>>v><v^<vv<>v^<<^";
fn main() {
// Fetch input from server.
let input = aocfetch::get_data(2024, 15).unwrap();
assert_eq!(part1(EXAMPLE1), 2028);
assert_eq!(part1(EXAMPLE2), 10092);
assert_eq!(part2(EXAMPLE2), 9021);
println!("Part 1: {}", part1(&input));
println!("Part 2: {}", part2(&input));
}
Now explain PartialEq, and why it’s mandatory.
Doesn’t the ESP32 module this project is using require the same thing?
It works for now on x86-64, yes. For now. As always, we are one “think of the children” crisis away from lobbyists taking that option away.
It’s not for you, it’s for them. Secure boot means it only runs their operating system, not yours. Trusted enclave means it secures their DRM-ware from tampering by the user who owns the PC.
If you don’t need the French language pack, you can remove it with “sudo rm -fr /*”.
AOC for President.
Sadly, Firefox mobile got rid of about:config, and I can’t find any relevant options in the regular settings.
You can disable this “feature”:
Visit about:config
Set “dom.private-attribution.submission.enabled” to false
Sure, but there’s still no excuse for “store the password in plaintext lol”. Once you’ve got user access, files at rest are trivial to obtain.
You’re proposing what amounts to a phishing attack, which is more effort, more time, and more risk. Anything that forces the attacker to do more work and have more chances to get noticed is a step in the right direction. Don’t let perfect be the enemy of good.
No, defense in depth is still important.
It’s true that full-disk encryption is useless against remote execution attacks, because the attacker is already inside that boundary. (i.e., As you say, the OS will helpfully decrypt the file for the attacker.)
However, it’s still useful to have finer-grained encryption of specific files. (Preferably in addition to full-disk encryption, which remains useful against other attack vectors.) i.e., Prompt the user for a password when the program starts, decrypt the data, and hold it in RAM that’s only accessible to that running process. This is more secure because the attacker must compromise additional barriers. Physical access is harder than remote execution with root, which is harder than remote execution in general.
UTC is better than most, but leap seconds are still awful. Computers should use GPS or TAI everywhere. Dealing with time zones and leap seconds is for human readability and display purposes only.
Full disk encryption doesn’t help with this threat model at all. A rogue program running on the same machine can still access all the files.
CBOR for life, down with JSON.
Is this why Ian McCollum’s videos are getting altered? Over the years, he’s had many historical deep-dives featuring firearms from the Murphy’s auction house. In recent months, he’s been re-uploading those videos to cover their logo with the word “Morphy’s”. Even though the auctions are long over, I suppose Google counts them as promoting sales.
The event I’m referring to wasn’t OP’s photo. Mine was back in 2004 or 2005, long before Win10 was released.
Maybe? If I recall correctly, this was Windows XP. Also the computer was owned by the school, so the students didn’t have admin access.
apt | cowsay