Skip Navigation

InitialsDiceBearhttps://github.com/dicebear/dicebearhttps://creativecommons.org/publicdomain/zero/1.0/„Initials” (https://github.com/dicebear/dicebear) by „DiceBear”, licensed under „CC0 1.0” (https://creativecommons.org/publicdomain/zero/1.0/)F
Posts
2
Comments
1235
Joined
3 yr. ago

  • Ah yeah you're right - I missed that.

  • Yes this is true, but it's a little advanced for this level so I didn't mention it. Probably better for beginners to focus on good code style than optimal performance.

  • Some suggestions:

    1. Declare input in the loop. That limits scope which is basically always a good idea.
    2. Trim the newline like

     
        
    let input = input.trim();
    
      

    This is better in several ways:

    1. Simpler
    2. Doesn't allocate a new string.
    3. Removes all whitespace at the start and end.
    4. It makes input immutable after that line.

    Also attempts is never read - you should have got a compiler warning about that.

    Otherwise, good work.

  • Oh yeah I can't read 😄

    I would be extremely surprised if any compiler was smart enough to short circuit that.

    I would be a little less surprised if checking the whole string was actually faster anyway though... but I would still bet against it.

  • You only need to check half of the string, so I think a technically optimal solution would have some take_while and maybe char_indices in there...

  • Aside from the better solution with iterators that Flipper mentioned, you can also:

    • Omit the type annotation for is_palindrome - it will be inferred as bool anyway
    • break; after setting is_palindrome = false
    • Use the (0..input.len()/2).all(|i| ...) iterator method instead.
  • Definitely true for a minority. Not the way most of these articles are presented though (including this one).

  • No tongue-twister or finger-breaker when typing (I had enough of that with 25 years of YaST2)

    ...

    • Zwieback
    • Zugezogen

    Erm. Yeah. Zap and Pin are good suggestions at least.

  • I don't see why. You can be interested in Linux and like some aspects of it but still get annoyed at the blinkered zealots claiming that there's no reason to use Windows.

  • Pornhub's audience is 75% male, and Linux users are almost all male too (and ... no offence guys but probably more likely to rely on porn), so I wouldn't take that as a representative global figure.

    Statcounter gives 1.4% which is much more likely to be unbiased (and sounds way more plausible based on my experience of real life).

  • Very good points. A codebase that gets this VERY wrong is Gitlab. I think it might be a dumb characteristic of Ruby programs, but they generate identifiers all over the place. I once had to literally give up following some code because I could not find what it was calling anywhere. Insanity.

    Another point: don't use - in names. Eventually you'll have to write them down in a programming language, at which point you have to change the name. CSS made this mistake. foo-bar in CSS maps to fooBar in Javascript. Rust also made this mistake with crate names. A crate called foo-bar magically becomes foo_bar in Rust code.

  • You won't get very far in life with such primitive black and white thinking.

  • One annoying thing on Windows...

    You could write a dozen rants about other similarly annoying things on Linux (or other ones on Windows).

  • Buying several OEM keys is still going to be cheaper than a retail one though.

  • It can understand, just not as well.

  • You can't confidently say that because nobody knows how to solve the bullshitting issue. It might end up being very similar to current LLMs.

  • He's right that it's probably harder for AI to understand. But wrong in every other way possible. Human understanding should trump AI, at least while they're as unreliable as they currently are.

    Maybe one day AI will know how to not bullshit, and everyone will use it, and then we'll start writing documentation specifically for AI. But that's a long way off.

  • I wouldn't recommend it. I actually looked up COBOL jobs a while ago, and while they paid more, it was only like 20% more - not enough to make it worth it IMO.

  • Huh I did not know Roku (the on-the-way-out TV company) made their own scripting language. How bizarre.