Created
September 26, 2023 06:38
-
-
Save 4RSIM3R/a93d2605e34ed78bf5e075bf6c3d15ce to your computer and use it in GitHub Desktop.
[PHP] Manhattan Distance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Manhattan Distance : | |
// Buatlah sebuah fungsi untuk menghitung 'manhattan distance' antara 2 titik koordinat, contoh: | |
// | |
// A = (2, 2) | |
// B = (3, 5) | |
// | |
// |x1 - x2| + |y1 - y2| | |
// | |
// Berapa Manhattan Distance Nya ? |2 - 3| + |2 - 5| -> |-1| + |-3| -> 1 + 3 = 4 | |
function manhattanDistance($x1, $y1, $x2, $y2) { | |
} | |
$result1 = manhattanDistance(2, 2, 3, 5); | |
echo $result1; // 4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment