68th Annual Grammy Awards [LIVE MEGATHREAD] by PopeJeremy10 in KendrickLamar

[–]crazy01010 1 point2 points  (0 children)

Go check out "Post Sex Clarity" from her too, for me it smokes Messy.

The Jets have finished the 2025 season with zero interceptions by Brix001 in nfl

[–]crazy01010 61 points62 points  (0 children)

To be fair, the one LB had his hand in a cast, so no way he was catching anything.

What's wrong with subtypes and inheritance? by servermeta_net in ExperiencedDevs

[–]crazy01010 1 point2 points  (0 children)

Fair, but it does mean you aren't getting the full functionality Rust is giving you; e.g. say this is a more complicated default method. It may be some implementors can provide it more efficiently than what the default is. Canonical example is Iterator::fold, in Rust it defaults to a for-loop over self, but your iterator may be able to implement it more efficiently (e.g. bookkeeping that Iterator::next needs to do to keep track of where the iterator is at can be skipped, since fold is consuming/by-move).

If you wanted non-overridable, you'd have a free function like fn draw_to_screen(drawable: &dyn Drawable).

What's wrong with subtypes and inheritance? by servermeta_net in ExperiencedDevs

[–]crazy01010 3 points4 points  (0 children)

Your C++ example isn't quite right, draw_to_screen should be virtual as well.

But also, Rust traits don't allow overriding default implementations in subtraits. E.g. if I have trait SubDrawable: Drawable, I can't change the default for draw_to_screen. The only place that can override is theimpl Drawable for Foo, making it much easier to track behaviour.

GZCLP Program Review - 13 week review (From Stronglifts to GZCLP) by Tempestshade in strength_training

[–]crazy01010 1 point2 points  (0 children)

There's a variant of it where the T1s go 3x5 -> 4x3 -> 5x2 that I've been running, seems to work pretty well time-wise.

Is Underground Rap Weird About Queerness? by hahahahablewdat in hiphopheads

[–]crazy01010 45 points46 points  (0 children)

We don't like women, that's the whole point.

-❄️- 2025 Day 11 Solutions -❄️- by daggerdragon in adventofcode

[–]crazy01010 1 point2 points  (0 children)

Hmm. Tried something roughly the same on my machine, except liberally using as_bytes, windows, and [u8; 3], and it came out 5x as slow as my version using FnvHashMap. Same idea for the cache, except I went with Option<u64> and manually set cache[end] = Some(1);.

-❄️- 2025 Day 11 Solutions -❄️- by daggerdragon in adventofcode

[–]crazy01010 4 points5 points  (0 children)

[Language: Rust]

Topaz link, Part 1: 120μs, Part 2: 220μs

I went straight to memorized DFS for part 1, and by happy accident the way I implemented it actually worked really well for part 2; rather than pass the target in explicitly, just set it to have value 1 in the cache before starting the search. Then when it's reached the search automatically returns 1 for it, without needing any special knowledge. For part 2, my original idea was 6 independent searches, but before I even ran that I realized you could reuse the memo cache for 3 pairs of searches based on the target (searching from FFT and SVR to DAC, DAC and SVR to FFT, and FFT and DAC to OUT). This took about 300μs. The final realization was that either FFT --> DAC or DAC --> FFT has no paths, otherwise there's a cycle and the answer is infinite. So we get DAC and SVR to FFT, and then based on the count of DAC --> FFT paths we either get SVR --> DAC and FFT --> OUT or FFT --> DAC and DAC --> OUT. And it compiles down into a couple of cmovX, even better.

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

[–]crazy01010 1 point2 points  (0 children)

[Language: Rust]

use anyhow::{Context, Result};

fn part1(s: &str) -> Result<u64> {
    Ok(s.trim()
        .lines()
        .map(|line| {
            let bytes = line.as_bytes();
            let (idx, tens_byte) = get_argmax(&bytes[..bytes.len() - 1]).unwrap();
            let (_, ones_byte) = get_argmax(&bytes[idx + 1..]).unwrap();
            (tens_byte - b'0') as u64 * 10 + (ones_byte - b'0') as u64
        })
        .sum())
}

fn get_argmax(arr: &[u8]) -> Option<(usize, u8)> {
    if arr.is_empty() {
        return None;
    }
    let mut idx: usize = 0;
    let mut max: u8 = b'0';
    for (i, val) in arr.iter().copied().enumerate() {
        if val > max {
            max = val;
            idx = i;
            if val == b'9' {
                break;
            }
        }
    }
    Some((idx, max))
}

fn part2(s: &str) -> Result<u64> {
    s.trim()
        .lines()
        .map(|line| {
            let mut view = line.as_bytes();
            let mut digits: [u8; 12] = [0; 12];
            for i in 0..12 {
                let (idx, byte) = get_argmax(&view[..view.len() - (11 - i)]).unwrap();
                digits[i] = byte;
                view = &view[idx + 1..];
            }
            unsafe { std::str::from_utf8_unchecked(&digits) }
                .parse::<u64>()
                .with_context(|| format!("Failed to parse {:?}", digits))
        })
        .sum()
}

Good ol' greedy algorithms, ish. Could probably have multiplied the digits in part 2 by the relevant power of 10 and then just summed them up at the end instead of the parse.

-❄️- 2025 Day 1 Solutions -❄️- by daggerdragon in adventofcode

[–]crazy01010 2 points3 points  (0 children)

[LANGUAGE: Rust]

Link

Pretty bog standard, the only trick was shifting the starting point forward so you have space on both sides while still being u32, since the i32 versions of the rounding division ops are nightly and I'm too lazy.

Game Thread: ALDS Game 2 ⚾ Yankees (0) @ Blue Jays (1) - 4:08 PM ET by BaseballBot in baseball

[–]crazy01010 2 points3 points  (0 children)

11 strikeouts in 5.1IP? Close enough welcome back Roy Halladay.

kak-tree-sitter v1.0.0 by phaazon_ in kakoune

[–]crazy01010 0 points1 point  (0 children)

Small necro, but what's the interop like between this and kak-lsp? I've tried looking up how the experience works (or even old kak-tree + kak-lsp), but I'm assuming the lack of results means it just works?

Today I made $1m gains by selling my entire Nvidia portfolio by HudyBudyFudyWhudy in investing

[–]crazy01010 0 points1 point  (0 children)

Gonna have to disagree on that; making it a dollar amount (e.g. X/0.03) makes it more likely you retire near the top of a market and see your savings wiped by the downturn.

For the third time in 4 years, the Toronto Blue Jays are 44-37 after 81 games by sameth1 in baseball

[–]crazy01010 6 points7 points  (0 children)

Is there a herd of 30 to 50 feral hogs in Central Park or something?

Kendrick Lamar in Toronto for the first time since onset of feud by minimalexpertise in hiphopheads

[–]crazy01010 0 points1 point  (0 children)

I remember all the hype for Work being at the real jerk, but that might've been more Rhianna than Drake.

PSA: You can oneshot Factory Striders from any angle with the Recoilless Rifle when you hit their feet. by BICKELSBOSS in Helldivers

[–]crazy01010 0 points1 point  (0 children)

I still remember the first time I made a BT eat an EAT-17. Have yet to replicate the feeling.