Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
This is a clever use of Linq, however it's poor performance due to needless heap allocations and iterates over the array multiple times.
This should not be marked best practice.
too clever, my mind is blown haha
31: 00011111
a : 01100001
b : 01100010
c : 01100011
...
so: a&31 = 00000001 = 1
b&31 = 00000010 = 2
c&31 = 00000011 = 3
There was no need for the arr variable here... could have done the same just using iterable.Where(...
Still much better than my solution. :)
Thinking outside of the box and change the rule of this puzzle with this clever trick! Well done!
Brilliant solution!
what a cool code :)
This is a really interesting solution, funny I thought of this solution as soon as I completed the assignment.
I love this solution - it's certainly the most readable!
Please use spoiler flag next time, your post was visible in the homepage.
This comment is hidden because it contains spoiler information about the solution
Sure, my foul
This isn't possible in any current version of C#.
2^31 = 2147483648
(DateTime.MaxValue - DateTime.MinValue).TotalDays = 3652059 (less than 2^31)
cycleLength is int, which has a max value of 2147483647 (less than 2^31)
There is no possible way to pass this method values that will cause the error you describe.
This comment is hidden because it contains spoiler information about the solution
Yours is a bit clearer, but it still takes targeted time to diagnose what is happening. For example, I don't use the exclusive OR all that much, so I wasn't sure what was happening. I had to go look it up. Then put together each piece of the code. It's only a few lines, but overtime with things like this, it adds up.
In most cases, especially for applications that are not performance-critical, readability and maintainability are far more important than minor gains in execution speed. Clear code is easier to debug, understand, and modify, which is crucial for long-term maintenance and collaboration.
Moreover, the performance difference in this case is likely negligible. Modern compilers and runtime environments like the .NET Framework are highly optimized, and the difference in execution time between these two approaches (My solution) in a simple game like rock-paper-scissors would be imperceptible.
Loading more items...