Alright, im trying to wrap my head around something here, perhaps I need more coffee. I've recently completed a simple programming challenge, but upon completion I see that some other entries are different from what I submitted.
The challenge description is here:
http://www.talentbuddy.co/challenge/528 ... 0af383a409.
So, given the values for 'a' and 'b' , we need to complete a function that solves for x in this equation: a*x + b = 0. If any value of x satisfies the equation please print "INF" (infinium).
A lot of solutions are like so:
Code: Select all
#include <iostream>
using namespace std;
void solve_equation(double a, double b) {
if(a==0)
cout << "INF";
else
cout << -b/a;
}
My solution will print "INF" is either 'a' or 'b' input is 0. Which is more correct? What aren't some people checking for what 'b' is then making 'b' negative? My code covers more situations, but apparently just a few lines is all that is needed.
Quidquid latine dictum sit, altum sonatur.
- Whatever is said in Latin sounds profound.
Omnis Vestri Substructio Es Servus Ad Nobis.
- All Your Base Are Belong To Us