Zikeji

joined 2 years ago
[โ€“] Zikeji@programming.dev 3 points 1 week ago

Javascript

More bruteforcing! There are probably better ways to do this but I'm happy enough with this lol.

SolutionYou can replace the require('fs') on the first line with the input and run it in your browser console as well.

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

let idsPart1 = [];
let idsPart2 = [];

input.split(',').forEach(range => {
    const [start, end] = range.split('-').map(v => parseInt(v, 10));
    let cursor = start;

    while (cursor <= end) {
        const cursorString = cursor.toString(10);

        // part 1 check
        let halfLength = Math.floor(cursorString.length / 2);
        let left = cursorString.slice(0, halfLength);
        let right = cursorString.slice(halfLength, cursorString.length);
        if (left === right) {
            idsPart1.push(cursor);
        }

        // part 2 check
        let sequenceLength = 1;
        while (sequenceLength <= halfLength) {
            const sequence = cursorString.slice(0, sequenceLength);
            let builtString = sequence;
            while (builtString.length < cursorString.length) {
                builtString = `${builtString}${sequence}`;
            }
            if (builtString === cursorString) {
                idsPart2.push(cursor);
                break;
            }

            sequenceLength += 1;
        }

        cursor += 1;
    }
})

const answer1 = idsPart1.flat().reduce((acc, cur) => acc += cur, 0);
const answer2 = idsPart2.flat().reduce((acc, cur) => acc += cur, 0);

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

[โ€“] Zikeji@programming.dev 5 points 1 week ago (1 children)

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 1 week ago

Streaming like movies and TV, or like Twitch?

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

[โ€“] Zikeji@programming.dev 100 points 2 weeks ago (7 children)

It's worth noting that Ozempic face is a side effect of rapid weight loss, not a side effect of Ozempic.

[โ€“] Zikeji@programming.dev 70 points 3 weeks ago

If I didn't know Trump was a flip flopping erratic personality him saying they have a lot on common would be very concerning lol.

[โ€“] Zikeji@programming.dev 12 points 3 weeks ago (1 children)

Does not appear to be the correct MR. Comments on the issue allude to "they never pushed it" so sounds like there never was an MR. Watching the announcement where they demo'd it, it wrote much more than is in that MR. Not to defend OpenAI, I hate vibe coded solutions that add so many useless comments.

Write. Readable. Code.

[โ€“] Zikeji@programming.dev 18 points 3 weeks ago

THERE'S NO LAWS AGAINST THE POKEMON BATMAN

[โ€“] Zikeji@programming.dev 26 points 3 weeks ago

Draw her finding a drawing of herself online and looking around suspiciously for the camera

[โ€“] Zikeji@programming.dev 22 points 3 weeks ago (2 children)

This but every outfit is the same exact outfit, American Psycho style.

[โ€“] Zikeji@programming.dev 23 points 3 weeks ago (4 children)

This is title gore (not OP, the original article). The title reads like the cleaner was already dead. What's wrong with just "charged with murder of cleaner who came to his door by mistake"?

[โ€“] Zikeji@programming.dev 3 points 3 weeks ago

Your connection being fine during downtime is a new detail not in your original post that changes the dynamics. That being said I believe my other response should be helpful.

[โ€“] Zikeji@programming.dev 3 points 3 weeks ago (1 children)

Well, it can't hurt to cross it off. You don't need to get a domain from a registrar that offers dynamic DNS, you just need to register a domain (or try another dynamic DNS like the other user suggested) and use a DNS provider that is free and offers an API. I personally use Cloudflare, there are plenty of guides for setting up a dynamic record on CF.

For registering a domain you can use an affordable registrar, I'm a Porkbun customer - for a .com domain it's like $11 for a year. No need to spend monthly.

view more: โ€น prev next โ€บ