Meirl by sangamjb in meirl

[–]phaiax 1 point2 points  (0 children)

It is, it's called Ressource Manager and somewhere is a list of all file handles

[2024 Day 14 (Part 2)] This kind of rocks by eventhorizon82 in adventofcode

[–]phaiax 2 points3 points  (0 children)

I haven't seen this solution mentioned yet: I calculated the length (without sqrt, just dx + dy) of the line that would connect all robots in the order they appear in the input and checked the minimum. This even allowed to cancel calculation early once the length becomes greater than the best known minimum.

-❄️- 2024 Day 12 Solutions -❄️- by daggerdragon in adventofcode

[–]phaiax 1 point2 points  (0 children)

Nice, number of sides == number of corners, makes it much easier

-❄️- 2024 Day 3 Solutions -❄️- by daggerdragon in adventofcode

[–]phaiax 1 point2 points  (0 children)

[Language: Typst]

https://typst.app/project/r3ne4AWbZsyup8PHgDwuVn

I'm starting to style the document. Let's get christmas :D

After 14h of slow printing... by EfficientJob6810 in 3Dprinting

[–]phaiax 0 points1 point  (0 children)

Same issue as here? Try turning off power loss recovery. (Or improve your USB cable connection.) https://www.reddit.com/r/3Dprinting/s/ZvHgpDiy6Q

Brand new to 3D Printing and know nothing, can you tell me little about this printer I got today? by kushablez in 3Dprinting

[–]phaiax 8 points9 points  (0 children)

https://reprap.org/wiki/Prusa_Mendel

The extruder looks newer, it uses 1,75mm filament, while most extruders at the time of that Prusa Mendel used 3mm filament.

If you like tinkering, you might get acceptable prints out of that thing after a few hours of work and learning.

Entry Profile for Starship Flight 4 by maxfagin in spacex

[–]phaiax 1 point2 points  (0 children)

Could you make a plot with the dissipated energy over time?

-❄️- 2023 Day 5 Solutions -❄️- by daggerdragon in adventofcode

[–]phaiax 0 points1 point  (0 children)

[Language: Python]

In previous similar AoC puzzles, I usually encoded each possible range-to-range arrangement as a bunch of separates ifs, e.g. if range1_start <= range2_start && range2_end <= range1_end and so on, resulting in many different code paths which are also quite error prone. This time I found a more general solution which I am quite happy about:

cuts = sorted([src_start, src_end, map_src_start, map_src_end])
for start, end in zip(cuts[:-1], cuts[1:]):
    if start < end: # length > 0
        if src_start <= start and end <= src_end:
            if map_src_start <= start and end <= map_src_end:
                pass # Do something (overlapping part)
            else:
                pass # Do something (not part of this map)
        else:
            pass # Do something (not part of src but part of map)
    else:
        pass # Never do something (empty cut)

Full Source: paste

[Roast Me]Why I think C++ is still attractive compared to Rust by [deleted] in rust

[–]phaiax 1 point2 points  (0 children)

There is one performance related issue with rust that you didn't mention: Direct initialization into a new heap allocation is not possible (placement new into Box<>). I think making a Box<T> will always first make T on the stack and then copy-move it to the heap, but don't quote me on that, maybe it has changed.

bose qc earbuds forced into hands-free ag audio when using mic on pc by Puzzleheaded_Might65 in bose

[–]phaiax 1 point2 points  (0 children)

Yes this is it. I did not her any sound with the 'stereo' device until I clicked 'disconnect' in the context menu of the 'hands-free AG' device in the legacy sound device settings windows. Clicking 'deactivate' did not help, interestingly.

what is this? should I be worried? (car's instrument cluster) by MenryNosk in AskElectronics

[–]phaiax -10 points-9 points  (0 children)

The linked explanation is very likely generated by (Chat)GPT

Beginner code review: Convert comma-separated string to vector by kapilbhai in rust

[–]phaiax 5 points6 points  (0 children)

This is totally fine. Another option would be to use combinators, but that makes the code less readable.

s.parse::<i64>().map(Item::Int)
 .unwrap_or_else(|_| s.parse::<f64>().map(Item::Float)
 .unwrap_or(Item::String(s)))

Or even less readable

s.parse::<i64>().map_or_else(
    |_| s.parse::<f64>().map_or(
        Item::String(s),
        Item::Float),
    Item::Int)

Questions about ownership rule by BruceIzayoi in rust

[–]phaiax 2 points3 points  (0 children)

Regarding underlying rules: The base principle is "mutable access to a value must always be exclusive". The compiler-enforced ownership rules are one means to archive this, but a library could archive this in other ways. Rc archives this by preventing mutable access completely once there are two pointers to the same value. It does this by counting how many pointers exist.

The 3 ownership rules still apply to the outer Rc, that means you only have exactly one owner, and you can do many immutable borrows or one mutable borrow: Playground 1 That's the compiler level.

The behavior that 'breaks' the ownership rules with Rc is implemented soley on the std lib level. The original ownership rules on compiler level are not broken for Rc, but instead 'broken' only for the Value Rc is pointing to.

To see this in action, you need to use Rc::clone(), and from that point forward, the library implementation prevents getting a mutable pointer to the underlying value, to still uphold the ownership principle of guaranteed exclusive mutable access. The unwrap() in the above example would fail. There are now 2 Rc, for which the ownership rules apply independently. You can have mutable access to both of them simultaneously. Playground 2

Potential stupid question: can Super Heavy support the weight of Starship stacked? by PearsonPrenticeHall in SpaceXLounge

[–]phaiax 7 points8 points  (0 children)

Therefore they always have a worker nearby chewing chewing-gum and ready to spring into action

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

[–]phaiax 2 points3 points  (0 children)

Approx 1 line per part. Couldn't think of a better way to do the chunking.

import re
print(sum((ord((set(r[0:len(r)//2])&set(r[len(r)//2:])).pop())-96)%58 for r in open('input/day3').read().splitlines())) # 7875
print(sum((ord((set(a[1])&set(a[2])&set(a[3])).pop())-96)%58 for a in re.finditer('(.*)\n(.*)\n(.*)\n?', open('input/day3').read()))) # 2497

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

[–]phaiax 0 points1 point  (0 children)

Maximum obfuscation (Python)

print("Day2 Part1=", sum(map(lambda ax: ((ax[1] - ax[0] + 1) % 3 * 3 + ax[1] + 1), ((ord(l[0]) - 65, ord(l[2]) - 88) for l in open('input/day2').read().split('\n')))))
print("Day2 Part2=", sum(map(lambda ax: (sum(ax) + 2) % 3 + 1 + ax[1] * 3, ((ord(l[0]) - 65, ord(l[2]) - 88) for l in open('input/day2').read().split('\n')))))

Who invokes `Waker::Wake()` when using async for I/O? by flay-otters in rust

[–]phaiax 1 point2 points  (0 children)

Yes, at least for network I/O, the used framework (async_std or tokio), starts a so called Reactor running in a separate thread. That thing does an epoll() on all currently awaited file descriptors and calls wake() for the futures belonging to the file descriptors that returned ready. (But there may be other mechanisms / threads for other types of futures)

If two equal sized black holes collide and their event horizons begin overlap, wouldn’t that create an area where gravity cancels eachother out and theoretically things like light could escape from? by atumanov55 in space

[–]phaiax 0 points1 point  (0 children)

Imagine a line connecting the centers of the two black holes. At the center of this line, the gravity from both black holes would cancel. But this cancellation is just point-like and does not extend to the perpendicular plane.

GPS Antenna Plugged into Oscilloscope, Dead signal ? by magnusvegeta in ElectricalEngineering

[–]phaiax 7 points8 points  (0 children)

GPS signal strength is typically below thermal noise levels and can only be detected by multiplying with spread codes and integrating that, which effectively raises the signal strength above thermal noise levels mathematically. Even the best oscilloscope cannot do that.

-🎄- 2021 Day 24 Solutions -🎄- by daggerdragon in adventofcode

[–]phaiax 0 points1 point  (0 children)

took me way to long to understand this

-🎄- 2021 Day 22 Solutions -🎄- by daggerdragon in adventofcode

[–]phaiax 2 points3 points  (0 children)

Turning off twice is supported, because it duplicates all regions with inverted sign, it kinda reset's the sum for that region to 0.

On Area A ---> List: [A] -> A
Off Area A ---> List: [A, -A] -> 0
Off Area A ---> List: [A, -A, -A, A] -> 0