Avatar

SleveMcDichael

SleveMcDichael@programming.dev
Joined
0 posts • 18 comments
Direct message

Tabs let you define how big you want each indent to be, and spaces do not.

Spaces can too: Simply use more or less of them, to taste.

I have ADHD. Two spaces per indent makes it damn near impossible for me to scan code.

Then use four, or six, or eight, or 20. Hell, most code I’ve seen uses four spaces per indent anyway.

[Re: braille]

Surely there’s an editor out there that will automatically display indent spaces as a tab character. Or failing that it seems like it would be rather trivial create a program to convert n spaces to tabs, and vice versa.

permalink
report
reply

A bit late to the party but here’s a Rust solution that is probably maybe correct: https://pastebin.com/Eaes7hU9

permalink
report
reply

The thing is the average person either can’t or can’t be bothered to remember even a dozen actually secure passwords, so they fall back to a couple of simple derivations of a common password, meaning each and every site a user signs up on represents an additional single point of failure.

permalink
report
parent
reply

Rust: https://pastebin.com/frYcgdxh

Like last time, a brute force solution: checking if every substring is a set of well formed brackets, and, if so, recording it if its the longest seen so far.

permalink
report
reply

Rust:

A super simple brute force attempt: https://pastebin.com/qbYQNQ7h

Also super slow. Took me a bit more than a minute for n=10.

edit: An updated version: https://pastebin.com/wVhxLmt9

Added some simple constraints to reduce the number of unfiltered entries that need to be generated, bringing the n=10 time down to 10ish seconds. EDIT: if any of the test cases are n=12 or greater, probably best to fail this without testing. It’s super inefficient memory wise.

permalink
report
reply

Time: 4.472s

Ough. Those must be some hefty test cases, even the deepest ones I tested (250 loops) completed in less than a tenth of a second. If its possible I may try to find a faster solution and resubmit later…

permalink
report
parent
reply

Here’s an entry in Rust, though it feels quite a bit like cheating:

fn main() {
    let mut a = std::env::args().skip(1).next().unwrap();
    println!("{}", f(&mut a));
}


fn f(a: &mut String) -> String {
    let mut b = String::new();

    while *a != b {
        b = a.clone();
        *a = a.replace("{}", "").replace("()", "").replace("[]", "");
    }

    return b;
}

edit: added main function to take cli input.

edit2: a rust based stack implementation: https://pastebin.com/FgfuxxRV

permalink
report
reply