Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
JessesAverage
int JessesAverage(int a, int b)
{
return (a / 2) + (b / 2) + (((a % 2) + (b % 2)) / 2);
}
@jessemcdowell

This comment has been minimized.

Copy link
Owner Author

jessemcdowell commented Apr 30, 2011

The first revision was what I proposed originally in my interview. After someone pointed out that it had a problem with Average(1, 1) I revised it to the second revision with the sum of the moduli.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.