Chais

joined 2 years ago
[–] [email protected] 3 points 1 week ago (2 children)

Like Silverlight but WASM? Hope it shares the same fate.

[–] [email protected] 3 points 1 week ago

Rückständige Bayern tun rückständige-Bayern-Dinge.

[–] [email protected] 13 points 1 month ago (1 children)

I don't like this type of question. In my experience knowing one language has little impact on learning another. What matters much more is understanding the underlying concepts.
If you grok OOP it doesn't matter if you go from Java to C# or from C++ to Python. Yes, there are differences, but they're mostly syntactic in nature.
So assuming you got the hang of imperative programming and maybe had some exposure to functional programming, too, the concept you're likely to struggle with the most is ownership. Simply because it's a concept that's fairly unique to Rust.
Having come from Java, via C++ and Python and having dabbled with Haskell a bit, I feel like The Book does a decent job of explaining Rust in general and its oddities in particular.

[–] [email protected] 5 points 1 month ago (2 children)
[–] [email protected] 18 points 1 month ago (2 children)

The Swedish government can go suck a lemon.

[–] [email protected] 1 points 1 month ago (1 children)

Because R is incredibly clunky. I've worked with both and never got the hang of R.

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

Of course. But in the end it boils down to: company does something I don't condone, so I don't give them money.

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

the fact that even a small political stand that someone dont agree with can turn them against a company or even a person is crazy to me

Why? I try not to buy from companies that employ child or slave labour (Nestlé) or drain the water supply in drought regions (also Nestlé) or companies that support fascists (Müller and apparently Proton) because voting with my wallet is the only choice I have for even a slim chance of making my opinion heard in this capitalist hellscape.

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

You mean missing documentation?

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

Does Fwy usually speak of themselves in third person?

12
Stuck on day 6, part 2 (sh.itjust.works)
submitted 4 months ago* (last edited 4 months ago) by [email protected] to c/[email protected]
 

I'm not looking for a solution or even code, just a hint. Here's what I currently do:

  1. Add the current position and heading to the recorded path
  2. Check if turning right would lead back onto the recorded path in the same direction we walked it before
  3. Check if the next field is obstructed
    1. If so, turn right
    2. Repeat until no longer blocked
  4. Update current position

This approach works fine for the unit test, but yields a result too low for the puzzle input. I tried adding recursion to the party check, but even 20 levels of recursion didn't sufficiently increase the amount of options found, suggesting I'm missing a mechanism to identify them.

Any clues?

Current state of affairs:

from math import sumprod
from operator import add
from pathlib import Path


def parse_input(input: str) -> list[list[int]]:
    return input.strip().splitlines()


def find_guard(world: list[list[int]]) -> tuple[int]:
    for y, line in enumerate(world):
        x = line.find("^")
        if x > -1:
            return (y, x)
    return (-1, -1)  # No guard


def turn(heading: tuple[int]) -> tuple[int]:
    mat = [(0, 1), (-1, 0)]
    return tuple([sumprod(col, heading) for col in mat])


def step(pos: tuple[int], heading: tuple[int]) -> tuple[int]:
    return tuple(map(add, pos, heading))


def is_blocked(world: list[list[str]], guard: tuple[int], heading: tuple[int]) -> bool:
    pos = step(guard, heading)
    try:
        return world[pos[0]][pos[1]] == "#"
    except IndexError:
        return False


def cast_ray(
    world: list[list[int]], start: tuple[int], heading: tuple[int]
) -> list[tuple[int]]:
    pos = step(start, heading)
    ray = []
    try:
        while world[pos[0]][pos[1]] != "#":
            ray.append(pos)
            pos = step(pos, heading)
    except IndexError:
        # Left the world
        ...
    return ray


def part_one(input: str) -> int:
    world = parse_input(input)
    guard = find_guard(world)
    heading = (-1, 0)
    while (
        guard[0] >= 0
        and guard[0] < len(world)
        and guard[1] >= 0
        and guard[1] < len(world[guard[0]])
    ):
        while is_blocked(world, guard, heading):
            heading = turn(heading)
        world[guard[0]] = f"{world[guard[0]][:guard[1]]}X{world[guard[0]][guard[1]+1:]}"
        guard = tuple(map(add, guard, heading))
    return sum([line.count("X") for line in world])


def part_two(input: str) -> int:
    world = parse_input(input)
    guard = find_guard(world)
    heading = (-1, 0)
    path = {}
    options = 0
    while (
        guard[0] >= 0
        and guard[0] < len(world)
        and guard[1] >= 0
        and guard[1] < len(world[guard[0]])
    ):
        path.setdefault(guard, []).append(heading)
        turned = turn(heading)
        if turned in path.get(guard, []) or turned in [
            d
            for p in set(cast_ray(world, guard, turned)).intersection(set(path.keys()))
            for d in path[p]
        ]:
            # Crossing previous path and turning would cause us to retrace our steps
            # or turning would lead us back into our previous path
            options += 1
        while is_blocked(world, guard, heading):
            heading = turned
        world[guard[0]] = f"{world[guard[0]][:guard[1]]}X{world[guard[0]][guard[1]+1:]}"
        guard = tuple(map(add, guard, heading))
    return options


if __name__ == "__main__":
    input = Path("input").read_text("utf-8")
    print(part_one(input))
    print(part_two(input))
 
 

Fermented with black cardamom and garlic (which I'm just noticing I forgot to put on the label 🤷) and puréed with mango and pear.
Added a little rice vinegar and salt to balance the fruit.
It's a little spicier than Sriracha, but not at all unpleasant. Nicely sweet and spicy. You can taste it with a spoon without regretting it.

 
 

I'm trying to get networkd to connect to a wireguard endpoint, specifically ProtonVPN, in case it matters. I just can't get it to connect. Has anyone had success with that? Specifically without using wg-quick.

 
 

By that I mean randomly generated playlists. Based on either one or multiple tags, songs or artists. Finite or infinite.

Ideally it would allow combining local sources with remote ones for discovering new music. Thinking along the lines of audioscrobbler, Bandcamp and SoundCloud. Maybe one could even hook into Spotify's API, of they allow that.

Does something like this exist? I'm currently running Navidrome and while it's pretty and functional, it's very much a classic Mediaplayer, that just happens to be a website.

1
Pizza Friday (i.imgur.com)
submitted 2 years ago* (last edited 2 years ago) by [email protected] to c/[email protected]
 

Sourdough crust with tomato sauce, topped with onions, pesto seitan sausage, artichoke, zucchini and cheese and half lemon olives.

 

As you can see, the included extension cord collides with the chosen cpu cooler. The other end of the cable looks like this.

So I need a 1ft c13 to c14 cable with two angled connectors. Not sure if the c14 side should be angled up or right.

Anyone know where I'd buy such a specific cable?

view more: next ›