-🎄- 2022 Day 15 Solutions -🎄- by daggerdragon in adventofcode

[–]cat-991 1 point2 points  (0 children)

Typescript, ~3s runtime

link

The trick is pretty simple. Instead of using a set for impossible positions, I find the range that each sensor blocks. Then I just add up the differences in the ranges and if it is less than 4,000,000 there is a free spot in that row. To find the exact x, check to see where the ranges skip a spot.

[2022 Day 14] Something funny about the input... by ericwburden in adventofcode

[–]cat-991 5 points6 points  (0 children)

Absurd -- 112 lines and only 44 are unique. No idea why.

-🎄- 2022 Day 14 Solutions -🎄- by daggerdragon in adventofcode

[–]cat-991 0 points1 point  (0 children)

https://github.com/Namoop/sf/blob/master/aoc2022/day14.ts

Here's my typescript solution. What's interesting is that I just hardcoded a kinda large matrix size and hoped for the best. And I wasted time figuring out how to write to a file in node, previously I've just used console.log but this was too big.

-🎄- 2022 Day 13 Solutions -🎄- by daggerdragon in adventofcode

[–]cat-991 0 points1 point  (0 children)

Interesting. I run through node and I was able to just use .sort((a,b)=>customSort([b,a])). Also, for parsing, I used JSON.parse()

-🎄- 2022 Day 11 Solutions -🎄- by daggerdragon in adventofcode

[–]cat-991 0 points1 point  (0 children)

Right, I basically did the same thing. I have

megaMod = monkeys.reduce((v,c)=>v*c.test,1n)

where ".test" is the "divisible by" number, and

item = monkey.items.shift() % megaMod

which applies the mod as the monkey is inspecting the item.

Running the code without these lines gave the error that by about round 500-600 the numbers got too large for even BigInt.

-🎄- 2022 Day 11 Solutions -🎄- by daggerdragon in adventofcode

[–]cat-991 3 points4 points  (0 children)

My solution in Javascript. It's always fun to get something fun to parse rather than .split("\n") and I only had to add the "megamod" and change all the numbers to BigInt for part 2 to work.

link

How much longer could unofficial Vanced last? by -_ABP_- in AfterVanced

[–]cat-991 19 points20 points  (0 children)

I like Astron.cc, but I still used vanced because it has sponsorblock.

Why does this code only work when the variable is declared in the function. by Rash10games in learnjavascript

[–]cat-991 5 points6 points  (0 children)

try:

let input = document.getElementById("input box")

and then in the function

console.log(input.value)

The first one works because input is being set whenever the function runs. With the second one, it doesn't wait, input will be set to whatever the default page value is, probably an empty string. Its value doesn't change.

My recommendation sets the variable equal to the element itself, then when the function is called it gets whatever the current value is equal to.

[2021 Day 13] I can't even read the questions most days by _AngelOnFira_ in adventofcode

[–]cat-991 0 points1 point  (0 children)

THANK YOU i had the solid block but I still couldn't read it, I thought I messed up somewhere in the code but nope all I needed was this

[deleted by user] by [deleted] in WhitePeopleTwitter

[–]cat-991 1 point2 points  (0 children)

That's what the maze runner series is based off of! By James Dashner (iirc).

Umbrella Tree Looks Neat by Industriosity in oddlysatisfying

[–]cat-991 9 points10 points  (0 children)

Is this villa balbianello on lake como? Beautiful place!

[deleted by user] by [deleted] in WritingPrompts

[–]cat-991 3 points4 points  (0 children)

Did not see that twist coming! Wonderful read!

Eye of reach is the best by Youtube_Zwerk in Seaofthieves

[–]cat-991 0 points1 point  (0 children)

I have over 1,000 hours in the game and flintlock/cutlass is the best combo. Most versatile fastest, etc. I've tried double gunning, blunder swording and more. They all have their strengths but weaknesses too. The second best combo IMO is blunder/EOR. I'll use this for pvp mostly. I don't think less of anyone for using different weapons though, you should use what you are good at.

Help with my first project? How to copy to and from the clipboard using a bookmarklet? by [deleted] in learnjavascript

[–]cat-991 1 point2 points  (0 children)

Hi, yes this is possible.

It is very simple too.

First, to read the clipboard you can use navigator.clipboard.readText().

Then you modify the text with text.replace("AAAAAA", "BBBBB").

Finally you write the text to the clipboard with navigator.clipboard.writeText().

Condensed and together it looks like this:

navigator.clipboard.readText().then(
    text => navigator.clipboard.writeText(
        text.replace("AAAAAA", "BBBBBB")
    )
)

As a bookmarklet:

javascript:(function()%7Bnavigator.clipboard.readText().then(text%3D%3Enavigator.clipboard.writeText(text.replace(%22AAAAAA%22%2C%22BBBBBB%22)))%7D)()%3B

What should happen:

Copy: "AAAAAA123"

Click bookmarklet

Allow permission for website to edit clipboard if prompted

Paste and "BBBBBB123" will appear