You are viewing a single comment's thread. Return to all comments →
Here is a c# way that doesn't do uneeded additions or comparisons.
Console.WriteLine(apples.Where(x => HitHouse(s,t,a,x)).Count()); Console.WriteLine(oranges.Where(x => HitHouse(s,t,b,x)).Count());
With the comparison function:
static bool HitHouse(int houseStart, int houseEnd, int treeLoc, int objectLoc) { int loc = treeLoc + objectLoc; return !(loc < houseStart || loc > houseEnd); }
Seems like cookies are disabled on this browser, please enable them to open this website
Apple and Orange
You are viewing a single comment's thread. Return to all comments →
Here is a c# way that doesn't do uneeded additions or comparisons.
With the comparison function: