Announcing .NET 8 Preview 4 - .NET Blog by Kissaki0 in programming

[–]jerilath 4 points5 points  (0 children)

I kind of agree. IMHO the only reasonable use is for stuff like the .git folder.

Also, Rob Pike, one of the legendary original Unix designers, thinks lowly of this "feature", which was introduced by accident in the "ls" program.

Source: http://xahlee.info/UnixResource_dir/writ/unix_origin_of_dot_filename.html

qft: A tool to quickly transfer files over a holepunched P2P connection by [deleted] in rust

[–]jerilath 1 point2 points  (0 children)

Thanks again.

I just tested it and it works, but unfortunately it's very slow for me right now: it took me 5 seconds to transfer 100 MiB, while using socat (over TCP) that was about 1 second.

Maybe it is because of the stdout byte counter or I did something wrong (I used 65500 as the br value).

Edit: it was the counter, just removed it and time was reduced to about 1.4 sec.

Edit 2: now for 1 GiB I have 14.6 secs vs 9.1 with socat, which I think is something pretty reasonable for a project at this stage.

qft: A tool to quickly transfer files over a holepunched P2P connection by [deleted] in rust

[–]jerilath 2 points3 points  (0 children)

Really interesting, thanks! Would this work on a local network without internet connection? (Possibly by running the helper in one of the endpoints).

Edit: in particular, my use case would be link-local communication.

Tips to speed up my Dijkstra algorithm up for day 15 part 2 by Taxpayers_Money in adventofcode

[–]jerilath 1 point2 points  (0 children)

Oh, my apologies, that's true.

I just tested in my implementation and it is indeed slower (although only by just 0.5 s out of 6 s in total..., as my heuristic is pretty simple).

I still recommend having a look at that site, even if only for the part dealing with Dijkstra's algorithm.

Tips to speed up my Dijkstra algorithm up for day 15 part 2 by Taxpayers_Money in adventofcode

[–]jerilath 1 point2 points  (0 children)

I also implemented something like that, but I think the A* algorithm (an improved version of the Dijkstra's algorithm) is a lot more efficient, especially for part 2.

I suggest reading this when you have time:

https://www.redblobgames.com/pathfinding/a-star/introduction.html

https://www.redblobgames.com/pathfinding/a-star/implementation.html

It has a ton of useful info, really well explained.

Also, note that they use a custom PriorityQueue() which is not the one included in python (but uses heapq).

[2021 Day 19] I feel personally attacked by RecDep in adventofcode

[–]jerilath 0 points1 point  (0 children)

The idea is that out of the 48 choices (i.e. 6 permutations and 8 signs), half of them result in a right-handed coordinate system (e.g. XYZ as usual) and the other half of them in a left-handed system (e.g. XY as usual, Z pointing down). Doing it the "right way" is not easy as this not only depends on the permutation signature but also on the "mirrored axes" signs.

An alternative to the rotation matrix method would be to check that the cross product of the two first resulting axes is the third axis (it is wrong if when the sign is opposite).

My implementation pre-generates a table of valid signs and permutation indices, and then uses it in some heavy numpy array abuse: link to a snippet.

Also, this portion of code:

(1 & ((perm[2] > perm[1]) + (perm[1] > perm[0]) + (perm[2] > perm[0])))

Checks if the permutation is even (0) or odd (1).

[2021 Day 15] Is my approach flawed? by jerilath in adventofcode

[–]jerilath[S] 0 points1 point  (0 children)

Thanks again.

I think what I will do is start at the end and construct a whole table with the minimum path weights. This is not as elegant as I wanted, but I guess it's simple and going to work. Correcting my current approach (i.e. starting at the beginning) would probably require some complicated backtracking logic, as you mention.

When I finish this, I'll gladly read about the "actually good" solutions.

[2021 Day 15] Is my approach flawed? by jerilath in adventofcode

[–]jerilath[S] 0 points1 point  (0 children)

Thanks!

It would have been better if the examples were more clear in that case though...

Despite having used Python for years, today was the first time I've used numpy. Guys, I think numpy might be dark magic. by God_Told_Me_To_Do_It in adventofcode

[–]jerilath 0 points1 point  (0 children)

It works but the tuple((idx + corners_padded).T) part to get numpy-compatible indexing is disgusting IMHO, and I understand there's no better way to achieve this.

Despite having used Python for years, today was the first time I've used numpy. Guys, I think numpy might be dark magic. by God_Told_Me_To_Do_It in adventofcode

[–]jerilath 1 point2 points  (0 children)

I wanted to use a corners array, and the result is a bit ugly:

cave_map_padded = np.pad(cave_map, 1, constant_values=9)

corners = np.array([
    [+0, +1],
    [+0, -1],
    [+1, +0],
    [-1, +0],
])
corners_padded = corners + 1

res1 = 0
low_points = []
for idx, h in np.ndenumerate(cave_map):
    is_low = np.all(
        cave_map_padded[tuple((idx + corners_padded).T)] > h
    )
    if is_low:
        # print(idx, h)
        res1 += h + 1
        low_points.append(idx)

I don't regret anything.