this is travelling salesmen, eh? i'm pretty sure at least.
![](https://i.rdrama.net/e/chudsey.webp)
![:marseynotes: :marseynotes: :I prefer to speak in cats:](https://i.rdrama.net/i/hats/Three Lil Marseys.webp?h=10)
day 16 aoc thread: the np is complete
- 29
- 13
Now playing: Fear Factory (Tard Mix) (DKC).mp3
Top Poster of the Day:
911roofer
![](https://i.rdrama.net/images/163936841726r.webp)
![Cosmonaut Helmet - Yuri Gagarsey, hero of the Soviet Union!](https://i.rdrama.net/i/hats/Cosmonaut Helmet.webp?h=10)
Current Registered Users: 30,845
![sidebar image](https://i.rdrama.net/images/17001292996389685.webp)
tech/science swag.
Guidelines:
What to Submit
On-Topic: Anything that good slackers would find interesting. That includes more than /g/ memes and slacking off. If you had to reduce it to a sentence, the answer might be: anything that gratifies one's intellectual laziness.
Off-Topic: Most stories about politics, or crime, or sports, unless they're evidence of some interesting new phenomenon. Videos of pratfalls or disasters, or cute animal pictures. If they'd cover it on TV news, it's probably lame.
Help keep this hole healthy by keeping drama and NOT drama balanced. If you see too much drama, post something that isn't dramatic. If there isn't enough drama and this hole has become too boring, POST DRAMA!
In Submissions
Please do things to make titles stand out, like using uppercase or exclamation points, or saying how great an article is. It should be explicit in submitting something that you think it's important.
Please don't submit the original source. If the article is behind a paywall, just post the text. If a video is behind a paywall, post a magnet link. Fuck journos.
Please don't ruin the hole with chudposts. It isn't funny and doesn't belong here. THEY WILL BE MOVED TO /H/CHUDRAMA
If the title includes the name of the site, please leave that in, because our users are too stupid to know the difference between a url and a search query.
If you submit a video or pdf, please don't warn us by appending [video] or [pdf] to the title. That would be r-slurred. We're not using text-based browsers. We know what videos and pdfs are.
Make sure the title contains a gratuitous number or number + adjective. Good clickbait titles are like "Top 10 Ways to do X" or "Don't do these 4 things if you want X"
Otherwise editorialize. Please don't use the original title, unless it is gay or r-slurred, or you're shits all fucked up.
If you're going to post old news (at least 1 year old), please flair it so we can mock you for living under a rock, or don't and we'll mock you anyway.
Please don't post on SN to ask or tell us something. Send it to [email protected] instead.
If your post doesn't get enough traction, try to delete and repost it.
Please don't use SN primarily for promotion. It's ok to post your own stuff occasionally, but the primary use of the site should be for curiosity. If you want to astroturf or advertise, post on news.ycombinator.com instead.
Please solicit upvotes, comments, and submissions. Users are stupid and need to reminded to vote and interact. Thanks for the gold, kind stranger, upvotes to the left.
In Comments
Be snarky. Don't be kind. Have fun banter; don't be a dork. Please don't use big words like "fulminate". Please sneed at the rest of the community.
Comments should get more enlightened and centrist, not less, as a topic gets more divisive.
If disagreeing, please reply to the argument and call them names. "1 + 1 is 2, not 3" can be improved to "1 + 1 is 3, not 2, mathfaggot"
Please respond to the weakest plausible strawman of what someone says, not a stronger one that's harder to make fun of. Assume that they are bad faith actors.
Eschew jailbait. Paedophiles will be thrown in a wood chipper, as pertained by sitewide rules.
Please post shallow dismissals, especially of other people's work. All press is good press.
Please use Slacker News for political or ideological battle. It tramples weak ideologies.
Please comment on whether someone read an article. If you don't read the article, you are a cute twink.
Please pick the most provocative thing in an article or post to complain about in the thread. Don't nitpick stupid crap.
Please don't be an unfunny chud. Nobody cares about your opinion of X Unrelated Topic in Y Unrelated Thread. If you're the type of loser that belongs on /h/chudrama, we may exile you.
Sockpuppet accounts are encouraged, but please don't farm dramakarma.
Please use uppercase for emphasis.
Please post deranged conspiracy theories about astroturfing, shilling, bots, brigading, foreign agents and the like. It degrades discussion and is usually mistaken. If you're worried about abuse, email [email protected] and dang will add you to their spam list.
Please don't complain that a submission is inappropriate. If a story is spam or off-topic, report it and our moderators will probably do nothing about it. Feed egregious comments by replying instead of flagging them like a pussy. Remember: If you flag, you're a cute twink.
Please don't complain about tangential annoyances—things like article or website formats, name collisions, or back-button breakage. That's too boring, even for HN users.
Please seethe about how your posts don't get enough upvotes.
Please don't post comments saying that rdrama is turning into ruqqus. It's a nazi dogwhistle, as old as the hills.
Miscellaneous:
The quality of posts is extremely important to this community. Contributors are encouraged to provide high-quality or funny effortposts and informative or entertaining comments. Please refrain from posting the following:
Boring wingcucked nonsense nobody cares about that belongs in chudrama
Normie shit everyone already knows about
Anything that doesn't gratifify one's intellectual laziness
Bimothy-tier posts
Anything that the jannies don't like
Jannies reserve the right to exile baby ducks from this hole at any time.
We reserve the right to exile you for whatever reason we want, even for no reason at all! We also reserve the right to change the guidelines at any time, so be sure to read them at least once a month. We also reserve the right to ignore enforcement of the guidelines at the discretion of the janitorial staff. This hole is a janny playground, participation implies enthusiastic consent to being janny abused by unstable alcoholic bullies and loser nerds who have nothing better to do than banning you for any reason or no reason whatsoever.
[[[ To any NSA and FBI agents reading my email: please consider ]]]
[[[ whether defending the US Constitution against all enemies, ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]
/h/slackernews SETTINGS /h/slackernews MODS /h/slackernews LOG /h/slackernews EXILEES /h/slackernews FOLLOWERS /h/slackernews BLOCKERS
Jump in the discussion.
No email address required.
i am unbelievably filtered![:marseyitsover: :marseyitsover:](/e/marseyitsover.webp)
Jump in the discussion.
No email address required.
Jump in the discussion.
No email address required.
More options
Context
Jump in the discussion.
No email address required.
Jump in the discussion.
No email address required.
Jump in the discussion.
No email address required.
More options
Context
More options
Context
More options
Context
More options
Context
Well after a lot of time trying to find the bug, i realized that we are always supposed to start at 'AA', but instead i started at the first line of the input. Literally would have been done like after like 30 minutes if I had paid attention to that...
I solve part two simply by dfs through the part once, and then if time gets to zero, i restart the dfs.
Part one ran in 661ms, Part two in 38004ms. Could most likely really speed this up by turning nodes with a flow rate of 0, into longer tunnels, but really don't care anymore.
Jump in the discussion.
No email address required.
LMAO same. Though I got lucky in that the thing told me that my answer is too high, so it must've been a bug and not a wrong algorithm, and I was lowkey bothered by writing the code that extracted starting node name from the first node without an explicit instruction to do so, so it was on my mind, so I immediately reread the task and oh shit.
Neat!
Jump in the discussion.
No email address required.
More options
Context
Mommy is soooo proud of you, sweaty. Let's put this sperg out up on the fridge with all your other failures.
Jump in the discussion.
No email address required.
More options
Context
More options
Context
part 1 optimized code
About 1.1s runtime on input, which is tremendous compared to early iterations of the code.
What I do is shortcut paths that take zero-flow nodes, prune those zero-flow nodes (all but AA), compute floyd-warshall and replace the actual graph by this one, which basically skips having to go to already activated nodes or travel through useless nodes. Also replaced my queue BFS with a recursive DFS since most of the BFS was spent inserting into the queue (like 89% lmao). Removed the useless dict to skip identical situations (happened literally only once ever).
Jump in the discussion.
No email address required.
Okay here's part 2. Tried a global variable approach because doing shit with recursion is usually painful, but ended up with very slow code and a result with 200k+ paths. Did it the recursive way and only 113 paths to search lmao.
I am officially unfiltered
Jump in the discussion.
No email address required.
More options
Context
More options
Context
Got a tip on part 2![:marseysuicide: :marseysuicide:](/e/marseysuicide.webp)
officially filtered![:marseywall: :marseywall:](/e/marseywall.webp)
Jump in the discussion.
No email address required.
More options
Context
im just so fricking sick of my solution working on the test input but not the real input. it's happened like 4 days in a fricking row now. how am i supposed to debug this shit?
Jump in the discussion.
No email address required.
The old school way, like you'd do if you didn't have a test input at all!
By "doesn't work" do you mean that it gives a wrong answer? Is the answer too low (you could be using a wrong algo) or too high (you have a bug)? Have you noticed that the starting node is "AA" not the first line in input
?
Jump in the discussion.
No email address required.
NEVER MIND
I BEAT PART 1 HOLY SHIT
i originally had a thing that checked if the time spent was above 10 and pressure was less than 500, then it would abort (to stop it taking fucking forever). that worked on the test, but gave the wrong answer on the real input. i changed it to time > 15 instead and it worked, which was a much more reasonable reason to fail than the previous ones. pretty sure the code i wrote is extremely unholy; i barely even remember the parts i wrote at the start of the day. pretty happy tho
Jump in the discussion.
No email address required.
Congratulations! Btw, you don't have to explicitly call
graph.add_node
unless you want to add attributes on it or something.Jump in the discussion.
No email address required.
More options
Context
Jump in the discussion.
No email address required.
More options
Context
All those words won't bring daddy back.
Jump in the discussion.
No email address required.
Jump in the discussion.
No email address required.
More options
Context
More options
Context
More options
Context
More options
Context
More options
Context
Have a solution that works for the test case in p1, but not sure if it works with the real data or just take a bit.
The idea is basically a depth first search and some memoization to store path we have already tried.
Jump in the discussion.
No email address required.
idk if that will work well. they could add weird cases were half going into a branch and later completing it is the best solution.
unless u can solve np. in which case, i'm so down for revolutionizing cs in the process.![:marseyparty2: :marseyparty2:](/e/marseyparty2.webp)
Jump in the discussion.
No email address required.
My solution actually works fast now, the issue was that the hashmap I used for memo used a shitty hash function, my results are still wrong, but I believe that is due to me entering the input wrong. Had to do other things though so couldn't test it properly so far.
But the other issues is that you can visit the same node multiple times, you can just not turn the valve more than once. This massively increase the amount of possible routes, which forces you into some kind memo solution.
Jump in the discussion.
No email address required.
i don't think u can use memoizing to significantly speed up an np-complete problem into not something np, not without inadvertently missing parts. that's kind of why they are np-complete. ur also going to be unbelievably fricked by part 2
my answer to p1 takes < 60ms in js of all things.
Jump in the discussion.
No email address required.
Are you on the leaderboard?
I'm confused by several people who apparently solved part 1 by simply running DFS on a reduced graph. It still has 15 nodes (plus technically a separate starting node but that doesn't matter), so if you enumerate all possible routes, without pruning the search somehow, that's 15! ~= 10^12 of them, which you can't do in any reasonable amount of time. So how does your code work?
Myself, I did this: you can do dynamic programming using (current node, set of opened valves) and implied current turn as a key. That is, if you know that you can open valve #5 at turn 10 while having opened valves 3 and 7 already, with a maximum score of whatever, then you can ignore how you got to that state. And if you have a priority queue keyed by current turn and steadily work through it, then that's your correct DP computation order (though I somehow convinced myself that I need some extra complications). So now instead of 15! I'm traversing a graph with 15 * 2^15 nodes (plus some spread of future current turns in the queue).
Jump in the discussion.
No email address required.
u can't actually enumerate out that many cause of the max cost. if you jump across the map and back - it will be very few nodes you enumerate out. if they removed max cost then i suppose it wouldn't be feasible.
i'm prolly gunna have to do the dynamic approach cause p2 with plain recursion is kinda nonsense.
Jump in the discussion.
No email address required.
Oh, I see. Hmmm. Interesting.
Note how I did part 2 in 15 minutes which might be a hint in itself![:marseysmug2: :marseysmug2:](/e/marseysmug2.webp)
Jump in the discussion.
No email address required.
More options
Context
More options
Context
More options
Context
More options
Context
More options
Context
More options
Context
More options
Context
APLsisters, this might be the end of the line.....
Jump in the discussion.
No email address required.
Not just graphshit but NP-hard graphshit. Good luck.
Jump in the discussion.
No email address required.
More options
Context
More options
Context
Goddamn this one was a fucking nightmare. I thought I was hot shit realizing that you can turn the problem into travelling salesman based on the shortest paths between all nonzero valves since you can reasonably assume you'll be beelining between them at all times, but figuring out how to adapt to multiple salesmen took me ages despite it being fairly simple in the end. Just glad I squeezed through the filter tbh.
Jump in the discussion.
No email address required.
You sat down and wrote all this shit. You could have done so many other things with your life. What happened to your life that made you decide writing novels of bullshit here was the best option?
Jump in the discussion.
No email address required.
More options
Context
More options
Context
AOC's Nipples?
Jump in the discussion.
No email address required.
More options
Context
Sneeds-Feeduck-And-Seeduck make an account already!
Jump in the discussion.
No email address required.
More options
Context
Oh boy. More CGI nonsense for mentally underdeveloped manchildren. Wonderful.
The MCU films have become an endless and risk-free pack of Taco Bell mild sauce that is slowly dumbing down moviegoers and re-calibrating what a blockbuster film can be.
Disney is a black hole swallowing everything in its path until it is the only universe we have left. I bet you dollars to donuts no one here saw Silence or The Nice Guys in theaters but borrowed their dad's Subaru so you could see Ant-Man and the Wasp opening weekend.
I come from a generation where a creative "face-swapping" blockbuster film with $100M+ budget and an R-Rating from a foreign director could get a prime wide release date and make money. Now because of infantile consoomers who routinely get excited to pay for toy commercials with DoD propaganda, budgets are being slashed, young filmmakers are selling out, legends are relegated to streaming, and less people are getting laid.
To be clear, if you're a grown adult and you're genuinely excited for a fringe piece of shit superhero movie like Spider-Man: We Brought Back the Gambling Addict Who Dates Women Half His Age, you're a goddarn useless dork.
The MCU is crack for dumb people. They got you strung out and morons just blindly line up saying “the last couple MCU flicks have been lame, but I've seen all 47 of them to this point so I better watch Man-Ant vs The Gobots vs Dr Doom!”
McDonalds is quick, easy, cheap, and completely average in every way. Sure, from time to time it hits the spot but I usually end up feeling like shit and my butt leaks for 24 hours. It's more work, more of a challenge, and sometimes can be disappointing but I'd much prefer to seek out a unique burger joint that at least will try to offer their own spin on things. I'm not 100% sure what I'll get but it might be something interesting. Now everything is built on franchise recognition and familiarity and more and more people are conceding everyday - which puts my ability to go to my kind of restaurant at risk. Companies follow the money and may offer the occasional artisan option - but if it ain't, selling it'll be replaced something easier to sell. Heck, these lazy morons don't even dine out anymore - they sit on their couch and have their compressed, shitty, and inoffensive content delivered directly to their homes.
Happy Meal fricks who justify watching a decade of toy commercials and hand every nickel to corporations who call movies “content” not realizing they're setting the rest of us up are the worst.
Watch what you want, but when I can't see something like First Reformed or Portrait of a Lady on Fire or American Animals or Only God Forgives on a big screen because the theaters have got 16 screens all playing Hawkeye vs Han Solo, I'm blaming you.
Jump in the discussion.
No email address required.
More options
Context