Maximum distinct lines passing through a single point | function to find maximum lines which passes through a single point ; Driver Code
function maxLines ( n , x1 , y1 , x2 , y2 ) { var s = [ ] ; var slope = 2147483647 ; for ( let i = 0 ; i < n ; i ++ ) { if ( x1 [ i ] === x2 [ i ] ) slope = 2147483647 ; else slope = ( ( ( y2 [ i ] - y1 [ i ] ) * 1.0 ) / ( x2 [ i ] - x1 [ i ] ) ) * 1.0 ; s . push ( slope ) ; } return s . length ; } var n = 2 ; var x1 = [ 1 , 2 ] ; var y1 = [ 1 , 2 ] ; var x2 = [ 2 , 4 ] ; var y2 = [ 2 , 10 ] ; document . write ( maxLines ( n , x1 , y1 , x2 , y2 ) ) ;