Execute
Save
Share
Share link
share
share
share
Team
Public Teams
Comments
0
Created By:
Guest
Title:
Title
Description
Edit
Copy Link
Login
Email *
Password *
Login
OR
Create Account
Screen Name *
Email *
Password *
Retype Password *
Team Access Code
Register
Public CodeBins
HELP
--Select Theme--
Ambiance
Blackboard
Cobalt
Eclipse
Elegant
Erlang-Dark
Lesser-Dark
Monokai
Neat
Night
Rubyblue
Vibrant-Ink
Xq-Dark
New CodeBin
CodeBins Versions
01/14/2019- V.3
12/22/2018- V.2
12/22/2018- V.1
Compare Versions
Recent CodeBins
View All CodeBins
/*Each coordinate separate with "," */ /*Each x-axis and y-axis separate with a space*/ var test = "[1 1],[3 2],[5 3],[4 1],[2 3],[1 4]"; //var test = "[1 1],[2 2],[3 3]"; var node = test.split(","); nodeLen = node.length; var coord = []; var x_axis = []; var y_axis = []; text = "Input: "; for (i = 0; i < nodeLen; i++) { coord[i] = node[i].split("\[")[1].split("\]")[0]; x_axis[i] = coord[i].split(" ")[0]; y_axis[i] = coord[i].split(" ")[1]; text += "[" + x_axis[i] + " " + y_axis[i] + "]"; if (i < nodeLen - 1) { text += ","; } } text += "<br/>"; var x0 = 0; var y0 = 0; var x1 = 0; var y1 = 0; var x2 = 0; var y2 = 0; var slope01 = 0; var slope12 = 0; var cnt_arr = []; tet = "<ul>"; for (i = 0; i < nodeLen; i++) { for (j = i + 1; j < nodeLen; j++) { var cnt = 2; for (k = j + 1; k < nodeLen; k++) { x0 = x_axis[i]; y0 = y_axis[i]; x1 = x_axis[j]; y1 = y_axis[j]; slope01 = (y1 - y0) / (x1 - x0); x2 = x_axis[k]; y2 = y_axis[k]; slope12 = (y2 - y1) / (x2 - x1); if (slope01 == slope12) { cnt += 1; } cnt_arr.push(cnt); } } } cnt_arr.sort(function(a, b) { return a - b; }); document.getElementById("show").innerHTML = text + "Output: " + cnt_arr[cnt_arr.length - 1];
Bottom of Page
In Head
On Load
On Ready
Setting
Validate
Copy
Format
Setting
Validate
Copy
Format
<html> <body> <p id="show"></p> </body> </html>
No Doc Type
HTML5
HTML 4.01 Transitional
HTML 4.01 Strict
HTML 4.01 Frameset
XHTML 1.1
XHTML 1.0 Transitional
XHTML 1.0 Strict
XHTML 1.0 Frameset
Copy
Format
Download
×
Code Description
×
Difference of Versions
HTML
CSS
JS
×
JS Error
×
CSS Error
Errors
Warnings
×
JavaScript Setting
JS Libraries:
Chrome Frame 1.0.3
Dojo 1.8.0
Dojo 1.7.3
Dojo 1.7.2
Ext Core 3.1.0
jQuery 1.8.0
jQuery 1.7.2
jQuery 1.6.0
jQuery 1.5.0
jQuery 1.4.4
jQuery 1.4.0
jQuery-min 1.7.2
jQueryUI-min 1.8.21
MooTools more-1.4.0.1-full
MooTools core-1.4.5-full
MooTools core-1.4.1-full
Prototype 1.7.1.0
script.aculo.us 1.9.0
SWFObject 2.2
Twitter Bootstrap 2.0.4
WebFont Loader 1.0.28
yui 3.5.1
User Libraries:
Upload File
JavaScript URL(s):
×
CSS Setting
CSS Libraries:
jQueryUI 1.8.21
Twitter Bootstrap 2.0.4
User Libraries:
Upload File
CSS URL(s):