fenil Posted September 30, 2021 Share Posted September 30, 2021 Given N = 4, A = [1, 3], B = [2, 4] function should return 10. The graph contains two edges: (1, 2) and (3, 4). We can assign following values to the vertices: 4, 3, 2, 1. The sum of values at the edges' endpoints is (4 + 3) + (2 + 1) = 10. how to find edges of vertices and sum of values at the edges' endpoints ? function ec($n, array $a, array $b){ } Link to comment https://forums.phpfreaks.com/topic/313840-find-edges-of-vertices-and-sum-of-values-at-the-edges-endpoints/ Share on other sites More sharing options...
Barand Posted September 30, 2021 Share Posted September 30, 2021 Now it returns 10 again function ec($n, array $a, array $b) { return $n * $b[1] - $b[0] * $a[0] * $a[1] ; } echo ec( 4, [1,3], [2,4]); // 10 If you post this topic again you will be banned. 1 Link to comment https://forums.phpfreaks.com/topic/313840-find-edges-of-vertices-and-sum-of-values-at-the-edges-endpoints/#findComment-1590548 Share on other sites More sharing options...
Recommended Posts