[-] Zikeji@programming.dev 5 points 2 months ago

I read about and see videos about the humans right violations that are happening in Pakistan, Ukraine, and other parts of the world and I know if I were put through some of that, having seen videos and read shit ain't going to mean jack shit.

[-] Zikeji@programming.dev 5 points 6 months ago

Regent pisses me off lol. All the others I got solid strategies with but regent is still a PITA

[-] Zikeji@programming.dev 5 points 6 months ago

Meshtastic is basically just texting, but there are nodes people setup for BBS purposes.

[-] Zikeji@programming.dev 5 points 9 months ago

Javascript

I generally like trying the brute force approach first (though in the latter days it just wastes time). After exhausting 32GB of RAM I changed approaches.

Admittedly I don't really understand these algorithms as well as I would like, and I also will admit I inadvertently was LLM assisted :(. When I was trying to figure out what algo I should use and the AI summary in Google's search spoiled me. But I did learn alot.

One interesting observation, unrelated to the solution itself, is the solutions runs about 30% faster in Firefox than it does via Node (25.2.1 and 24.11.1) on my machine.

Code

const input = require('fs').readFileSync('input-day9.txt', 'utf-8');

/** @type {Array<[number, number]} */
const points = input.split("\n").map(r => r.split(',').map(v => parseInt(v, 10)));

let largest = 0;
let largestInside = 0;
for (const [startX, startY] of points) {
    for (const [nextX, nextY] of points) {
        if (startX === nextX && startY === nextY) continue;

        const minX = Math.min(startX, nextX);
        const maxX = Math.max(startX, nextX);
        const minY = Math.min(startY, nextY);
        const maxY = Math.max(startY, nextY);

        const area = (maxX - minX + 1) * (maxY - minY + 1);
        if (area > largest) {
            largest = area;
        }

        if (area <= largestInside) continue;

        // center point check, ala https://en.wikipedia.org/wiki/Even%E2%80%93odd_rule
        const centerX = (minX + maxX) / 2;
        const centerY = (minY + maxY) / 2;
        let inside = false;
        for (const [i, [aX, aY]] of points.entries()) {
            const [bX, bY] = points[i - 1] ?? points[points.length - 1];
            if (centerX === aX && centerY === aY) {
                inside = true;
                break;
            }
            if ((aY > centerY) !== (bY > centerY)) {
                const slope = (centerX - aX) * (bY - aY) - (bX - aX) * (centerY - aY);
                if (slope === 0) {
                    inside = true;
                    break;
                }
                if ((slope < 0) !== (bY < aY)) {
                    inside = !inside;
                }
            }
        }

        if (!inside) continue;

        // check for edge intersections, ala https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection
        let intersects = false;
        for (const [i, [aX, aY]] of points.entries()) {
            const [bX, bY] = points[i - 1] ?? points[points.length - 1];

            if (aX === bX) {
                if (aX > minX && aX < maxX) {
                    const wallMinY = Math.min(aY, bY);
                    const wallMaxY = Math.max(aY, bY);

                    if (Math.max(minY, wallMinY) < Math.min(maxY, wallMaxY)) {
                        intersects = true;
                        break;
                    }
                }
            } else if (aY === bY) {
                if (aY > minY && aY < maxY) {
                    const wallMinX = Math.min(aX, bX);
                    const wallMaxX = Math.max(aX, bX);

                    if (Math.max(minX, wallMinX) < Math.min(maxX, wallMaxX)) {
                        intersects = true;
                        break;
                    }
                }
            }
        }

        if (intersects) continue;

        if (area > largestInside) {
            largestInside = area;
        }
    }
}

console.log(`Part 1 Answer: ${largest}`);
console.log(`Part 2 Answer: ${largestInside}`);

[-] Zikeji@programming.dev 5 points 10 months ago

A straightforward day 1 for a Javascript / NodeJS solution.

Poorly Optimized JS Solution

let position = 50;
let answer1 = 0;
let answer2 = 0;

const sequence = require('fs').readFileSync('input-day1.txt', 'utf-8');

sequence.split('\n').forEach(instruction => {
    const turn = instruction.charAt(0);
    let distance = parseInt(instruction.slice(1), 10);

    while (distance > 0) {
        distance -= 1;

        if (turn === 'L') {
            position -= 1;
        } else if (turn === 'R') {
            position += 1;
        }

        if (position >= 100) {
            position -= 100;
        } else if (position < 0) {
            position += 100;
        }

        if (position === 0) {
            answer2 += 1;
        }
    }

    if (position === 0) {
        answer1 += 1;
    }
});

console.log(`Part 1 Answer: ${answer1}`);
console.log(`Part 2 Answer: ${answer2}`);

[-] Zikeji@programming.dev 5 points 10 months ago

Streaming like movies and TV, or like Twitch?

And free as in the legal free ones, or illegal free ones?

[-] Zikeji@programming.dev 5 points 1 year ago

For those types it feels like a broken record. Some part of them wants to understand and be challenged but their pride/programming overrides it and they get stuck in a loop for stupidity.

Some are just assholes. I blocked the person earlier after they they asked for an explanation about why Trump's policies on immigration are any worse than Obama's saying they were genuinely curious, after I responded with as objective of an explanation I got hit with the "oh honey that's wrong" lol.

[-] Zikeji@programming.dev 5 points 1 year ago

Usually when I suspect a hardware issue I start by unplugging every external device that isn't the keyboard. If that does the trick, in they go again one by one. Otherwise, it's time for hardware to get the same treatment. Unfortunately your processor doesn't have on board graphics, so unless you have a donor system you can borrow a known working good GPU from, I'd probably try and reseat the GPU (remove, maybe canned air to blow out slot, back in).

[-] Zikeji@programming.dev 5 points 2 years ago

When working with transient data, streaming it (as opposed to saving it to the disk first) is preferred to reduce clean up requirements.

[-] Zikeji@programming.dev 5 points 2 years ago

That reminds me, I just started The Completionist Chronicles by Dakota Krout and it started off with some really weird Elon Musk fanfic.. Fortunately I haven't seen anymore but damn I was nearly nauseous.

[-] Zikeji@programming.dev 5 points 3 years ago

It's a deterrent. Which is a pretty apt comparison for robots.txt and user agent blocking.

view more: โ€น prev next โ€บ

Zikeji

0 post score
0 comment score
joined 3 years ago