cacheson

joined 1 year ago
[–] [email protected] 2 points 8 months ago* (last edited 8 months ago)

Nim

Another least common multiple problem. I kinda don't like these, as it's not practical to solve them purely with code that operates on arbitrary inputs.

[–] [email protected] 15 points 8 months ago

Yeah, I laughed at that bit. Big "I am not a member of the National Socialist German Worker's Party" energy.

[–] [email protected] 2 points 8 months ago

Nim

Part 1 was pretty straightforward. For part 2 I made an ItemRange type that's just one integer range for each attribute. I also made a split function that returns two ItemRange objects, one for the values that match the specified rule, and the others for the unmatched values. When iterating through the workflows, I start a new recursion branch to process any matching values, and continue stepping through with the unmatched values until none remain or they're accepted/rejected.

[–] [email protected] 1 points 8 months ago

Yeah, I read up on ear clipping for a small game dev project a while back, though I don't remember if I actually ended up using it. So my solution is inspired by what I remember of that.

[–] [email protected] 2 points 8 months ago

Yep, I figure it's good exercise to make me think through the problems thoroughly.

[–] [email protected] 3 points 8 months ago (2 children)

Shoelace formula

This would have been really useful to know about. I've committed to a certain level of wheel-reinvention for this event unless I get really stuck, but I'm sure it'll come up again in the future.

[–] [email protected] 2 points 8 months ago* (last edited 8 months ago) (3 children)

Nim

I am not making good time on these anymore.

For part 1, I walked through the dig plan instructions, keeping track of the highest and lowest x and y values reached, and used those to create a character grid, with an extra 1 tile border around it. Walked the instructions again to plot out the trench with #, flood-filled the exterior with O, and then counted the non-O tiles. Sort of similar to the pipe maze problem.

This approach wouldn't have been viable for part 2, due to the scale of the numbers involved. Instead I counted the number of left and right turns in the trench to determine whether it was being dug in a clockwise or counterclockwise direction, and assumed that there were no intersections. I then made a polygon that followed the outer edge of the trench. Wherever there was a run of 3 inward turns in a row, that meant there was a rectangular protrusion that could be chopped off of the main polygon. Repeatedly chopping these off eventually turns the polygon into a rectangle, so it's just a matter of adding up the area of each. This worked great for the example input.

Unfortunately when I ran it on the actual input, I ran out of sets of inward turns early, leaving an "inside out" polygon. I thought this meant that the input must have intersections in it that I would have to untwist somehow. To keep this short, after a long debugging process I figured out that I was introducing intersections during the chopping process. The chopped regions can have additional trench inside of them, which results in those parts ending up outside of the reduced polygon. I solved this by chopping off the narrowest protrusions first.

[–] [email protected] 1 points 8 months ago* (last edited 8 months ago) (1 children)

Nim

Another tough one. Judging by the relative lack of comments here, I wasn't the only one that had trouble. For me this one was less frustrating and more interesting than day 12, though.

I solved part 1 by doing a recursive depth-first search, biasing towards a zigzag path directly to the goal in order to establish a baseline path cost. Path branches that got more expensive than the current best path terminated early. I also stored direction, speed, and heat loss data for each tile entered. Any path branch that entered a tile in the same direction and at the same (or greater) speed as a previous path was terminated, unless it had a lower temperature loss.

This ran pretty slowly, taking around an hour to finish. I took a break and just let it run. Once it completed, it had gotten pretty late, so I did a quick naive modification for part 2 to account for the new movement restrictions, and let that run overnight. The next day it was still running, so I spent some time trying to think of a way to speed it up. Didn't really get anywhere on my own, so I started reading up on A* to refresh my memory on how it worked.

The solution that I arrived at for the rewrite was to use Dijkstra's algorithm to pre-compute a map of what the minimum possible costs would be from each tile to the goal, if adjacent tiles could be moved to without restriction. I then used that as the heuristic for A*. While I was writing this, the original part 2 program did finish and gave the correct answer. Since I was already this far in though, I figured I'd finish the rewrite anyway.

The new program got the wrong answer, but did so very quickly. It turned out that I had a bug in my Dijkstra map. I was sorting the node queue by the currently computed cost to move from that node to the goal, when it instead should have been sorted by that plus the cost to enter that node from a neighbor. Since the node at the head of the queue is removed and marked as finalized on each iteration, some nodes were being finalized before their actual minimum costs were found.

When using the A* algorithm, you usually want your heuristic cost estimate to underestimate the actual cost to reach the goal from a given node. If it overestimates instead, the algorithm will overlook routes that are potentially more optimal than the computed route. This can be useful if you want to find a "good enough" route quickly, but in this case we need the actual best path.

[–] [email protected] 1 points 8 months ago

The volatility is dampened as more people start using it, including using it as an investment. Dampened volatility makes it a worse investment, but a better currency. If you analyze Bitcoin's price history, you'll see that it used to be more volatile than it currently is. This trend is likely to continue, barring some sort of catastrophic failure of the system.

[–] [email protected] 1 points 8 months ago

Looks like this fix for nimsuggest didn't make it in though, so I'm still on devel for now.

1
anime_irl (media.kbin.social)
 
6
anime_irl (media.kbin.social)
 
6
anime_irl (media.kbin.social)
 
3
anime_irl (media.kbin.social)
 
4
anime_irl (media.kbin.social)
 
 

https://kbin.social/m/Animemes

The split between animemes and goodanimemes was due to a conflict that occurred on reddit. There's no need to maintain the division here on kbin though, so I've turned this magazine into a signpost.

4
submitted 10 months ago* (last edited 10 months ago) by [email protected] to c/[email protected]
 

EDIT: Looks like the defederation has been reversed. @db0 Thank you for looking into this quickly.


A commenter in the linked post is suggesting that dbzer0 automatically follows lemmy.world's block list. That seems like kind of a bad idea? In this instance it seems like the LW admins are just following the decision of lemmy.ml's tankie admins, and tankies gonna tank.

 

EDIT: As noted in the linked post, the defederation was a mistake and has been reversed. Thank you to the lemmy.world admins for reviewing this quickly.


I'm not a lemmy.world user, so I'm not directly affected by this defederation. I am a fan of both anime and the fediverse in general though, so I'm concerned about an apparent crackdown on my hobby and by what seems to be an increasingly damaging flaw in the fediverse model.

A few days ago. lemmy.ml defederated from ani.social, a lemmy instance specialized in anime. The only explanation given by Dessalines (lead dev of lemmy, owner of lemmy.ml and lemmygrad.ml) was that it was "full of CSAM". As far as anyone who's commented can tell, there doesn't seem to be any evidence of this whatsoever (see post link for an overview of the discussions). The only CSAM here appears to be in Dessalines' head.

That defederation was annoying, but not all that surprising. Dessalines and his fellow lead dev Nutomic are tankies, and tankies often seem to have a weird hatred of anime fans. The two of them have a history of making self-marginalizing decisions, so the obvious course of action is to just point them out so that people gradually abandon lemmy.ml, and hopefully eventually fork the lemmy codebase.

However, today I found out that lemmy.world had also defederated ani.social, again with no evidence presented for the decision. It looks like the LW admins are just rubber-stamping the bad decision of the lemmy.ml admins, without bothering to investigate at all.

We really can't afford to have the most popular lemmy instance behaving like this. The LW admin team has generally shown more professionalism in that past, so what gives?

 

Those of you that have your account on lemmy.ml may want to consider moving to another instance if you still want to be able to access ani.social.

view more: β€Ή prev next β€Ί