<?php
$hotels = [
['Anika', 0, 8.0, 11728],
['Maroula', 0, 8.4, 13032],
['Paravos', 0, 8.5, 15638],
['Billis', 0, 8.5, 16289],
['Terinkas', 0, 8.1, 17918],
['Tias', 0, 8.6, 19222],
['Liristis', 0, 9.1, 20851],
['Irina', 0, 9.3, 21176],
];
$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 Anika and Maroula...
19728 VS 13032
Maroula wins!
----------
Comparing Anika and Paravos...
21728 VS 15638
Paravos wins!
----------
Comparing Anika and Billis...
21728 VS 16289
Billis wins!
----------
Comparing Anika and Terinkas...
13728 VS 17918
Anika wins!
----------
Comparing Anika and Tias...
23728 VS 19222
Tias wins!
----------
Comparing Anika and Liristis...
33728 VS 20851
Liristis wins!
----------
Comparing Anika and Irina...
37728 VS 21176
Irina wins!
----------
Comparing Maroula and Paravos...
15032 VS 15638
Maroula wins!
----------
Comparing Maroula and Billis...
15032 VS 16289
Maroula wins!
----------
Comparing Maroula and Terinkas...
7032 VS 17918
Maroula wins!
----------
Comparing Maroula and Tias...
17032 VS 19222
Maroula wins!
----------
Comparing Maroula and Liristis...
27032 VS 20851
Liristis wins!
----------
Comparing Maroula and Irina...
31032 VS 21176
Irina wins!
----------
Comparing Paravos and Billis...
15638 VS 16289
Paravos wins!
----------
Comparing Paravos and Terinkas...
7638 VS 17918
Paravos wins!
----------
Comparing Paravos and Tias...
17638 VS 19222
Paravos wins!
----------
Comparing Paravos and Liristis...
27638 VS 20851
Liristis wins!
----------
Comparing Paravos and Irina...
31638 VS 21176
Irina wins!
----------
Comparing Billis and Terinkas...
8289 VS 17918
Billis wins!
----------
Comparing Billis and Tias...
18289 VS 19222
Billis wins!
----------
Comparing Billis and Liristis...
28289 VS 20851
Liristis wins!
----------
Comparing Billis and Irina...
32289 VS 21176
Irina wins!
----------
Comparing Terinkas and Tias...
27918 VS 19222
Tias wins!
----------
Comparing Terinkas and Liristis...
37918 VS 20851
Liristis wins!
----------
Comparing Terinkas and Irina...
41918 VS 21176
Irina wins!
----------
Comparing Tias and Liristis...
29222 VS 20851
Liristis wins!
----------
Comparing Tias and Irina...
33222 VS 21176
Irina wins!
----------
Comparing Liristis and Irina...
24851 VS 21176
Irina wins!
----------
----------
Top:
Irina: 7
Liristis: 6
Maroula: 5
Paravos: 4
Billis: 3
Tias: 2
Anika: 1
Terinkas: 0
----------
Finalists:
Irina
Liristis
- 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/b9dEg 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/b9dEg on line 3
Process exited with code 255. - Output for 4.3.2 - 4.3.4
- Parse error: parse error in /in/b9dEg on line 3
Process exited with code 255.
preferences:
334.28 ms | 401 KiB | 460 Q