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.
Nice. Software developer, gamer, occasionally 3d printing, coffee lover.
- 1 Post
- 675 Comments
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.
I was wondering why it was extra cold today. Makes sense now, thanks!
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
Zikejito
Technology@lemmy.world•A Developer Accidentally Found CSAM in AI Data. Google Banned Him For ItEnglish
19·12 天前It’s also more distinct. CP has many potential definitions. CSAM only has the one I’m aware of.
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}`);
I know if I were to setup the V2L feature on my car to power my home it would look like this (the manual way). But there would be a physical interlock that prevents mains power from being on while this is plugged in.
That file is for debugging. Seems like something is setting
SSLKEYLOGFILE. You could try unsetting it (unset SSLKEYLOGFILE). Something is probably setting it in your shell, so you probably want to look at your specific shell configs for a more permanent solution.
Zikejito
Mildly Infuriating@lemmy.world•The most invasive cookie/tracker option is listed as “Platinum” while the most privacy-respecting option is merely “Silver”English
90·18 天前Cookie consent dialogs can fuck off and die in general. Always using dark patterns to try and trick you into choosing the worst option.
There are quite a few EVs that come with simple controls (respectively). It’s just the companies spawned to make EVs that decide to reinvent the wheel.
I’ve had a Chevy Bolt EUV and a Hyundai Ioniq 5 - both have physical buttons for most of what I want.
Javascript
Short and sweet. Basically just handle all the range overlaps for part 2 and then do basic subtraction to get the answer.
spoiler
const input = require('fs').readFileSync('input-day5.txt', 'utf-8'); /** @typedef {[number, number]} Range */ /** @type {[Range[], number[]]} */ const [freshRanges, availableIngredients] = input.split("\n\n").map(l => l.split("\n")).map((l, i) => (i === 1) ? l.map(v => parseInt(v, 10)) : l.map(v => v.split('-').map(vv => parseInt(vv, 10)))); let freshOnHand = 0; for (const ingredient of availableIngredients) { for (const [start, stop] of freshRanges) { if (ingredient >= start && ingredient <= stop) { freshOnHand += 1; break; } } } console.log(`Part 1 Answer: ${freshOnHand}`); const sortedRanges = [...freshRanges].sort((a, b) => a[0] - b[0]); const mergedRanges = []; let current = sortedRanges[0]; for (let i = 1; i < sortedRanges.length; i++) { const [nextStart, nextEnd] = sortedRanges[i]; if (nextStart <= current[1] + 1) { current = [current[0], Math.max(current[1], nextEnd)]; } else { mergedRanges.push(current); current = [nextStart, nextEnd]; } } mergedRanges.push(current); const freshIngredientCount = mergedRanges.reduce((acc, [start, stop]) => acc + ((stop + 1) - start), 0) console.log(`Part 2 Answer: ${freshIngredientCount}`);
Saved this. My doggo is nearly 15 and whole he’s still healthy I am much too afraid of losing him. I suspect I’ll need a reminder like this in the future.
Javascript
After smashing out a functional version in 20 minutes, I converted it into a OOP approach for a more appealing solution.
Solution
const input = require('fs').readFileSync('input-day4.txt', 'utf-8'); class PrintingDepartmentMap { /** @param {string} input */ constructor(input) { /** @type {number[][]} */ this.map = input.split("\n").map(r => r.split('').map(v => v === '@' ? 1 : 0)); } /** * @param {number} x * @param {number} y * @returns {number} the value of that tile, or -1 if invalid */ getCoord(x, y) { if (x < 0 || y < 0 || x >= this.map[0].length || y >= this.map.length) { return -1; } return this.map[y][x]; } /** * @param {number} x * @param {number} y * @returns {number} the number of adjacent tiles that are >= 1 */ countAdjacent(x, y) { return [ // top-left this.getCoord(x - 1, y - 1) >= 1, // top this.getCoord(x, y - 1) >= 1, // top-right this.getCoord(x + 1, y - 1) >= 1, // right this.getCoord(x + 1, y) >= 1, // bottom-right this.getCoord(x + 1, y + 1) >= 1, // bottom this.getCoord(x, y + 1) >= 1, // bottom-left this.getCoord(x - 1, y + 1) >= 1, // left this.getCoord(x - 1, y) >= 1 ].reduce((acc, v) => !!v ? acc + 1 : acc, 0); } /** * transform in place the map replacing any rolls (1) with (2) if they are accessible * @returns {PrintingDepartmentMap} */ markAccessable() { for (let y = 0; y < this.map.length; y += 1) { for (let x = 0; x < this.map[0].length; x += 1) { if (this.map[y][x] < 1) continue; if (this.countAdjacent(x, y) < 4) { this.map[y][x] = 2; } } } return this; } /** @returns {number} the number of removed rolls */ removeAccessable() { let removed = 0; for (let y = 0; y < this.map.length; y += 1) { for (let x = 0; x < this.map[0].length; x += 1) { if (this.map[y][x] === 2) { removed += 1; this.map[y][x] = 0; } } } return removed; } } const map = new PrintingDepartmentMap(input); let removed = 0; while (true) { const justRemoved = map.markAccessable().removeAccessable(); if (removed === 0) { console.log(`Part 1 Answer: ${justRemoved}`); } if (justRemoved === 0) break; removed += justRemoved; } console.log(`Part 2 Answer: ${removed}`);
Sure, which makes the transition suck even lol.
:(
Time to switch to yarn or something.
Javascript
More bruteforcing! There are probably better ways to do this but I’m happy enough with this lol.
Solution
You 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}`);
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}`);
Zikejito
Technology@lemmy.world•How do streaming sites work? Not the "official" the other 'free' onesEnglish
5·23 天前Streaming like movies and TV, or like Twitch?
And free as in the legal free ones, or illegal free ones?











I new product he helped release. So the former.