I need more of these

I need more of these.

Post them.

Attached: 1531315949974.jpg (426x492, 32K)

Other urls found in this thread:

youtube.com/watch?v=dlrjDvS7wxo
cs.usfca.edu/~galles/visualization/AVLtree.html
lslwww.epfl.ch/pages/teaching/cours_lsl/sl_info/FPMultiplier.pdf
ideone.com/uRcsAD
twitter.com/SFWRedditGifs

Attached: 1531314687942.png (461x660, 62K)

Attached: sleepsort.png (1080x1920, 308K)

shitcode.net

Attached: 1533833977202.png.png (900x907, 130K)

Attached: ProgrammingJobInterviewAnswers.png.png (2752x4342, 742K)

Pretty sure this is a prank. He probably wrote a program generator to output this shit.
That's what I choose to believe.

Just open your github page.

>first post on /prog/
>it's capped by a fucking phone shitter

>Das edge

I've read this image over at least 10 times because it's hilarious, but I just decided to solve all of the questions in it because I'm trying to learn python.
Overall, it took me maybe 10 minutes to go through them all. The deck of cards one was the hardest - took me maybe about 5 minutes because I had to lookup the python function for 'push' which ended up being 'append' and also how to cast to a string. Still got it in 11 lines.

But really, are some people really this stupid? Like actually? I don't really code that much, but for the little I do know this is obscenely easy.

Attached: 1533583198618.png (718x2262, 508K)

>4784
No one would actually write something this long for something this stupid, it's obviously auto-generated and Jow Forums fell for it bad

Did I do it right?
result = [];
for( var i = 0; i

right, not good enough.
var result = new List();
for (var i = 1; i

Attached: 1412285542956.png (694x670, 101K)

Attached: 1412620393527.png (694x801, 77K)

Attached: 1412626224514.png (694x801, 82K)

Attached: 1412631739036.png (694x670, 114K)

Attached: 1412634782407.png (461x614, 82K)

Attached: 1412634985076.png (694x669, 70K)

Attached: 1412685468489.png (850x800, 115K)

Attached: 1412693917822.png (660x608, 98K)

Attached: 1412703125145.png (1515x663, 116K)

Attached: 1412736427823.png (694x670, 70K)

Attached: 1412821619446.png (694x801, 111K)

Attached: 1414259350012.png (1000x749, 90K)

Attached: 1414260193421.png (1600x1000, 41K)

Attached: 1503338675413.png (766x664, 151K)

Attached: 1414260977875.png (1004x612, 48K)

If you're going to make shit up you should at least make it relatively believable.

Attached: 1414264992773.png (1004x1627, 352K)

Attached: 1415006868791.jpg (685x547, 52K)

Attached: 1416105641110.png (1152x648, 218K)

Attached: 1508682904199.jpg (735x754, 122K)

Attached: 1423931094560.png (3000x3000, 288K)

Attached: 1425838394951.png (955x654, 139K)

Attached: oc.png (1000x1000, 86K)

What's wrong with this one?

Attached: rps.png (2492x3000, 258K)

>What's wrong with me?
Bools on bools.

Whats dis.Jow Forums.org? I cant seem to access it…

Setting up a lot of operations for something the modulus just tells you?

And for the cards
var seeds = ["hearts", "diamonds", "clubs", "pikes"]
var cards = [];
seeds.forEach( seed => {
for( var i = 1; i cards.splice( Math.floor( Math.random() * cards.length ), 1 )[0]

console.log( randomCard(), randomCard() );

youtube.com/watch?v=dlrjDvS7wxo

I still refuse to believe this is real. No way are there people that can't find odd numbers.

Attached: 1535384507698.jpg (425x424, 58K)

Stroustrup is rolling in his grave

He's still alive...

OK but... how do you actually do that? (Allowing doubles as inputs)

You didnt read the news? Sorry.

With a for cycle?

>(Allowing doubles as inputs)
You don't need a double as input as you can pass two any number of arguments you want.
Using double would only make sense for the return value, but as you don't need to return two values, but only one, there's no need.

>he doesn't use single characters for the suits
>pikes and not spades
Into the trash it goes

Holy shit getting a job will be easy
Boosted my confidence 100%

Good luck inverting AVL trees on a whiteboard.

Repeated addition. Would only work with integers, I don't immediately know if it's possible to multiple decimal numbers without * or /.

He means double as in floats/doubles.

I already did that as a "student teaches the class" exercise. It's not hard at all. You literally just flip nodes with the algorithm that you can derive in no more than a minute.

Attached: Duffcsgrad.png (900x775, 112K)

Try that while two to three interviewers are staring at you.

Good one.

But I had a whole class
Way more stressful since my grade was resting on it. If I fuck up an interview I'll just go to another company, their loss

Those were the text boards. They were killed in 2013.

This website helped me a lot to understand how the algorithm works.
cs.usfca.edu/~galles/visualization/AVLtree.html
B - trees are even easier

I feel stupid, of course it's possible to do such multiplications, I learned about this shit years ago. You would just have to implement a floating point multiplier algorithm in software.

lslwww.epfl.ch/pages/teaching/cours_lsl/sl_info/FPMultiplier.pdf

manually carry out IEEE754 multiplication, which I think involves a couple conditionals for subnormals, exponent addition, and multiplication (by e.g. repeated shift-add) for the mantissae

lost bc this actually is pajeet tier now

It's just unrolled.

Prepare to be underwhelmed.

function multiply ( a, b )
{
var p = 0;
do { ( a & 1 ) ? p += b : 0 ; b = 1 );
return p;
}


That's the multiplication itself. Applying it to Javascript's "Number" type (by means of more bit twiddling and the aforementioned floating point multiplier ) is left as an exercise to the reader.

You obviously lived a sheltered life...

any better ways to do this?

It won't go to N

isn't that a good algorithm?

I have a feeling people do this in a professional environment

Not using &?

just small mistake.
for (int i = 1; i

You absolute brainlets
int sum(int n) {

return (n * (n + 1)) >> 1;
}

How about adding how long you sleep using whatever methods there are instead of sleeping???

Attached: https_%2F%2Fblogs-images.forbes.com%2Fbrookecrothers%2Ffiles%2F2018%2F08%2Fpixel-3-xl-in-hand-rozetk (1280x868, 78K)

use

& 1
ftfy

public int Product(int a, int b) {
// calculate a and b's product with using the operator *
if(b == 0) {
return 0;
}
return b > 0 ? a + Product(a, b - 1): -Product(a -b);
}

it was in the 90s, but now compilers have improved enough that Duff devices get in their way and prevent them from making higher level optimizations. They stripped all the Duffs out of some old Cisco router library code and performance improved significantly

You think you're cute posting Duff's device, but fuck off.

I'd write this as async so the method wouldn't block until this time tomorrow.

Attached: 1501821748161.png (1790x1071, 288K)

is right-shifting once is faster compared to multiply by 0.5?

It's readability. The compiler optimises it to do right shift by one regardless. I just prefer writing it this way, but in terms of CPU yes, shifting is way faster than any kind of multiplication.

nevermind. i just read that the era of bitwise operation is faster is in the past. today's machines and compilers are smarter than before.

i tested it in c#. do multiplication vs right shifting for n time (n is large number) and the right shift is slower.

If you were writing assembly on a simple CPU like a teaching tool yeh.
Most compilers would optimise away all of those operations and it wouldn't matter which way you wrote it.
I don't know about real assembly on a real modern CPU, no one knows what really goes on inside those.

This algorithm could have been forever connected with his name. Instead he just posts it on some Anonymous board.

i tried running the code in linqpad and right shifting is slower. then i tried it in ideone and it's faster. weird. same result as linqpad in dotnetfiddler (slower).

ideone.com/uRcsAD

return (a >> 1);
return (a / 2);

is mostly equivalent on modern CPUs, as in it will be compiled to a right shit, but
return (a * 0.5);

will not be compiled as a right shift, as SSE extensions will be used. See:
/tmp/tmp.Oq86TEyh6b  cat test.c
unsigned multiplication(unsigned a) {

return (unsigned) (a * 0.5);
}

unsigned division(unsigned a) {

return (unsigned) (a / 2);
}
unsigned shift(unsigned a) {

return (unsigned) (a >> 1);
}
/tmp/tmp.Oq86TEyh6b  gcc -mgeneral-regs-only -O3 -c -o test test.c
test.c: In function ‘multiplication’:
test.c:3:9: error: SSE register return with SSE disabled
return (unsigned) (a * 0.5);
^~~~~~~~~~~~~~~~~~~~
x  /tmp/tmp.Oq86TEyh6b  gcc -O3 -c -o test test.c
/tmp/tmp.Oq86TEyh6b  objdump -d test

test: file format elf64-x86-64


Disassembly of section .text:

0000000000000000 :
0: 89 ff mov %edi,%edi
2: 66 0f ef c0 pxor %xmm0,%xmm0
6: f2 48 0f 2a c7 cvtsi2sd %rdi,%xmm0
b: f2 0f 59 05 00 00 00 mulsd 0x0(%rip),%xmm0 # 13
12: 00
13: f2 48 0f 2c c0 cvttsd2si %xmm0,%rax
18: c3 retq
19: 0f 1f 80 00 00 00 00 nopl 0x0(%rax)

0000000000000020 :
20: 89 f8 mov %edi,%eax
22: d1 e8 shr %eax
24: c3 retq
25: 66 66 2e 0f 1f 84 00 data16 nopw %cs:0x0(%rax,%rax,1)
2c: 00 00 00 00

0000000000000030 :
30: 89 f8 mov %edi,%eax
32: d1 e8 shr %eax
34: c3 retq

No you retards.
You can just
return (n % 2);

You'll only need one function that either returns true or false (1 or 0).

"a" could also be 0, you should add that to the first if.

Copying & pasting the implementation of one method and just changing the value the expression is tested against is asking for someone to make a typo when you could just define IsNumberOdd then make IsNumberEven return its negation.

You're the retard. You could just use node and import is-odd.

tried it in rextester and it tied. what's the result in c? which one is faster using the same test case as mine? see the code in:
ideone.com/uRcsAD

weekly download 1,552,898
noice

Then its
return !(n % 2);

You're missing the point

if(-1 & 1) printf("t. bitlet");

Holy. Shit. Are most "coders" really this stupid?