Skip to content

Instantly share code, notes, and snippets.

@macdonaldr93
Created April 11, 2022 18:32
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 macdonaldr93/a458ea96ec7373f986e403b924de16bb to your computer and use it in GitHub Desktop.
Save macdonaldr93/a458ea96ec7373f986e403b924de16bb to your computer and use it in GitHub Desktop.
Lighthouse Labs 2022 - Challenge #1
const van_tor_price = 250;
const van_ott_price = 280;
const van_mon_price = 240;
const van_edm_price = 150;
const van_cal_price = 180;
const van_tor_travel_time = 3.5;
const van_ott_travel_time = 4;
const van_mon_travel_time = 4;
const van_edm_travel_time = 1.5;
const van_cal_travel_time = 1;
const ott_ber_price = 1350;
const mon_lon_price = 1300;
const edm_lon_price = 1290;
const cal_lon_price = 1400;
const tor_mun_price = 990;
const ott_layover = 3.5;
const mon_layover = 2;
const edm_layover = 5;
const cal_layover = 2.5;
const tor_layover = 1.5;
const ott_ber_travel_time = 9;
const mon_lon_travel_time = 8;
const edm_lon_travel_time = 10;
const cal_lon_travel_time = 10;
const tor_mun_travel_time = 9.5;
const bestValueLag = [
{
name: 'van_tor_mun',
value:
calculateBestValue(van_tor_price, van_tor_travel_time) +
calculateBestValue(tor_mun_price, tor_mun_travel_time, tor_layover),
},
{
name: 'van_ott_ber',
value:
calculateBestValue(van_ott_price, van_ott_travel_time) +
calculateBestValue(ott_ber_price, ott_ber_travel_time, ott_layover),
},
{
name: 'van_mon_lon',
value:
calculateBestValue(van_mon_price, van_mon_travel_time) +
calculateBestValue(mon_lon_price, mon_lon_travel_time, mon_layover),
},
{
name: 'van_edm_lon',
value:
calculateBestValue(van_edm_price, van_edm_travel_time) +
calculateBestValue(edm_lon_price, edm_lon_travel_time, edm_layover),
},
{
name: 'van_cal_lon',
value:
calculateBestValue(van_cal_price, van_cal_travel_time) +
calculateBestValue(cal_lon_price, cal_lon_travel_time, cal_layover),
},
].sort((a, b) => a.value - b.value);
console.log(bestValueLag);
function calculateBestValue(price: number, time: number, layover: number = 0) {
return price / (time + layover);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment