This Simple Algorithm Will Fix All Of Uber’s Surge Pricing Woes

Uber has been getting its surge pricing all wrong. Fortunately, its an easy fix with these few lines of code. Disclosure: this has not gone through code review.

function getPricing($userType) {

  switch($userType) {

  case "isJournalistOrBlogger":
  alertPRTeam(); 
  showBiggestDiscountCode();
  break;

  case "worksForLyft":
  returnError("Seriously?");
  break;

  case "hasTweetedRecently":
  showDiscountCode();
  autoFollow();
  reTweet();
  giveBadge("Congrats! You just had a moment on Uber"); 
  break;

  case "hasInvestedInUber":
  setSurgeRate = valueRequiredToMeetRevenueTargets;
  break;

  case "isVC":
  if(declinedToInvestPreviously = true) {
    setSurgeRate = 5;
    } else {
    setSurgeRate = 2;
    }
  break;

  case "hasPaidSurgeBeforeWithoutComplaining":
  setSurgeRate = previousSurgeRate + 1;
  break;

  case "isExecAtPostIPOCompany":
  setSurgeRate = maxSurgeRate;
  break;

  case "isBanker":
  setSurgeRate = maxSurgeRate + 1;
  break;

  }

}
Posted in Algorithms