···
fn generations(times: u32, mut world: Vec<u8>, size: usize, stuck: bool) -> Vec<u8> {
fn pos(x: usize, y: usize, size: usize) -> usize {
-
// this shit is unreadable man
-
(1 + y) * (size + 2) + (1 + x)
···
unsafe { *world.get_unchecked(pos(x, y, size)) }
let mut new_world = vec![0_u8; (size + 2).pow(2)];
-
world[pos(0, 0, size)] = 1;
-
world[pos(sizem, 0, size)] = 1;
-
world[pos(0, sizem, size)] = 1;
-
world[pos(sizem, sizem, size)] = 1;
···
// i hate the duplication here :(
-
world[pos(0, 0, size)] = 1;
-
world[pos(sizem, 0, size)] = 1;
-
world[pos(0, sizem, size)] = 1;
-
world[pos(sizem, sizem, size)] = 1;
···
let input = include_str!("../../input.txt").trim();
let size = input.split_once("\n").expect("invalid input").0.len();
-
// reads the input but adds a line of buffer on the sides. unreadable
let buffer_line = ".".repeat(size);
let input: Vec<u8> = format!("{buffer_line}\n{input}\n{buffer_line}")
···
fn generations(times: u32, mut world: Vec<u8>, size: usize, stuck: bool) -> Vec<u8> {
fn pos(x: usize, y: usize, size: usize) -> usize {
···
unsafe { *world.get_unchecked(pos(x, y, size)) }
let mut new_world = vec![0_u8; (size + 2).pow(2)];
+
world[pos(1, 1, size)] = 1;
+
world[pos(size, 1, size)] = 1;
+
world[pos(1, size, size)] = 1;
+
world[pos(size, size, size)] = 1;
···
// i hate the duplication here :(
+
world[pos(1, 1, size)] = 1;
+
world[pos(size, 1, size)] = 1;
+
world[pos(1, size, size)] = 1;
+
world[pos(size, size, size)] = 1;
···
let input = include_str!("../../input.txt").trim();
let size = input.split_once("\n").expect("invalid input").0.len();
+
// reads the input but adds a line of buffer on the sides
let buffer_line = ".".repeat(size);
let input: Vec<u8> = format!("{buffer_line}\n{input}\n{buffer_line}")