So /g/, what distinguishes a good programmer from a bad one?
comments
>>55313260
The amount of hair on his neck.
>>55313303
What's wrong with the * operator?
gotta unroll your loops
>>55313346
It's a programming challenge to write something without using X
>>55313346
I assume the 'right' way to do this exercise would be like this.def mul(a, b):
ret = 0
while b != 0:
ret += a
b -= 1
return ret
I guess the idea is to show an understanding of how to implement a multiplication algorithm? (The answer there shows a serious lack of understanding of the basic principle of abstraction, so it's indicative of *something*.)
>>55313388
Also, inb4 not handling non-integers or negative numbers.
>>55313260
holy fukken jesus. This can't be real
>>55313303
Everyone who I've seen try to do this one never does it without a loop and it makes me cringe. Here's the my one line version in c#public static int Product(int a, int b) {
return (b == 0) ? 0 : a + Product(a,b-1);
}
>>55313741
that's 3 lines; where did you learn to count?
>>55313781
You know you can put the header and closing bracket in the same line with the code, right? It's a return statement, not lambda calculus. I put it in 3 separate lines for readability because I'm on my phone like a lot of people and scrolling horizontally is shitty.
>>55313741
>recursion is better than iteration
what the fuck?
are you retarded?
>>55313303
Oh, now I get it, the asterisk is multiple sign, not the pointer
>>55313260
The """"correct"""" way to do that would be loading a list of those numbers from a CSV file and checking against each one using a loop
>>55313741
stupid idiot
>>55313825
>m-muh clock speed
What kind of shitty CPU are you running that the speed of an extra nanosecond to compute recursively is noticeable compared to a loop? There's no point in wasting lines on looping when you can do it in a return line using the null check operators.
>>55313876
>:^)
>>55313886
>fuck speed
>fuck readability
>fuck languages with no tail recursion optimization
hello pajeet
>>55313864
>>55313260
Just use sieve of eratosthenes or, at least brute force the damn thing
>>55313906
you must be a cs course student
>>55313886
Why the fuck should I care about having more or less lines and not about performance? Are you retarded?
>>55313864
The ""correct"" way would be using a modified sieve of eratosthenes to generate the first n primes along with their co-primes.
>>55313950
O(sqrt(n)), but better than THAT.
>>55313937
>wat is golfing
>>55313925
Pajeet thinks not having a CS degree is like a badge of honour. Paheet have no time for you.
>>55313886
Your shitty Pajeet attitude is why some much software is pure shit these days. Poo in the loo... more like poo in the software.
>>55313906
This guy gets it.
(You)'s
>>55313886
>what is stack