<?php
$hotels = [
['Tsambika', 2, 8.1, 9122],
['Tivoli', 2, 8.1, 11403],
['Sant-Amon', 1, 9.0, 14661],
['Radian', 2, 8.4, 17267],
['Filmar', 2, 8.4, 18510],
['Mon', 2, 8.7, 19222],
];
$totalHotelsNumber = 2;
$starCoef = 0.2;
$ratingCoef = 2000;
for ( $i=0; $i<count($hotels); $i++ ) {
$hotels[$i][4] = 0;
}
for ( $i=0; $i<count($hotels); $i++ ) {
for ( $j=$i+1; $j<count($hotels); $j++ ) {
echo 'Comparing '.$hotels[$i][0].' and '.$hotels[$j][0].'...'."\r\n";
$starDifference = $hotels[$i][1]-$hotels[$j][1];
$ratingToCompensate = $starDifference*$starCoef;
$rating = $hotels[$i][2]+$ratingToCompensate;
$ratingDifference = ($rating-$hotels[$j][2])*10;
$priceToCompensate = $ratingDifference*$ratingCoef;
$price = round($hotels[$i][3]-$priceToCompensate);
echo $price.' VS '.$hotels[$j][3]."\r\n";
if ( $price < $hotels[$j][3] ) {
echo $hotels[$i][0].' wins!'."\r\n";
$hotels[$i][4]++;
} else {
echo $hotels[$j][0].' wins!'."\r\n";
$hotels[$j][4]++;
}
echo "\r\n".'----------'."\r\n";
}
}
usort($hotels, function($hotelA, $hotelB){
return $hotelB[4]-$hotelA[4];
});
echo "\r\n".'----------'."\r\n";
echo 'Top:'."\r\n\r\n";
for ( $i=0; $i<count($hotels); $i++ ) {
echo $hotels[$i][0].': '.$hotels[$i][4]."\r\n";
}
echo "\r\n".'----------'."\r\n";
echo 'Finalists:'."\r\n\r\n";
for ( $i=0; $i<=1; $i++ ) {
echo $hotels[$i][0]."\r\n";
}
- Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
- Comparing Tsambika and Tivoli...
9122 VS 11403
Tsambika wins!
----------
Comparing Tsambika and Sant-Amon...
23122 VS 14661
Sant-Amon wins!
----------
Comparing Tsambika and Radian...
15122 VS 17267
Tsambika wins!
----------
Comparing Tsambika and Filmar...
15122 VS 18510
Tsambika wins!
----------
Comparing Tsambika and Mon...
21122 VS 19222
Mon wins!
----------
Comparing Tivoli and Sant-Amon...
25403 VS 14661
Sant-Amon wins!
----------
Comparing Tivoli and Radian...
17403 VS 17267
Radian wins!
----------
Comparing Tivoli and Filmar...
17403 VS 18510
Tivoli wins!
----------
Comparing Tivoli and Mon...
23403 VS 19222
Mon wins!
----------
Comparing Sant-Amon and Radian...
6661 VS 17267
Sant-Amon wins!
----------
Comparing Sant-Amon and Filmar...
6661 VS 18510
Sant-Amon wins!
----------
Comparing Sant-Amon and Mon...
12661 VS 19222
Sant-Amon wins!
----------
Comparing Radian and Filmar...
17267 VS 18510
Radian wins!
----------
Comparing Radian and Mon...
23267 VS 19222
Mon wins!
----------
Comparing Filmar and Mon...
24510 VS 19222
Mon wins!
----------
----------
Top:
Sant-Amon: 5
Mon: 4
Tsambika: 3
Radian: 2
Tivoli: 1
Filmar: 0
----------
Finalists:
Sant-Amon
Mon
- Output for 4.4.2 - 4.4.9, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29
- Parse error: syntax error, unexpected '[' in /in/NFjGt on line 3
Process exited with code 255. - Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1, 5.0.0 - 5.0.5
- Parse error: parse error, unexpected '[' in /in/NFjGt on line 3
Process exited with code 255. - Output for 4.3.2 - 4.3.4
- Parse error: parse error in /in/NFjGt on line 3
Process exited with code 255.
preferences:
288.63 ms | 401 KiB | 460 Q