Ad
  • Custom User Avatar

    Returning 0 but expected NaN in C#. There is no NaN for integers, only for floats.
    If you expect a float to be returned, then why are the results being truncated anyways?

  • Custom User Avatar

    Sum all fibonnaci numbers less than the argument that are even

  • Custom User Avatar

    Had so much trouble until I realized that cases have overflowing arithmetic with 32-bit integers

  • Custom User Avatar

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

  • Custom User Avatar

    Try it with SIMD

  • Custom User Avatar

    TryGetValue is better suited for accessing with a key undetermined to be in a dictionary

  • Custom User Avatar

    It's a good thing I wrote "Fortunately, seemingly all value types provided by .NET implement their own .Equals method to avoid boxing. So do record structs"

  • Custom User Avatar

    The ValueType class that all structs implicitly inherit don't have a generic implementation so only the object base class' .Equals method is implemented, meaning you'll have to go through expensive boxing for a simple comparison. This can even involve reflection

    See here https://source.dot.net/#System.Private.CoreLib/src/System/ValueType.cs

    Fortunately, seemingly all value types provided by .NET implement their own .Equals method to avoid boxing. So do record structs

  • Custom User Avatar

    I'm surprised there aren't more BitOperations solutions. There are more big integer solutions than this that do the same thing

  • Custom User Avatar

    You could say the same about any language

  • Custom User Avatar

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

  • Custom User Avatar

    Not enough information and available information scattered everywhere. You say the first few robots will have an updated state and transition_rule will be used to update the states of all robots. The rest is left to assumption from the description. Confirming a state for the previous robot and returning that clearly isn't enough and there's nothing else to gather from the description. Find a finite set of states and transition rules? We're only given 3 optional states, immutable in Rust.

    What I'm taking away from 80% of the description with the other 20% left up in the air is that this function is called over a collection of robots and the return value is what the target robot's new state is, with all robots being the correct state expected

  • Custom User Avatar

    TimeSpan also has a FromHours function so you don't have to multiply the distance by 3600

  • Custom User Avatar

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

  • Custom User Avatar

    Because brute force O(n^2) is better practice than a hashed O(n) solution

  • Loading more items...