Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Swordsman368yfunction writeABetterUserStoryNextTime() {
$a = 10;
$b = 20;
print ('Not sure that ' . $a . $b . ' is what the customer had in mind, but the user story did not give all details of the expected feature.'); -
Skayo85688yNow the real answer:
(JavaScript)
function sum(a, b){
var arr = [a, b];
return arr.sum();
}
sum(1, 2); // Returns 3
sum(3, 4); // Returns 7
Easy af. -
@Letmecode yup binary and some code to simulate the address circuit would do it
-
def sum(a, b):
if a == 0:
return b
elif b == 0:
return a
elif a == 1:
if b == 1:
return 2
if b == 2:
return 3
if b == 3:
return 3
# etc
elif a == 2:
if b == 1:
return 3
if b == 2:
return 4
if b == 3:
return 5
# etc
And so on, with negative numbers. It's a bit long but I can create a function that would write this function ;) -
@TheAnimatrix but there it would be valid, since it's just the code that generates the code. Right? Or else I could generate code that generates code that generates code. xD
-
I see autocorrect corrected the adder circuit above to the address circuit in my previous comment but that's what I meant, an adder circuit
Write a function that adds two numbers together. However, do not use + or any arithmetic operations to do so.
undefined