Zikeji

joined 2 years ago
[–] Zikeji@programming.dev 5 points 1 day ago

I'm hybrid, so 2 days a week I work flat 8 hours and it is bliss, then 3 days a week I "work" 11 hours but only get paid for 8 - at least, that's how I view it.

[–] Zikeji@programming.dev 18 points 4 days ago

I'm getting off a two week break. I wouldn't say I'm overwhelmed just... Exhausted by the thought.

Also think I should try week long breaks more often....

[–] Zikeji@programming.dev 11 points 6 days ago

An AIO or air cooler aren't as impactful as the environment in my experience. Throw your computer in the corner of a room and that AIO ain't gonna help.

If you do go AIO, make sure you do it right.

Either case, good airflow design does wonders - air cooled or AIO.

[–] Zikeji@programming.dev 2 points 1 week ago

Here’s an archive link in case anyone else refuses to give Substack views due to their affinity for Nazis:

https://archive.is/CmAgB

[–] Zikeji@programming.dev 9 points 1 week ago

I was looking at building a new PC but I can't stomach paying 5x the price for RAM. I'll just have to wait it out. Though if the price of components other than RAM lower I might consider buying up parts, I'll just have to watch.

[–] Zikeji@programming.dev 21 points 1 week ago (1 children)

When I was 15 or so I was hired from an ad on Craigslist for photo editing - just basic touching up, but like a thousand or so photos. The caveat was - softcore porn. I didn't mind, money is money. My very Christian family who found out however - they did mind. My sister ended up finishing the editing for me.

[–] Zikeji@programming.dev 3 points 2 weeks ago

I new product he helped release. So the former.

[–] Zikeji@programming.dev 16 points 2 weeks ago (2 children)

My former coworker left to work at Flock in their R&D department and every time I see Flock popup I check his LinkedIn to see if he's still there and hyup. I didn't take him for the type, but I mean as recently as a month ago he was praising them.

[–] Zikeji@programming.dev 2 points 2 weeks ago* (last edited 2 weeks ago)

If the title is interesting I'll read the text and if I decide to reply there's a good chance I'll sigh and discard my comment and move on.

Although sometimes I won't notice a post with an image has text underneath.

[–] Zikeji@programming.dev 5 points 3 weeks ago* (last edited 3 weeks ago)

My thoughts exactly. I thought maybe the ghost was along for the ride so.tbe human was "the vehicle & driver" but frame 1 makes it pretty clear that isn't the case.

One other possibility is the ghost is viewing the rating the human left but that's a stretch lol

[–] Zikeji@programming.dev 18 points 4 weeks ago* (last edited 4 weeks ago) (6 children)

It's also more distinct. CP has many potential definitions. CSAM only has the one I'm aware of.

[–] Zikeji@programming.dev 5 points 1 month ago (1 children)

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}`);

view more: next ›