Equation of a Line

From Hack Wars Wiki

Jump to: navigation, search

Outdated, should be deleted. - aoi

Challenge Information for Equation of a Line
Challenge Equation of a Line
Code 15
Input Example 4, 0, 10, 7 (Double)
Output Example 1.1666666, -4.6666665 (Double)
Level 0
Profit $0
Experience 0 to each stat
Description Given two points determine slope and y-intercept of a line.


Solution

float xOne = getInputFloat();
float yOne = getInputFloat();
float xTwo = getInputFloat();
float yTwo = getInputFloat();
float slope = (yTwo - yOne) / (xTwo - xOne);
float yIntercept = yOne - (slope * xOne);
 
setOutputFloat(slope);
setOutputFloat(yIntercept);
Personal tools