# compare trips based upon price

#### tylerdurdan

Im writting an algorithm to compare travel trips. A trip is a combination of a 1) flight and 2) an accommodation. For now I´m only looking at the prices. I want to find the "best" trip based upon the price. The problem is that the flight price is a static value which doesn´t increase by the amount of nights you spend. Vise versa the accommodation price does increases each time the amount of nights increases. Obviously formulas like those might solve the question but they dont:

q = flight_price+accommodation_price --> short trips are favored
q = (flight_price+accommodation_price)/nights ---> long trips are favored
So what would be an appropriate indicator to say that a trip is "better"? This indicator doesn´t need to provide a "real" price. It should rather give a value to compare the trips and put them in relation. Thank you.

#### IvanM

Well, if you divide the sum of the flight and accommodation by the number of nights, then for the two prices to be equal, the value of n would be equal to 1:

FP+AP=(FP+AP)/n

divide by (FP+AP)

1=1/n

n=1

So any value of n greater than 1 would lead to the second trip (which costs the combined costs of flight and accommodation prices divided by the number of nights) to cost less than the first trip.