Ad
  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Regex seems to have become contentious. I learned it long ago, and it's useful across several languages. But I don't think it ever made the difference in whether or not I got a job, and using it first just because I knew it tended to prevent me from learning language tricks and features as I'd just go find "how do I do regex in Python/JS/Ruby/C#/whatever" instead of how to solve the problem with native tools.

    It's also not a thing every programmer knows, and regex can be hard to read and decode later which makes it not an ideal thing to use.

    I think anyone learning a language can safely ignore regex. But that statement will upset a lot of regex fans.

  • Custom User Avatar

    I went brute force on this one...I should have compared the min/max lengths of each array to each other. Oh well.

  • Custom User Avatar

    Um, suddenly I'm not sure why this works. Why is a not false on the first iteration? I guess the first element is being passed, so I guess that works, but it's...messy at best. I should have added true as a second parameter to reduce.

  • Custom User Avatar

    Ok, I didn't know :capitalize. I was looking through the docs for "case" hoping to find "firstcase" or "camelcase" or something.

  • Custom User Avatar

    I hadn't done any Ruby in a while and felt satisfied with this until I saw the better, more idiomatic answers

  • Custom User Avatar

    This one beats many of the others because it uses the triple bit shift operator to ensure the int32 is unsigned.

  • Custom User Avatar

    I started with a simple bit shift count which passed the tests but failed random "attempt" tests that were larger than 32-bit max. Apparently bitwise operators return 32-bit numbers. I went to BigInt, but while >> works, bigint & one would throw an error, hence the modulus with two. Weird behavior.

  • Custom User Avatar

    I tried something very similar. The tests passed, but the "attempt" failed on numbers greater than 32-bit max because the bitwise operators only know 32-bit numbers. This would fail the attempt today. I didn't know about the 32-bit limit before, so lesson learned.