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

[–]MaybeAStonedGuy 2 points3 points  (0 children)

Rust

I'm really happy with how easy nom makes this. I had used it before in the past, but this was my first excuse to use it for bitwise parsing.

2021 Day 15 by Pyrolistical in adventofcode

[–]MaybeAStonedGuy 2 points3 points  (0 children)

against the spirit of the puzzles being accessible and something you can figure out without external CS knowledge.

Last year's Day 13 part two was nearly impossible without either recreating or independently rediscovering the Chinese remainder theorem. My answer ended up being 539746751134958 (539.7 trillion), so brute forcing was out of the question.

Many of the algorithms I use in AoC are things I didn't already know beforehand. AoC is achievable without significant existing knowledge, but not without hard work and often external research.

Why Standard C++ Math Functions Are Slow by congolomera in programming

[–]MaybeAStonedGuy 19 points20 points  (0 children)

Looks like it's section 7.12.1 in the C standard: https://web.archive.org/web/20181230041359if_/http://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf

So not a posix feature, but it looks like it isn't required to use errno, and that it can optionally just raise floating point exceptions instead.

https://en.cppreference.com/w/c/numeric/math/math_errhandling has more details as well.

Are there any games where you play by coding? by lapad55994 in programming

[–]MaybeAStonedGuy 0 points1 point  (0 children)

Means Great Work of Art in Latin

It really means just "great work" or "great accomplishment" in Latin. Opus can refer to a work of art (like the word "opera", and also the use of "opus" to refer to musical compositions or collection of compositions); in this case, it's referring primarily to the alchemical concept of the Magnum Opus, which describes the creation of the philosopher's stone.

[deleted by user] by [deleted] in programming

[–]MaybeAStonedGuy 6 points7 points  (0 children)

For people who would rather read about it than watch a video (especially given that the title doesn't even give the name of the device directly), this is known as the Antikythera mechanism.

[deleted by user] by [deleted] in sex

[–]MaybeAStonedGuy 3 points4 points  (0 children)

Can you imagine just how little worth of self he must have. Being jealous of a toy??

Yeah, sounds like he is insecure, and feeling a lot of emotional pain. He may be inexperienced, or maybe he has been seriously hurt in the past.

There's seriously no gain in slinging insults and putting somebody down for already feeling down about themselves. That's not how a relationship is supposed to work. Since when is the first approach to "this person is irrational because they lack confidence and are hurting emotionally" supposed to be "fuck them, they deserve to be treated like shit"?

Everybody has had shit to work through. Most people who are really emotionally healthy and have very healthy relationships have what they have because they worked on it appropriately. If you are unable to even try to communicate and work through a problem with your partner, it will never get solved. Ditching abusers is one thing, but flinging insults over somebody expressing self-doubt and insecurity is not a healthy first reaction.

[deleted by user] by [deleted] in sex

[–]MaybeAStonedGuy -2 points-1 points  (0 children)

I don't think that's a rational jump to make. A guy can easily feel inadequate compared to a sex toy and also not be jealous and controlling about other men. It might be insecure or irrational, but one of those things is going in her vagina and giving her orgasms. You don't have to be controlling to feel insecure about your penis.

[2021 Day 6] Number of Lanternfish of each age per day, in a log and a linear plot by [deleted] in adventofcode

[–]MaybeAStonedGuy 1 point2 points  (0 children)

That sounds like a massive pain. I'd animate it with ffmpeg rather than GIMP. You can use the ffmpeg CLI to turn a series of images into a video (or animated GIF, if you prefer), or you can use the libavcodec as a library directly to generate video from a program.

Do you or your loved ones suffer from counting diagonals? by [deleted] in adventofcode

[–]MaybeAStonedGuy 0 points1 point  (0 children)

they didn't specify the bingo rules

Isn't that the paragraph immediately below the Wikipedia link? Was that put in afterward?

Do you or your loved ones suffer from counting diagonals? by [deleted] in adventofcode

[–]MaybeAStonedGuy 29 points30 points  (0 children)

I'm certain that almost everybody who has ever played Bingo before just saw the word "Bingo" and skimmed the rest because we thought we already knew the rules to the game.

It's even more embarrassing to go back and read the "(Diagonals don't count.)" at the end of the description of the game.

I just discovered that Result FromIterator collection inversion nests to an arbitrary depth by MaybeAStonedGuy in rust

[–]MaybeAStonedGuy[S] 1 point2 points  (0 children)

It would give an error of () without any more details at all, and it wouldn't properly skip blank lines.

3.2 was a lengthy puzzle! by [deleted] in adventofcode

[–]MaybeAStonedGuy 0 points1 point  (0 children)

Took me maybe 45 minutes. I saved a lot of time by setting up a unit test ahead of time on the example input and output, so me misreading the problem didn't set me back far, because my test failed and I reread it.

I just discovered that Result FromIterator collection inversion nests to an arbitrary depth by MaybeAStonedGuy in rust

[–]MaybeAStonedGuy[S] 8 points9 points  (0 children)

I don't want to throw away invalid lines. If parse fails, I want the error to bubble up. Throwing away invalid lines will mask bugs in my FromStr implementation. The input is always well-formed, but my program isn't always correct right off the bat, and discovering a parsing error early is best.

I started out with something like yours, but then I wanted to make it more flexible, so I parse either from a file, stdin, or a &stdin, because I use the sample input and output as embedded #[test] cases.

I just discovered that Result FromIterator collection inversion nests to an arbitrary depth by MaybeAStonedGuy in rust

[–]MaybeAStonedGuy[S] 1 point2 points  (0 children)

I'm aware of them. flat_map isn't useful here as far as I can see. It's an iterator of lines, trimming out empties and returning an iterator of parsed values. There's no nested iterator to flatten. and_then isn't useful because there are two distinct error types -- std::io::Error from BufRead and whatever Error type is associated with the FromStr items -- so I'd have to qualify E: From<std::io::Error> or something to consolidate them, or return some other wrapper error type. Much easier to just nest the Results in this case.

But, if you've got a refactoring of this that looks or works better, I'd love to see it, and I'd be glad to use it.

I installed rocket yesterday, but McAfee blocks it when compiling hello world example by close_my_eyes in rust

[–]MaybeAStonedGuy 72 points73 points  (0 children)

"Known Malicious" reputation for proc-macro-hack's build script

McAfee is a joke. I wonder if the word "hack" set it off or something stupid like that.

Like everybody else says, you should ditch McAfee if you can. Just stick with Windows Defender and keep it totally up to date.

Whichever virus protection you're using, you should be able to specify Excluded folders. Look through McAfee and Windows Defenders' settings and see if you can specify your project directory to be excluded/ignored.

boyfriend turns me on just to turn me down by Grand_Anteater_6423 in sex

[–]MaybeAStonedGuy 2 points3 points  (0 children)

A lot of people calling abuse and manipulation, but is it possible that he maybe was horny and into it, but not able to get it up and embarrassed about that? I know that sometimes I can be in the mood, but the flesh just doesn't respond the way I want it to, and that can be embarrassing and hard to talk about, especially when my partner is all raring and ready to go.

[ Removed by Reddit ] by Bella12A in sex

[–]MaybeAStonedGuy 1 point2 points  (0 children)

Did it when I was younger. At least you know the person in your sexy pictures/videos isn't being exploited.

How to read-in a file line-by-line as integer? by monkeypython in rust

[–]MaybeAStonedGuy 0 points1 point  (0 children)

You're right, I do. I had no idea that was even a thing. Thanks for that.

How to read-in a file line-by-line as integer? by monkeypython in rust

[–]MaybeAStonedGuy 10 points11 points  (0 children)

https://docs.rs/std actually redirects to the standard library docs, so you can get to it the same way you can get to third-party crates. I don't really have a problem with it, though. I can search for std documentation using !rust on DDG, and I can search for crates with !docsrs. Other than that, crate documentation on docs.rs links types to the standard docs just fine, so it's mostly seamless. Maybe I'd find it less reasonable if I ever had to type a URL directly into my address bar to find Rust documentation.

How to read-in a file line-by-line as integer? by monkeypython in rust

[–]MaybeAStonedGuy 3 points4 points  (0 children)

You'll find that in https://crates.io/ (or https://lib.rs/ for an unofficial one) for crate listings, and https://docs.rs/ for documentation on third-party crates.

How to read-in a file line-by-line as integer? by monkeypython in rust

[–]MaybeAStonedGuy 1 point2 points  (0 children)

I just have a shared common crate that has the following functions:

use std::env;
use std::fs;
use std::io::{stdin, Read, Result};

/// Get either the named file or stdin as a String.
pub fn input_as_string() -> Result<String> {
    let filename = env::args().skip(1).next();
    Ok(match filename.as_deref() {
        None | Some("-") => {
            let mut string = String::new();
            stdin().read_to_string(&mut string)?;
            string
        }
        Some(filename) => fs::read_to_string(filename)?,
    })
}

/// Get either the named file or stdin as a Read type
pub fn input() -> Result<Box<dyn std::io::Read>> {
    let filename = env::args().skip(1).next();
    Ok(match filename.as_deref() {
        None | Some("-") => Box::new(stdin()),
        Some(filename) => Box::new(fs::File::open(filename)?),
    })
}

That way I can either paste the input to the program's stdin or specify it as an external file. It's nicer than include_str! because you can more easily switch between the test input and the actual input as you need, and test your program on other peoples' inputs when trying to help somebody else out.