Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@johnboker
Last active December 2, 2015 15:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnboker/59d8b99d6cb3806cf081 to your computer and use it in GitHub Desktop.
Save johnboker/59d8b99d6cb3806cf081 to your computer and use it in GitHub Desktop.
var paperNeeded = input.Select(a => new
{
SurfaceArea = 2 * a.Item1 * a.Item2 + 2 * a.Item1 * a.Item3 + 2 * a.Item2 * a.Item3,
Extra = Math.Min(Math.Min(a.Item1 * a.Item2, a.Item1 * a.Item3), a.Item2 * a.Item3)
}).Sum(b => b.SurfaceArea + b.Extra);
var ribbonNeeded = input.Select(a => new
{
Permiter = Math.Min(Math.Min(2 * (a.Item1 + a.Item3), 2 * (a.Item2 + a.Item3)), 2 * (a.Item2 + a.Item1)),
Extra = a.Item1 * a.Item2 * a.Item3
}).Sum(b => b.Permiter + b.Extra);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment