- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
I think you would have to deflate the tires so that they look flat for this to work.
Otherwise, Why do I bother checking the pressure in my car? If the air pressure in the tire always balances the weight of the vehicle, the pressure would always be the same regardless as to how inflated the tires were. My pressure gauge would be worthless, and I should just look for flatness to know when to put more air in.
Measuring the pressure of a half-flat tire would work though (within some margin of error).
Admin
[quote user="YourMoFoFriend"]Clearly you haven’t debugged some of the stuff I had to :) If only there was a forum where people could share their programming horror stories… :))[/quote] I've had my share of debugging applications developed by inane programmers. However, the computer itself is still completely logical and consistent, and that knowledge can be used to help the debugging process. If computers simply did whatever they wanted and invert logic however it wanted (just like a lot of brainteasers), it'd be impossible to debug without resorting to asking the computer to "be nice, pretty please, with sugar on top".
[quote user="YourMoFoFriend"][quote user="OutsideInwards"]There are no doors and no windows. The only items in the room with you is a table and a mirror. How do you get out? [/quote]So, what did you say? I honestly don't remember. It wasn't as silly as the "correct" answer (somebody else posted).
Admin
My two interviewing pet peeves (not related to riddles so I realize a little off topic) is
Saying "Let's start with an easy one...". There is no reason to say this, EVER. If the person gets it right, it makes no difference. If they get it wrong, they are just going to feel that much worse for not knowing. It can make the rest of the interview go really awkwardly.
Arguing (as the interviewer) to see how the person responds. I trained myself a long time ago not to argue too much with the interviewer. Sometimes you have another valid solution to the problem (brainteaser/puzzle/tech question) and the person just doesn't understand your point/dismisses it out of hand/whatever. I try and defend my point, but also try and recognize the point where I'm just hurting my cause. The chances of you convincing them you are right is really really low and the chances that they with think you are a jerk or are unwilling to take criticism is really high. I personally think this is part of what makes me a good interviewee. Then I find that there are people who intentionally argue with people, even if they give the correct and expected answer, just to see how they defend their point. A valid technique in a way, but now what do I do? If I am being interviewed do I argue or not? How can I know which type of interviewer this is?
Admin
Admin
Admin
Or that the brainteaser was a part of a larger group of questions and they didn't get the job based on their responses to actual technical questions.
It's actually too bad that there isn't a better way to learn from "failed" interviews so that we know what we should work on for future interviews. Feedback like "we didn't feel like you had the OOP experience we were looking for", "We found you to be a bit too standoffish" and the like would be great. Too often it is just "we don't think you fit our requirements at this time", if that. Even more too often you have to bug them to even get a no.
Admin
This is one of those tl;dr threads, but the coin problem was chewed over in the mathematics LJ community a while back.
Here's the original discussion: http://community.livejournal.com/mathematics/988261.html
And the solution: http://community.livejournal.com/mathematics/988982.html#cutid1
The trinary seach still sorta works, but the trick is to swap around the coins that are possibly light & possibly heavy.
For instance, starting with 8 coins (numbered 1 through 8): place (1,2,3) on the left scale, (4,5,6) on the right, leaving aside 7 & 8.
If it balances, obviously it takes 2 more weighings to determine if 7 or 8 is heavier or lighter. Total = 3.
If the first try instead tiles (say left), we know that one of (1,2,3) is heavy OR one of (4,5,6) is light, and that 7 & 8 are good coins.
Split the group and place one possibly-heavy and possibly-light each on either side of the scale, such as: (1,4) against (2,5), leaving (3,6) aside & unknown.
After this second weighing, there are three cases:
In case 1, one more weighing solves it: weight 3 against a good coin, and if it tilts 3 is heavy, otherwise 6 is light. Total = 3.
In case 2, either 1 is heavy or 5 is light, 2 & 4 are obviously good (because switching sides of the scale didn't affect the outcome). Similar to case 1, one more weighing against a good coins solves it. Total = 3.
In case 3, the two coins that switched sides are the potentially bad ones because switching sides DID affect the outcome. So either 2 is heavy or 4 is light. As with the first case, one more weighing solves it. Total = 3.
Using this method, with 7 good coins and 1 bad coin that is either lighter or heavier than the rest, you can determine which coin is bad and whether it is heavy or light in 3 weighings.
Admin
Admin
Actually you are wrong here. When the tire is partially flat or underinflated, the tire has less air pressure inside but more area contacting the ground. When you overinflate the tire it rises up and has less area contacting the ground.
This nicely fits in with the following: Pounds per square inch * Square Inches on ground = Weight of vehicle
Using a tire pressure gauge and checking for proper pressure is much easier than using a chalk outline of the surface of the tire on the ground and calculating the square inches on the surface of the road. Although both could be used as a proper indicator of correct inflation of your tires.
Admin
The coin answer is 2 weighings. Put 3 coins on each side;
If the sides are equal, then you know it's one of the other 2 coins. Use one more weighing between those 2 to find the odd coin.
If the sides are not equal, you know which set of 3 has the heavier coin. Pick 2 of those 3 coins, and weigh them against each other. If they're equal, the 3rd coin is the heavier one. If they're not equal, you know which one is heavier.
I actually use this in group meetings with programmers, and have people talk through the problem out loud. One declared a "mathematical impossibility" that the answer is less than 3 weighing.
Admin
I believe, and I could be wrong here, but I believe that the persons point is that there gets to be a point where the tires are fully inflated but it is still possible to add more air. That is, assume I use this method to measure the weight of my car. Say I make sure that each tire is at 40 psi which is what I think is recommended. I measure the area, do the multiplication, get some number. Now I overinflate the tires to 44 psi. I'll probably get basically the same area so doing the math will result in a much larger weight now, which is obviously wrong.
The problem is that in theory, adding more air always results in lowered surface area continuously, in such a way that as the pressure goes towards infinity the area goes towards zero. In reality, it doesn't work out quite that way due to the material properties of the rubber in the tires and other unseen factors. Remember, in theory, theory and reality are the same thing. In reality, they never are.
The only way to guarentee that you haven't gotten to a point where adding more air doesn't noticibly affect the area is to have the tires at least a little underinflated.
Admin
How about the original problem where you don't know if the coin is heavier or lighter? Throw that at the group and see if anyone falls for the "2 weighings" answer.
Admin
Admin
That was more or less what I was trying to say.
If the tire is fully inflated, some of the internal pressure is due to inflating the tire itself. (The tire still maintains pressure if suspended in midair). And this internal pressure would introduce significant error into the measurements.
Reducing the tire pressure a bit would greatly minimize this error. What we want is a tire pressure that reads as close to 1 Atm. as possible when suspended in mid air, yet still keeps the rubber off the rim when loaded.
Keep in mind that we are dealing with real tires here, not the theoretical ones you buy from this company
Admin
Admin
No, No ! As the pressure in your tire decreases, the tire will get flatter, and flatter, so that the surface of the tire in contact with the road increases, exactly as much as is necessary to keep the product of the surface area times the pressure equal to the weight of the car. At all times, at the point where the "Rubber meets the road", (to coin a phrase) there is an equilibrium. The force of the tire pushing on the road must exactly balance the force the road is pushing back on the tire. The force of the tire on the road is the air pressure, pounds per square inch (of surface area in contact), times the surface area in contact.
Admin
No, actually it does go exactly that way. In reality, in this case, they really are. If they weren't, (like say if you are sitting on the fender and suddenly jump off) the car would accelerate upwards, until the surface area in contact with the ground decreases sufficiently to bring the forces in balance again.
Admin
Ah, but the question is would it change enough for you to measure the difference? Take my example where you inflate the tires to where they look full and measure the area, and then add say 4-5 psi more air which I'm guessing will be ~10% increase in pressure and see if you actually get an exactly corresponding decrease in area. Honestly, do the test and you'll find that you don't. Especially if all you are doing is driving into the paper and tracing it with a pencil as I believe the orignal proposal was.
Admin
Jack,
Sorry, you are intuitively wrong. The internal pressure is not "due to inflating the tire itself",
It is simple equilibrium. At the point the tire touches the ground, there must be exact balance between the force the tire exerts on the portion of the ground it is touching, and the weight of the car. an EXACT balance. If these two values are not in balancfe, the car will move, upwards, or downwards, until there is exact balance. The movement up, (or down) changes both the internal ttire pressure, and the surface area. Downwards movement slightly inreases the surface area (and also slightly increases tire pressure) upwards motion decreases surface area. Imagine putting the car on hydraulic lift, and slowly letting it down onto the groun, from dangling totally suspended, with all weight on the lift, until the lift arms fall free under the car. At each point in this process, sum of the tire pressure times the surface area plus the weight being held by the lift, will equal the total weight of the car.
Admin
This was the confusing statement in my OP. "If the air pressure in the tire always balances the weight of the vehicle, the pressure would always be the same regardless as to how inflated the tires were."
I was thinking about my car, and how the tire does not visibly change contact area with air pressure/load.
That got me thinking about the difficulties in measuring contact area, and then I neglected area altoghethe.
P*A = W is correct.
However, some of the pressure is internal pressure of the tire, which ends up stretching the rubber and steel. A simple P*A calculation will be inaccurate because it doesn't take into this into account. The sidewalls of the tire will also bear some load (although miniscule in relation to an airplane).
You will get better results if you use a partially inflated tire.
All of which means that I have to get my snow tires out of the storeroom tonight or my boss will toss them.
Admin
Ah, the old "intuitively wrong" argument. Always a good way to win an argument.
Just like the people earlier saying that you couldn't possibly provide a solution to the hat problem that was right 75% of the time because their intuition and enough stat knowledge to make them dangerous told them it couldn't be.
Just like the guy who understood that if you got 4 heads in a row, the probility of getting another head is 50%, but intuitively its more likely to be tails next.
My answer comes from an extensive educational and professionaly experience in physics where no matter how "right" your physics is, the experiments can trick you.
I'm not at all disagreeing with your physics. You can explain it as many times as youd like, it wont change anything because I already agree with you. Its the how acurate is your measurement that I'd like to see.
And you actually provide me with my next point. Your statement below is that the force the tire is exerting on thr ground, blah, blah, blah. Basically the pressure of the tire onto the ground times the area gives you the force the tire is exerting to the ground, which by newton is the same as the force the ground is exerting on the tire, giving you the weight. Can you assert that the tire pressure you measure in the stem of the tube within the tire (a tire with a tread pattern onit) is exactly the same as the pressure the tire itself is exerting on the ground?
Admin
The reason for checking is that too little pressure means a large area of contact caused by a more-deformed tire, causing more flex in the tire material as it rotates, causing more heat, causing the material to break down faster. Too much pressure is no good, either. This is because it is exerting more pressure against the material than it was designed for, plus you have reduced the contact area, reducing the ability to control the vehicle.
A little less pressure means only a little bit more flattening, and may not be easily detected visually.Admin
Admin
And it's who that is self-righteous in our conversation? That is me, too? OK. Thanks for setting me straight.
So next time I'm being interviewed by a total idiot, instead of thinking "I don't want to work with/for total idiots" I will instead think, "I must do a song & dance for the idiot, or else people on the internet will say I failed."
Excellent choices I have there. Awesome.
Admin
No, it's true. There's always a contact area. It's not that the pressure "always balances the weight of the car", but pressure exerts its force uniformly over the interior of the tire, so if you press against the tire, it pushes back with a force equal to the pressure times the contact area. And since the car is going neither up nor down, the balancing force from the ground must equal the downwards force exerted by gravity (AKA weight). So the contact area times the pressure does give you the weight of the car. There can only be zero contact area if the tire is completely rigid (infinite pressure) or the car is weightless. And that matches the limits of the equation too.
Admin
You do not know if the coin is heavier or lighter than the others!
Admin
Ahh, My bad, I thought you were disagreeing with the physics... To add more agreement, you could not be more correct about the difficulties in using this concept t oactually measure the weight of anything... It would be extremely difficult (to say the least) to get an accurate measurement of the surc=face area of the tire in contact with the ground. Even if you could accurately draw the outline of the tire, the portions of the tire where the grooves are would need to subtracted, where they are not touching. Additionally, ther would be irregularities associated with the distribution of the internal tire pressure (equal everywhere on the inside of the tire) to the outside surface of the tire tread... It would NOT be equivilent everywhere on the tread. These difficulties would likely make this approach impractical, albiet "in theory" doable.
It's just that the distinction between "theory" and "practice" does not in any way change the physics, or the truth if the principle, It only changes the engineering efficacy of the technique.
Admin
Believe it or not, I did pass thermo and fluids, and the one statement that everyone is jumping has been retracted.
However, a rubber tire is not a weightless balloon or a frictionless piston chamber. It is a semi-rigid body which will distort the results.
I suggest that lowering the pressure in the tire will produce a better result than using a high pressure tire. Pressure is reasonably easy to measure, so for lab purposes I don't really care.
Areas however tend to be irregular and hard to measure. Furthermore, there are effects at the edge of the footprint where the force goes from 100% to 0% over a non-trivial area. (remember, aircraft tires are balloon shaped) This edge effect will be significant in a high pressure tire.
Flattening the tire will significantly increase the footprint ( say by a factor of x) and increase the edge by a much lesser amount (sqrt(x))
Total error is c * perimeter, or C1 * sqrt(A). % err is then c1 * sqrt(A)/A or c1/sqrt(A). ( *100)
Plot 1/sqrt(x) and you will get a graph which goes to infinity at x= 0, and 0 at x=infinity and goes through (1,1)
This shows that there is significant error at high pressure - small footprint and much less error at low pressure - large footprint.
Admin
But to answer your other point, Yes, I can assert that the sum (actually the surface Integral, since it's a continuous pressure distribution across the surface in contact with the ground) of the pressure at each point on the tire in contact with the ground, integrated over that surface area, will exactly equal the weight of the car.
Admin
I'm glad we are in agreement. It's too bad it wouldn't be easy to do though. Otherwise it would be pretty easy to build a system to use at the "weigh stations" for semi's that is cheaper than what they have now.
Admin
Admin
Admin
And, by application of Stokes theorem, (I think it's Stokes thereom), this must be equal to the tire pressure inside the tire times the same total surface area.
Admin
Manhole covers should not move when wet or iced up when people walk, drive or stand on them, hence the protrusion (or notch in some countries). It is rare that the notch or protrusion has to do its job because it is rare that the manhole cover is that heavily loaded, but a truck driving over it will do it every time - the driver would find it unsettling at least if the cover spun under his driving wheels.
Man I never thought that bit of info would be useful....
Admin
Looks like someone found wikipedia! Just kidding. No offense, really.
Admin
Two things:
Computers are ideally predictable but the people who program them aren't. More specifically, you can write perfect code according to a specification, and the code might still fail if the specification wasn't perfect. You could use a third-party library perfectly according to the documentation, but the documentation could be incorrect, or the library might be buggy. Even the debugger itself may make your program behave differently, and ultimately some things can't simply be tested in a debugger, such as distributed processing tasks. Which leads up to,
The programs themselves may be neatly deterministic, but read up on chaotic dynamics to see how a "simple" system can turn into a counterintuitive monster of complexity. Then couple that with the complexity of a modern OS like Windows, and add a billion users who will all most likely do the wrong thing at one point or another. After pondering "legacy software support", consider that legions of third-party developers over whom you have no direct control will be writing interdependent drivers and other add-ons. Then, OMG, what if many of those people decided to connect all their uniquely configured systems via a global network of some sort?
Short version: You can not count on the logic of the computer any more than you can count on the logic of a brain teaser. Brain teasers follow formal logic in a creative and/or purposefully incorrect way. The difference to programming is programmers don't get it wrong on purpose.
Specifically, the $29 question follows perfectly sound logic up to a point where an error is made. It's a teaser because the question itself is false, which is unexpected. You should be able to immediately realize there IS something wrong though, and if you then can't identify the bad logic, how can you claim to know what good logic is?
Similarly, you may have seen some of those mathematical "proofs" that 1=2, usually involving a disguised division by zero. That's an incorrect application of maths, but the people who can tell you what's wrong with it are precisely the people who can also do it right.
The inescapable-room question is not a brain teaser, BTW, it's a joke. Using it as a brain teaser suggests the interviewer (not necessarily the company) read some book about interviewing techniques and gravely misunderstood something. Still, then it's up to you to make the most of the situation. Personally, I'd try hard to come up with a solution, thinking out loud while explaining my reasoning. But it amounts to equating the indestructibility of the walls with the inability to get out of the room. I'd arrive at the conclusion that there is no way to get out. Then when given the "solution" I'd chuckle and go "oh, I get it. Hadn't thought of that. Is being sealed inside a box something I should be worried about here?" while trying to keep a light, humorous tone, since that's obviously where the conversation is supposed to be heading. You know, people skills. Charisma.
If you really feel he made his decision based on how you answered/didn't answer that question, misjudging your actual qualifications, then either the company isn't right for you anyway, in which case, what's the problem, or you need to explain/present yourself better, maybe directly to whoever the interviewer has to answer to.
Admin
Yes, I misread you too, sorry. I'm not a physicist myself but a mathematician, see, so I tend to idealize everything and thought you didn't understand the thing about uniformity of pressure. But we agree on the physics, good, and of course the properties of the tire mean that the larger the surface area the lesser the error. That makes intuitive sense. :)
I would still hold that "measure the contact area of tire to ground, measure the pressure (catchy), and multiply those" in itself is beautiful answer to "how would you weigh a 747?"
Admin
We're up to 783 comments now, so this is going to be difficult. I'm trying to reply coherently and briefly and fairly, but if I've mis-represented anyone or anything, then that's the nature of the thread. (Where is Donald Knuth when you need him?) In any case, I apologise.
The point is this. If I interview somebody, I am looking for:
And the last shall be first:
What, people with a sense of humour? I'd have to be insane to do something like this in an interview. It's easier to walk out. As you, or at least somebody else, might be able to guess from the phraseology, this is sarcasm.You lose.
As an interviewer (usually for my replacement, what with me being a contractor), I also understand the following point:
You win. I interviewed a particularly obnoxious young woman from an Ivy League school who spent the entire time dissing my design for a system that was actually in production and actually working. I hired her. A fine attitude, I thought, and she had the technical chops and would probably fit in well. I wasn't about to insult her, or any other candidate, by asking them to parse ancient Greek given a ten-minute course on the alphabet ... which is pretty much an equivalent to a contrived logic puzzle.And so to technical ability:
OK, let's assume this as a starting point. You obviously can't ask me whether I'm part Jewish. (This would be a question I would love to ask. It would add 10% to the chance of me hiring somebody at this point.) You can't, realistically, ask me whether I got fired at my previous job for gross incompetence and/or blatant contravention of Sarbannes-Oxley. In fact, there's very little information you can glean other than actually talking to me. You know, talking. Verbal communication. It's quite easy, really. And in fact, you'll find that most people who are "customer facing" -- one of your other points, AFAIR -- tend to face customers via conversation and not through pointless logical puzzles. And why logical puzzles? Why not "I see you have French on your resume. I've always wondered. How do you ask for an upside-down rhubarb tart in French?"I submit that this is an equally reasonable way of qualifying a candidate, based upon your requirements.
This is impressive. (It really is; I'm not being sarcastic.) Actually thinking, and looking something up, puts you easily in the top 5% of this thread. (Mind you, that's still 38-odd people, so there are still some duds out there.) I don't have the faintest idea whether gwenhywfaer is male, female, or indeed human. The name is an avatar. I'm assuming female, although given the linguistic clues ("arsehole," not "ass," and there's a huge difference), I'm fairly sure that (s)he is from the UK. I've also noted posts on several previous threads, and I find the idea that (s)he is a troll, droll.Basically, I think you should both make nice. You both have a reasonable point of view. You've both been drawn into blog-yelling at each other, and I can't remember who started it, and I don't care. I am the Kindergarten teacher. Stop Now.
Damn right, G, it's not the same. Not that anybody cares too much about critical thinking on an Internet thread. Gotta say though, the only times I've been asked rank logic questions like this, I've had the same experience. It's usually designed to dust-bin you, not to hire you. The one time I took it seriously and answered the first three with "I know this -- I read it in Mount Fuji," they looked very disappointed until they hit on the riddle that I'd read but had forgotten. Boy, did they enjoy canning me for that one.I still prefer my way of moving Mount Fuji. And failing that, I like the meshing of the eight-coin problem with the fruit-dispensing problem -- echt Web 2.0, and definitely worth a shot in an interview; and the genius of it is, you can ask it as either the interviewer or the inverviewee. (Answer to (a) - three, but it's not immediately obvious. It requires knowledge of both problem spaces and a spot of induction. Still genius though. I may not walk out on the next cretin interview -- I think I'll just ask them this. I'd love to see the answer to (b), though).
You lose again, sweetie.You really are a dipstick, aren't you?
Admin
Admin
Pretty good analysis, and similar to what I was thinking when I posted. But since then, several people have posted both binary-ish and ternary-ish solutions that have worst cases of 3 weighings.
The binary-ish solution is to divide the coins into four groups, weighing two of groups against each other, leaving the other two groups off the scale. This tells you which half of the coins contains the bad coin, so you can discard that half and repeat the process on the remaining four coins. After that, you'll know the bad coin is one of two coins, so you can figure out which one it is by picking one of the two and weighing it against a known-good coin.
The ternary-ish solution is more complicated because it doesn't just require dividing and conquering -- you may have to do some shuffling around after the first weighing. There's a solution that is probably correct on this page (16), and a more thorough analysis on earlier pages. But it also works out to a best- and worst-case of three weighings.
I find it amusing that people are so quick to offer the solution to a similar problem (the one where you know the coin is heavier). I guess there's a slight disadvantage to knowing the answers to some of these problems, in that it affects your assumptions going in.
Admin
Ok, back to the hat problem for just a second. I know we have covered over and over again that the 75% solution works. I'm not going there. Another thing that was asked and I don't believe answered is whether we know this is the best we can do. Some people pointed out how you would program it so I did. Here is my code:
public class Hats { public static final int RED = 0; public static final int BLUE = 1; public static final int PASS = 2;
public static void main(String[] args) { // what should alice say when she sees RR for (int i=0; i<3; i++) { // what should alice say when she sees RB for (int j=0; j<3; j++) { //what should alice say when she sees BB for (int k=0; k<3; k++) { //what should bob say when he sees RR for (int ii=0; ii<3; ii++) { //what should bob say when he sees RB for (int jj=0; jj<3; jj++) { //what should bob say when he sees BB for (int kk=0; kk<3; kk++) { //what should carol say when she sees RR for (int iii=0; iii<3; iii++) { //what should carol say when she sees RB for (int jjj=0; jjj<3; jjj++) { //what should carol say when she sees BB for (int kkk=0; kkk<3; kkk++) { double score = score(i,j,k,ii,jj,kk,iii,jjj,kkk); if (score > 0.5) { System.out.println(i + " " + j + " " + k + " " + ii + " " + jj + " " + kk + " " + iii + " " + jjj + " " + kkk); System.out.println(score); } } } } } } } } } }
}
public static double score(int arr, int arb, int abb, int brr, int brb, int bbb, int crr, int crb, int cbb) { int wins = 0; if (win(RED, RED, RED, arr, arb, abb, brr, brb, bbb, crr, crb, cbb)) { wins++; } if (win(RED, RED, BLUE, arr, arb, abb, brr, brb, bbb, crr, crb, cbb)) { wins++; } if (win(RED, BLUE, RED, arr, arb, abb, brr, brb, bbb, crr, crb, cbb)) { wins++; } if (win(RED, BLUE, BLUE, arr, arb, abb, brr, brb, bbb, crr, crb, cbb)) { wins++; } if (win(BLUE, RED, RED, arr, arb, abb, brr, brb, bbb, crr, crb, cbb)) { wins++; } if (win(BLUE, RED, BLUE, arr, arb, abb, brr, brb, bbb, crr, crb, cbb)) { wins++; } if (win(BLUE, BLUE, RED, arr, arb, abb, brr, brb, bbb, crr, crb, cbb)) { wins++; } if (win(BLUE, BLUE, BLUE, arr, arb, abb, brr, brb, bbb, crr, crb, cbb)) { wins++; } return wins/8.0d; }
public static boolean win(int acolor, int bcolor, int ccolor, int arr, int arb, int abb, int brr, int brb, int bbb, int crr, int crb, int cbb) { int correct = 0; int aguess = guess (bcolor, ccolor, arr, arb, abb); int bguess = guess (acolor, ccolor, brr, brb, bbb); int cguess = guess (bcolor, acolor, crr, crb, cbb); if (aguess == acolor) { correct++; } else if (aguess != PASS) { return false; } if (bguess == bcolor) { correct++; } else if (bguess != PASS) { return false; } if (cguess == ccolor) { correct++; } else if (cguess != PASS) { return false; } return correct > 0; }
public static int guess (int color1, int color2, int rr, int rb, int bb) { if (color1 == RED) { if (color2 == RED) { return rr; } return rb; } if (color2 == BLUE) { return bb; } return rb; } }
Sorry for any wierd indenting, and I'm sure it could be written better but I just threw it together and made some things explicit so that I could keep my own thoughts straight. The result was
0 2 0 1 2 0 1 2 0 0.625 1 2 0 0 2 0 1 2 0 0.625 1 2 0 1 2 0 0 2 0 0.625 1 2 0 1 2 0 1 2 0 0.75 1 2 0 1 2 0 1 2 1 0.625 1 2 0 1 2 0 1 2 2 0.625 1 2 0 1 2 0 2 2 0 0.625 1 2 0 1 2 1 1 2 0 0.625 1 2 0 1 2 2 1 2 0 0.625 1 2 0 2 2 0 1 2 0 0.625 1 2 1 1 2 0 1 2 0 0.625 1 2 2 1 2 0 1 2 0 0.625 2 2 0 1 2 0 1 2 0 0.625
With the appropriate line being
1 2 0 1 2 0 1 2 0 0.75
This is the solution of if you see two hats of the same color, guess the oposite. If not then pass. It had the highest win percentile.
To describe it briefly, I let alice, bob, and carol each have their own strategy. Each one would have a rule of what to do when they see two red hats, what to do when they see two blue hats, and what to do when they see one of each. For each one they could guess red, blue, or pass. The nested loops just create all possible strategies and test them.
Let me know if there is a bug in there somewhere.
Admin
I'm really saddened by this conversation. Up until page 10 it was relatively interesting, comparing hat experiments etc... then it degenerated into a flame war about who was TEH STUPID JERK in any gambling probability.
Here are my answers: Bike for the blind? I'm told a tandem works, otherwise I would never make one - too risky. Manhole covers - Easy to make, easy to transport, easy to make holes for. Boeing 747 - google it Chicken/fox/grain or husband/wife/children/guard/prisoner -- meh, just go with the flow and you'll solve it 80% of the time. Or shoot the fox. Ravine, flashlight, 1+2+5+10 minute people? 5+10 minute peoples cross, throw the flashlight back to the 1+2 people who then cross. Result: 12 minutes. Three hats: I won't even act that I have a personal idea, 50% is enough for me, but I know I can get 75% with the ideas presented here. I could go for 87,5% with the vertice solution but I wouldn't even try to explain that to the other people in the test. Why is the sky blue? Light difracts in the atmosphere. Why does it look blue? How should I know? It's not even proven that 'blue' looks the same to all people. How much does the world weigh? In what gravity well? Itself? Just try to calibrate that. 8 coins? Meh, surprisingly "12 coins with 3 weighings" is easier. Easiest case, just weigh 2 at a time and you won't spend any time thinking about it. I mean seriously, when talking about sort/bitwise operations, we're talking mostly about human-interface use times. Optimization secondary. Coin flipping? I've worked with professional magicians, and trust me, nothing is more devious than a coin flip. Except maybe a dice toss or a card flip. Except a question designed to find out how you think. Tooth fairy trips? Exactly the same amount of trips that santa or one of his elves does.
Seriously, I've always enjoyed a brain teaser every now and then, but this thread takes it to ridiculousness. Those of you who WBM about teasers used in interviews should remember one thing: IT'S JUST ONE PART OF THE INTERVIEW. If you screwed up the teaser, it's your own fault, not the interviewer's. If you don't stand out, that's again your problem. Most people I know who do the actual interviews are a canny bunch. If you get to the point they want to test a teaser on you, they're probably really looking for reasons to look past some flaw of yours or your negligent CV. Enjoy the teaser, since you can't answer wrong it's going to be the easiest part of the interview.
Why? If you don't have what the interviewer's looking for, you're going to miss the job anyway. So might as well be yourself and either tell him to lay off on the stupid teasers or enjoy yourself solving a problem with someone who knows his shit. God only knows, it's probably a huge step ahead of what you had in school.
Admin
Er, you may still be having an argument, but not with me. I stopped arguing here; when I realised that you hadn't, I lost patience with you here. Which in retrospect was probably a misjudgement.
Admin
I think it's relatively clear that "Jack," an apt moniker if ever I've seen one, is not quite clear on what a troll might be. I am not one, normally, to rely on Wikipedia for a definition; but this might suffice for Jack and his like: http://en.wikipedia.org/wiki/Wikipedia:Troll
There's also a mild cognitive dysfunction here. The predicate, that Jack "refuse[s] to be trolled," is either clearly absurd or a case of monomania. Were you to be a troll (which you're not; cf my last post), you would not be trolling Jack, but Worse Than Failure. Were he to refuse to be trolled, the solution is obvious: stop reading Worse Than Failure. Or indeed anything at all on the entirety of the World Wide Web.
I suppose an equally valid solution would be to climb up a school tower somewhere in Colorado with a machine-gun and/or a sniper rifle, but somehow I get the feeling that "Jack" is a large, pallid, hairy thing that lives under a bridge and lacks everyday contact with humans.
Admin
How about this
http://www.urbandictionary.com/define.php?term=troll
Seems the definition isn't as clear as you think. I'm sure Jack was using the "I refuse to be trolled" thing in the yhbt sense (http://www.urbandictionary.com/define.php?term=yhbt). If yhbt (you have been trolled), means to be suckered into a flame war, then refusing to be trolled would mean refusing to be suckered in, right?
BTW, what does this have to do with riddles in job interviews again?
Admin
My apologies.
Particularly since I can't be bothered to look up your alternative Internet definition of trolling. I realise it's largely an Internet term, and that therefore it is reasonable to delve around in Internet muck to figure out what precise meaning it might have as of 01:20 on the 19th May 2007 in Sweden, but somehow I can't bring myself to do that. Not unlike trying to solve artifical problems for the benefit of stupid pointy-haired interviewers, should that answer your question about riddles.
Call me dim-witted. Call me a slut. Call me Ishmael, should you wish: but actually posting a comment to the effect that "I refuse to be trolled..." given your (or the world-renowned www.urbandictionary.com, soon to be seen in a classroom near you) definition of "trolling" is ...
... ummmm ...
to troll yourself? I mean, if you wanted to avoid that god-awful concatenation of consonants, wouldn't you just not post?
Which is to miss the point. Not uncommon on this thread. All I was trying to say is that, IMHO, it is utterly absurd to suggest that the specific comment by gwenhwyfaer to which Jack was apparently referring was in any way obvious to a normal person as a troll. Sodding hell, I've had to read through fifteen or so pages to work out what the hell was going on. I wouldn't call gwenhwyfaer a troll, nor would I call any of the other people on this weird sub-thread a troll, and I frankly don't see the point of it. If you're offended, stop reading. Don't throw pointless insults, backed up with no evidence or argument, around.
Oh, and BTW. I am sick and tired of nominalists. I don't care what some idiot internet site thinks "troll" might mean, or indeed anything else. Take a poll of anyone on the internet, and you'll find that they regard the word as deeply offensive, and essentially a gerund rather than what appears to be a future perfect participle. My point was merely that gwenhwyfaer was, apparently, being accused of being a "troll" in the generally accepted sense of the word.
You may well disagree with this. And you may well be correct. I just don't remember "Jack" having been one of the first 750 posts -- and had he been so, this might tentatively support your theory of what he meant by trolling -- and therefore I stand by my original supposition that the guy was just being a nitwit.
Admin
Lewis Carroll wrote about this problem, only he called it the Lion, Lamb, and Lettuce problem. People do eat lamb, so now you have a motivation to get them all there intact.
Admin
Admin
Admin
Believe it or not...I was actually asked the 747 question....Job interview with Phillips Consumer Electronics, back in '96....while stalling to come up with a better answer I said "call Boeing"....the interviewer was stunned...noone had answered it that way before!