Applying for programming jobs

>applying for programming jobs
>get interview
>introductions go well, going over resume etc
>"okay user just a couple questions to work through"
>You have 3 and 5 liter jugs how to measure out 4 liters?
>How many ping pong balls can fit in the Titanic
>Prove Pi is irrational
WHAT THE FUUCKKK

Attached: die-hard.png (178x233, 99K)

Other urls found in this thread:

youtube.com/watch?v=IW0oA3Pxe-Q
en.wikipedia.org/wiki/Proof_that_π_is_irrational
sighingnow.github.io/coq/a_formal_proof_for_sqrt_2_is_irrational.html
twitter.com/SFWRedditGifs

learn to code

>Fill the 5 litre can from the tap
>Empty the 5 litre can into the 3 litre can - leaving 2 litres in the 5 litre can.
>Pour away the contents of the 3 litre can.
>Fill the 3 litre can with the 2 litres from the 5 litre can - leaving 2 litres in the 3 litre can.
>Fill the 5 litre can from the tap.
>Fill the remaining 1 litre space in the 3 litre can from the 5 litre can.
>Leaving 4 litres in the 5 litre can.

>How many ping pong balls can fit in the Titanic
many

>Prove Pi is irrational
no

Programmers should be able to figure out the jugs one.

>You have 3 and 5 liter jugs how to measure out 4 liters?
I knew runescape would prepare me for something

They're BS questions, really the goal is to disqualify Americans do they can hire 10 street shitting pajeets.

I was thinking the exact same thing. Fremminik Trials quest or whatever.

you're pathetic m8

>Prove Pi is irrational
The other two aren't as bad but who the fuck even knows how to start this without being at least a math minor?

put the poo-poo in the loo, Vhart

If you lack basic problem solving skill you deserve to be replaced.

>No American could answer these.
Deserved then.

Assume rational, pi = p/q.
Okay I'm stuck...

Programming skills > memento tier joke questions

I'll grant you a point if you prove you shit in a toilet.

If you can't into basic problem solving your programming skills are bound to also be shit.

Proving sqrt(2) is reasonable pi is not.

It's a fucking joke question designed to fail autists, who are wizardly coders but nervous af. I saw a dozen if the best programmers I know fail out before some math major who can barely code and hates it (girl) beat them.

If you support shit like this then you are a shill for globohomo corporations.

>Proving sqrt(2)
do it then faggot

If you're too autistic to perform during an interview, then it doesn't matter what questions I ask you. If you've studied computer science at a university you should have the basic math knowledge to solve these.

>How many ping pong balls can fit in the Titanic
479635573

idiots

In school, you are taught that pi is irrational. Only facts are taught in school. Ergo pi being irrational is a fact.

But Pi IS the ratio between a circumference and its diameter, so its by definition rational.

This method creates 6 L of waste water
A more efficient way would be to fill the 3 liter jug first, and then pour it in the 5 liter jug, refill the 3 liter jug, then use the 3 litrer jug to finish filling the 5 liter jug (so there is 1 L in the 3 L jug). Throw away the 5 liters of water in the 5 L jug, and put the 1 L of water in the 5 L jug. Finish by filling the 3 L jug, and pouring it in the 5 L jug to get 4 L of water.

>Yes Mr. user we saw you implemented a b tree that's very nice
>but i'm afraid we're going to have to go with with the guy who studied math parlor tricks

>Thinking anyone actually does this
>Thinking I wouldn't just walk out immediately

Can't you just fill half of the 5 litre jug and half of the 3 litre jug and then put the water of the 3 liter jug into the 5 liter jug and get 4 litres?

I mean, 5/2 is 2.5, and 3/2 is 1.5, 2.5+1.5 is 4, so it makes sense right?

Right?

No job in silicon valley for you then.

Oh wow, I don't get to live in a total shit hole. Thanks no thanks.

If jug is fat in bottom area then you can't measure correctly.

Huh

Well I guess I'm too dumb to be a programmer then, I can't come up with any other solution.

As no rules specified whether new containers could be introduced or not:
Place 3L jug in a waterproof container. Fill 5L jug completely, transfer to 3L jug. 2L overflows into the new container. Move the remaining 3L back to the 5L jug, fill back up completely, repeat first step. You now have 4L in the new container.

You are allowed to pour jugs into other jugs, and to stop pouring when you see an obvious end ( like, you can stop pouring when a jug becomes empty, or when a jug becomes full).

bsuck.basrd

>do it then faggot
suppose sqrt(2) is rational, therefore
sqrt(2) = a/b, therefore
2 = (a^2)/(b^2).
this can be rearranged as a^2 = 2b^2.
now we know that a^2 must be an even number, therefore a must be even as well.
since all even numbers can be written as 2 times a number, we can replace a with 2k, giving us
2 = ((2k)^2)/(b^2)
now reduce
2 = (4k^2)/(b^2)
2b^2 = 4k^2
b^2 = 2k^2
this means that b^2 is even, because it is equal to 2 times a number k.
this is a contradiction, because there exists no ratio a/b where both a and b are even numbers, and we prove that sqrt(2) ≠ a/b, and therefore irrational.

There is literally no reason to have a B-tree when you can use an AVL tree, and neither AVL trees, nor B-Trees are more impressive than basic parlor tricks.

I know but I can't come up with anything.

I understand the solutions that have been posted in the thread but I don't think I could have come up with them on my own, atleast not in a short amount of time.

autism

These types of problems are a skill in their own. If you want to be better at them, practice. However it won't make you a good programmer, hence this thread.

If you cant figure out the jug question then your university has failed you massively.

Here is an easier problem: write a recursive function that finds the mid point of a singly connected linked list (given the head of the list as an input). You may assume the linked list is non-empty, and that it has an odd number of nodes.

>WHAT THE FUUCKKK
They are bored.
They have already interviewed more candidates that they can remember.
They are fucking with you.

def get_midpoint(head):
counter = get_len(head)//2
while counter:
head = head.next
counter -= 1
return head

def get_len(head):
if head != None:
return get_len(head.next) + 1
return 0

Attached: 1536571815948.gif (200x172, 70K)

>Fill 5L jug completely
>Pour into 3L jug, fill completely
>2L left over in 5L jug (big jug)
>Pour out 3L jug (from small jug)
>Pour the 2L in the big jug into the small jug so 1L remains empty in the small jug
>Fill 5L completely once more
>Now fill the small jug completely leaving 4L in the big jug.

Stop interviewing and freelance. Jobs are for suckers, built shit and people will want you.

Between a candidate that has rote memorized how to implement a B-tree, versus a candidate that knows the complexity of each operation in both CPU and I/O? I'll always pick the latter.

How do you know that you are filling 2L? The probability that you land on exactly 2L is 0. (It's a continuous function.

If we assume we are able to fill and empty both containers to their exact volumes it works. No use over thinking it.

These questions are not meant to be straight answer but rather to evaluate your behaviour. This is how I would answer:

1. fill each jug half way
>Straight forward and simple, shows you get the job done instead of coming up with passing water from one to the other.

2. Dunno, but I would get the dimensions of Titanic online, calculate it's volume and then divide by a ping pong ball volume
>Shows you know how to find out a solution for a problem no-one would have an answer

3. Dunno, but it has something to do about the number of times you can fit the diameter in the circumference.
>At least I tried.

That's all well and good if it actually happens, but if it did this would most likely be the outcome.

No, with a single recursive function. Your one and only recursive function may use a single if else statement (no loops, no iteration).

It's probably the easiest, but I can't solve it. You show pi = perimeter/(2*radius) and prove the perimeter is irrational or something.

>jugs
time for formal methods
youtube.com/watch?v=IW0oA3Pxe-Q

They don't ask poojets these questions.

[/code]
middle [x] = x
middle (x : xs@(_:_)) = middle (init xs)
middle _ = error "The list is supposed to be of odd length retard!"

en.wikipedia.org/wiki/Proof_that_π_is_irrational

Expecting someone to come up with something like these on the spot is not reasonable (even in math academia, let alone a programming interview). It would only serve to check if the candidate happens to know it by heart, but why anyone would be interested in such a thing I can't imagine.

>How many ping pong balls can fit in the Titanic

trick question. it's 0, water already took all available space

>4 litres out of a 5 and 3 liter jug
>fill 5 liter jug halfway (2.5 liters)
>fill 3 liter jug halfway (1.5 liters)1.5 plus 2.5 equals 4 took me all of 5 seconds to figure out, maybe you should apply at mcdonalds or whatever. the cash registers tell you how much change the customers get now so you wont have to use math

Bit sloppy.
>no ratio a/b where both a and b are even numbers
>2/4
You have to instead assume at the beginning, that without loss of generality, a and b do not have common divisors.

This wouldn't work if the jugs are unevenly shaped and you don't know what 'halfway' is.

Not OP but you're obviously retarded. The question implies that there are no markings and you can only fill either jug to maximum capacity and empty it all out. Learn to fucking greentext as well you moron

sighingnow.github.io/coq/a_formal_proof_for_sqrt_2_is_irrational.html

I wanted to screencap this but couldn't make it fit on a page.

>basic math
>proving pi is irrational
Go on, post this trivial proof if it's so easy.

Pi is irrational because who in their right mind would call something pi without being able to eat it.

Attached: RationalPie.jpg (960x960, 388K)

Alright that settles it, let's introduce you to the team you'll be working with.

>just answer its not hard
>the specifications are missing critical information and need to be reviewed before work can begin
>not my job, I'm a software engineer not a theoretical mathematician

pi = pi/1. Therefore pi is rational.

What if you just fill both halfway and pour the 3L half into the 5L half. 1.5 and 2.5 = 4

BTFO

What if you just fill the 5L 4/5th?

How do you eyeball 4/5ths completion? Half is a pretty easily visible property.

This meme questions are there so they can throw everyone out besides the one guy they have already chosen (the nephew of some middle manager)

There is no reason to use an AVL tree when red-black trees exist

>brainlets can't prove pi is irrational

Based and redpilled

You don't and neither do you eyball half. That's my point. The only reason to even consider this thought experiment is when you assume that only 3L and 5L can be measured to sufficient accuracy.
The question doesn't make any sense otherwise.