last day (15 days later) » 

9:20 AM
1
A: Increasing the coefficients of two numbers to sum to a targeted value

PeilonrayzRearrange the equation to find one variable from another. \$R = xX + yY\$ \$xX = R - yY\$ \$x = \frac{R - yY}{X}\$ I also wouldn't return -1, but would instead use None or an empty list. This is as -1 makes no logical sense. And rather than extending a list with another list, just return the...

 
I'm confused, to me that looks like a test for an even number after an integer division in python2.
 
@stefan you're correct, I messed up the operator, it should have been a %, rather than a &. I also assume Python 3, or from __future__ import division.
 
Still you are returning float which may result in a TypeError.And you return negative x values as your loop runs up to R for no reason and you do not test for it (coefTargetSum(24, 5, 11)).
 
@stefan My code is purely for showing an alternate way to do something. It's rare to get a TypeError, but is adding int(...) that hard? So, the question doesn't say anything about results not being allowed to be negative.
 
If the task was not without negative numbers the search space would be infinite. You do limit the seach space to range(R), so you are accepting the non-negative-constraint. Just not fully.
 
9:20 AM
@stefan So? My answer helped the OP, and looks to be good enough. If you have problems with my answer just put them in your answer.
 
I'd really prefer that you fix the answer, as this is not only for the OP
 
So what, you want me to limit the range to R // X + 1 and to return an (x, int(y))?
Then you'll be happy?
 
at least i do expect an anser to be right. so no negative values. limit is one solution, testing would be an inefficient other one. and yes, when the answer is correctly passing test cases i do not argue about minor stuff.
 
There are no test cases provided. There's no domain provided either. I only use x % 1 == 0, because it looked like they were only looking for integers. IMO this is all minor stuff, as the big stuff was that the algorithm needed to change.
 
what should coefTargetSum(24, 5, 11) return?
 
9:32 AM
@stefan Depends on what range you allow.
From the question, it doesn't exclude 1, 1.7272...
However if you go by the code and only the code -1
 
then for heavens sake return -1 (even if you suggested None or [] in your review). eod
 
@stefan are you happy now?
 

last day (15 days later) »