HTMLify
Day 85
Views: 3 | Author: djdj
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | class Solution { /** * @param Integer[][] $coordinates * @return Boolean */ function checkStraightLine($coordinates) { $x0 = $coordinates[0][0]; $y0 = $coordinates[0][1]; $x1 = $coordinates[1][0]; $y1 = $coordinates[1][1]; for ($i = 2; $i < count($coordinates); $i++) { $x = $coordinates[$i][0]; $y = $coordinates[$i][1]; if (($y1 - $y0) * ($x - $x1) !== ($y - $y1) * ($x1 - $x0)) { return false; } } return true; } } |