Sunday, April 24, 2022

solution:evenlySpaced

 Given three ints, a b c, one of them is small, one is medium and one is large. Return true if the three values are evenly spaced, so the difference between small and medium is the same as the difference between medium and large.

 

 

public boolean evenlySpaced(int a, int b, int c) {
  return (a - b == b - c) || (a - c == c - b) || (a - b == c - a);
}
 

No comments:

C# scan cs file and find variables values and names

using Microsoft . CodeAnalysis ; using Microsoft . CodeAnalysis . CSharp ; using Microsoft . CodeAnalysis . CSharp . Syntax ; using Xunit . ...