Logic Puzzles

Do logic puzzles help in programming? I'm shit at math but mostly because in class they always say I have to solve a certain problem in this specific way. But I like playing around with logic problems. Anyone ever heard of this one?

Yes. I had an interview once and the question was something about eight blocks. The interviewer then said they all look the same and weigh the same. I must find the one that is heavier than the others. Except I wasn't allowed to pick them up and feel how heavy they are. However there is a balance scale and I can weigh them, but the objective was to do it in the least amount of tries possible.

I answered by saying that you split them into two groups of 4. Then the side that is the heaviest, take two of the 4 and place them on the side of the balance scale that was lighter. Again, the side that was the heaviest had the heavier block on it. So take the two blocks of the lighter side and replace them with one of the blocks that's on the heavier side. After weighing them again you're able to determine the heavier block. In all this takes 3 tries. However there may be various answers to this type of logic problem. You often see these types of logic problems in a branch of mathematics called discrete mathematics/structures. The professor I had for that course liked to call it computer science math. We didn't do a whole lot of algebra or precalculus. The course mainly went over permutations, combinations, number theory, graph theory, and probabilities.

The "you need to be good at maths to be a good programmer" meme needs to die already, every piece of maths you need is either googlable, binary or year 9 level

Am I being trolled?

no

Are those the types of interviews they give for programming positions that I keep hearing about?

You don't need Math for making a webpage in the same way you don't need a nuke to take down a wild nigger. But try to write OpenGL/DirectX without knowing the bare basics.
Same goes for logic and writing code that doesn't look like if(a==b) return true else if(a!=b) return false else return false.

Yes. You can find the answers to most of those questions online, but personally I like trying to solve them myself before I look for someone else's answer. They're primarily analyzing your thought process and how you might approach the problem and not necessarily if you get it right or wrong (unless you're interviewing for Google). I was allowed to ask questions like, "are the blocks in any sequential order" and stuff of that nature. They wanted me to go over my thought process aloud. Eventually they did offer me a position, but took another position with a different company.

I should've been more specific. The interviewer did say that all the blocks looked the same. Aswell as all weighing the same except for one. He said I wasn't allowed to pick it up and even if I did "I wouldn't feel the difference" for the sake of the interview question.

Where do I need to throw my CV in order to work in fields where I do programming where you actually need to think and know math?

This comes under 'googlable'.

In the trash

That makes a lot more sense now, I was about to join in laughing at you.


Agreed. They're just pointless ego stroking.

What you want his CV for user?

I would weigh all of the blocks on a balance and not waste time thinking about stupid theoretical non-ways to solve the problem.

"Solve this problem in as few steps as possible in a way that's simple enough to automate" is a very common problem in programming. That question is testing whether you can think of a binary search algorithm.

woooooow so hard

Do you know what a balance scale does?

do you know what a shotgun does?

...

That's not a balance scale, Pajeet. Pic related is one.

Holy shit. Your cluster fuck of nested if/else conditions must be a ball trying to decipher.

...

What helps in programming is programming. Just come up with an idea and make it. That way you learn everything when you need it.

I'm not sure how the "weight half against the other" applies to programming, as you can't "weight" data.

You'd need to assume it's already been sorted or something, otherwise you have to check everything to be sure anyways.

What happens if you ask the true god what the random god would say?

They simply want to know if you are not a retard that wants to do everything linearly when there is a logarithmic solution to the problem.

THIS is why you need discreet maths, and will never become great programmer without the maths.

Or worse, in quadratic time like this street shitter:

That's not quadratic you stupid fuck

So I ask them "is 1 + 1 = 2?" 9000 times to bust the Random one.
The difference between True and False is strictly semantic then.

Only "yes" or "no", moron.

It gives you random answer.


Read OP image, you are limited to 3 questions.

Image

Just ask them who are the identities to each?

Yes/No would random god say you were a faggot?

Too bad the real solution is that you ask multiple questions (bi-conditional questions) in one question.. CONUNDRUM! So the answer is to break the rules of the question.

I know the riddle of two trolls, one of whom always lies and one of whom always tells the truth, at a fork in the road where you can only ask one of them one question about the correct path. You just pick one and ask which path the other would claim to be correct, then take the other path.

How the hell do you solve this one in OP? The random element and also not knowing "yes" from "no" really sounds like it makes this impossible in only three questions. Am I being trolled?

I think the easiest way is to know someone who knows someone whose company is looking for someone with your background. Then of course you need to know your shit and not fuck up the interview because the guy vouched for you. Needless to say if you know nobody this will not work and will need to go through the hard path.

It works based on using statements that both false and true will answer truthfully.

For example we can ask God 2: "If I asked you: Is God 1 random, would you say ja?" If God 2 says ja, that means that either God 2 is random, or God 1 is random. If he says da, then either God 2 is random, or god 3 is random. Either way you can then go to the God that is not random (since you know which one of them is not now) and ask "If I asked you: Are you False, would you say Ja?" if he answers Ja, this means that he is false, if he answers Da it means that he is True. You can then ask him "Is God 2 random?" and if he answers Ja, it means God 2 is random, if he answers Da, it means the God you haven't spoken to yet is random.

This works because both true and false will respond to this question truthfully because false would go through this process (for example): Is God 2 random (yes): would I respond with yes (no) so I respond with yes.

True would go through this: Is God 2 random (yes): would I respond with yes (yes), so he responds with yes.

The lack of knowledge of Ja and Da doesn't matter because which God is true or false is based on your assumptions about yes and no. IE, if your assumption is wrong, then you think false is true, and because you also think yes is no (and vice versa) you interpret his lying as the truth.

#rekt