Well, my F# solution translated to C# would be something like this;
static int StrongestIn(int n, int m)
return Enumerable.Range(n, (m-n))
.Aggregate((a,b) => BitOperations.TrailingZeroCount(a) > BitOperations.TrailingZeroCount(b)
? a : b);
There is no built in "MaxBy" in the C#, so here I replaced it with an Aggregate. (The TrailingZeroCount method will use intrinsics (e.g. a CPU instruction) if its available, so I'm not worried about calling it repeatedly for the accumulator.)
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.