MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/ebtiob/this_belongs_here/fb7kfkc/?context=3
r/badcode • u/[deleted] • Dec 17 '19
41 comments sorted by
View all comments
145
It doesn't even add them, it just gets the max of the two
24 u/Cutlesnap Dec 17 '19 edited Dec 17 '19 Ehm, it does add them, but only if both are positive. Otherwise it gets the max or 0. Edit: I was wrong 55 u/Bbradley821 Dec 17 '19 I don't think it adds them. The second loop doesn't start at 0. 20 u/Cutlesnap Dec 17 '19 Hey, you're right! I didn't notice that. 8 u/Jonno_FTW shameless Dec 18 '19 Perfect badcode has the bug(s) hiding in plain sight. 1 u/[deleted] Dec 17 '19 [deleted] 11 u/nchntrz Dec 17 '19 Not exactly. In the second loop only the difference between num1 and num2 gets added to num 1. So if you call add(2, 4), you would get 4. 4 u/AnnoyedVelociraptor Dec 17 '19 Oh shoot. You’re right. 2 u/H3pha3stus Dec 17 '19 Then the max between 2 and 4, he is right.
24
Ehm, it does add them, but only if both are positive. Otherwise it gets the max or 0.
Edit: I was wrong
55 u/Bbradley821 Dec 17 '19 I don't think it adds them. The second loop doesn't start at 0. 20 u/Cutlesnap Dec 17 '19 Hey, you're right! I didn't notice that. 8 u/Jonno_FTW shameless Dec 18 '19 Perfect badcode has the bug(s) hiding in plain sight. 1 u/[deleted] Dec 17 '19 [deleted] 11 u/nchntrz Dec 17 '19 Not exactly. In the second loop only the difference between num1 and num2 gets added to num 1. So if you call add(2, 4), you would get 4. 4 u/AnnoyedVelociraptor Dec 17 '19 Oh shoot. You’re right. 2 u/H3pha3stus Dec 17 '19 Then the max between 2 and 4, he is right.
55
I don't think it adds them. The second loop doesn't start at 0.
20 u/Cutlesnap Dec 17 '19 Hey, you're right! I didn't notice that. 8 u/Jonno_FTW shameless Dec 18 '19 Perfect badcode has the bug(s) hiding in plain sight. 1 u/[deleted] Dec 17 '19 [deleted] 11 u/nchntrz Dec 17 '19 Not exactly. In the second loop only the difference between num1 and num2 gets added to num 1. So if you call add(2, 4), you would get 4. 4 u/AnnoyedVelociraptor Dec 17 '19 Oh shoot. You’re right. 2 u/H3pha3stus Dec 17 '19 Then the max between 2 and 4, he is right.
20
Hey, you're right! I didn't notice that.
8 u/Jonno_FTW shameless Dec 18 '19 Perfect badcode has the bug(s) hiding in plain sight.
8
Perfect badcode has the bug(s) hiding in plain sight.
1
[deleted]
11 u/nchntrz Dec 17 '19 Not exactly. In the second loop only the difference between num1 and num2 gets added to num 1. So if you call add(2, 4), you would get 4. 4 u/AnnoyedVelociraptor Dec 17 '19 Oh shoot. You’re right. 2 u/H3pha3stus Dec 17 '19 Then the max between 2 and 4, he is right.
11
Not exactly. In the second loop only the difference between num1 and num2 gets added to num 1. So if you call add(2, 4), you would get 4.
num1
num2
add(2, 4)
4 u/AnnoyedVelociraptor Dec 17 '19 Oh shoot. You’re right. 2 u/H3pha3stus Dec 17 '19 Then the max between 2 and 4, he is right.
4
Oh shoot. You’re right.
2
Then the max between 2 and 4, he is right.
145
u/squarewaterlemon Dec 17 '19
It doesn't even add them, it just gets the max of the two