private static List<Size> pickUpToThree(List<Size> sizes){
  List<Size> result=new ArrayList<Size>();
  Size largest=sizes.get(0);
  result.add(largest);
  Size lastSize=largest;
  for (  Size size : sizes) {
    double targetArea=Math.pow(.5,result.size()) * area(largest);
    if (area(size) < targetArea) {
      if (!result.contains(lastSize) && (targetArea - area(lastSize) < area(size) - targetArea)) {
        result.add(lastSize);
      }
 else {
        result.add(size);
      }
    }
    lastSize=size;
    if (result.size() == 3) {
      break;
    }
  }
  if (result.size() < 3 && !result.contains(lastSize)) {
    result.add(lastSize);
  }
  return result;
}

private static List < Size > pickUpToThree ( List < Size > sizes ) { List < Size > result = new ArrayList < Size > ( ) ; Size largest = sizes . get ( 0 ) ; result . add ( largest ) ; Size lastSize = largest ; for ( Size size : sizes ) { double targetArea = Math . pow ( .5 , result . size ( ) ) * area ( largest ) ; if ( area ( size ) < targetArea ) { if ( ! result . contains ( lastSize ) && ( targetArea - area ( lastSize ) < area ( size ) - targetArea ) ) { result . add ( lastSize ) ; } else { result . add ( size ) ; } } lastSize = size ; if ( result . size ( ) == 3 ) { break ; } } if ( result . size ( ) < 3 && ! result . contains ( lastSize ) ) { result . add ( lastSize ) ; } return result ; }
given a list of sizes of a similar aspect ratio , it tries to pick evenly spaced out options . it starts with the largest , then tries to find one at 50 % of the last chosen size for the subsequent size .
