The CodeMaiden’s Demesne

Lorem ipsum dolor sit amet

An Exercise in Logic?

Posted by thecodemaiden on April 29, 2008

So, I’ve been thinking (a most rare and frightful occurrence) and today my thoughts fell upon logic puzzles, particularly those that involve two partners in crime. You know, the ones where one always tells the truth and one always lies, and you have only one chance to squeeze the information you need out of them with a Yes/No question. Actually, any question with only two possible answers will suffice.

I’ll start off with the basic solution: just ask them, “What would your cohort say if I asked him if the mall is to the right or to the left?” What this does is force the truthful one to think something like, “Since the mall is to the left, my cohort would say ‘Right’,” and blurt out “Right!”. The untruthful one would think, “My goody two-shoes cohort would say ‘Left’,” and blurt out “Right!”. You then conclude that the opposite of what they say is where you want to go. If you want to think of it in terms of functions and the composition thereof (and I did), what it boils down to is them both applying the “lie” function. No need to think too hard about it; just know that if you encounter two such people, do the opposite of what they tell you.

Now, however, is the part where you consider that life is so much more confusing than puzzles. Like, what if they both say, “I don’t know”? This means that the liar has decided his partner does know and, you know, lies. It also means that the non-liar really does not know, and since you only get one question, you are screwed.

Even if they both knew what you needed to find out, and you played by the rules and asked the “right” question, consider the motivation for the liar to lie. If his intention is just to test your logical skills, then he may give the exact opposite of what the other would say. I find it hard to believe, though, that someone would spend their entire life garnering a reputation for lying all the time just because he and his associate feel like posing logic puzzles to everyone. If for some strange reason he just cannot tell the truth, he could just as well say “Pickle!”, or “Up!”. If his intention is to deceive – and I think that’s the point of lying – then he could really mess with you. Imagine this:

You: If I asked your friend, would she say the mall was to the right or to the left?
Liar: No.
Honest one: Neither.

or maybe even this (yes, the mall is still on the left):

You: If I asked your friend, would she say the mall was to the right?
Liar: I dunno.
Honest one: Nope.

See the problem here? Sure, if you heard them respond, you’d know which one was just messing with you, but guess what? You used up your one question. At least if one had said “Pickle!” you’d just do what the other one said. Also, the answers above bank on the honest one knowing for sure whether the liar will decide to mess with you or not. If the liar was really in it to trip people up, she’d just mix it up so the only honest answer the honest one could give is “Depends on her mood”.

“Argh!” you yell, “you think too much!” Well it gets even better: how do you know one always lies and one always tells the truth, anyway? Let’s kick it into overdrive with this question: what if one of them walks up to you and says: “We have the information you want, but one of us always tells the truth and one of us always lies, and you only get one question?” It’s all fine and dandy if the truthful one says it, but what if it was a lie?

Stay tuned for the exciting conclusion…

Posted in Musing and Confusing | Tagged: , , , | Leave a Comment »

I Am the Very Model of an Engineer Electrical.

Posted by thecodemaiden on April 28, 2008

Well, perhaps I’m not. Most people don’t think of a West Indian woman with dreadlocks when they think of electrical engineers, but that’s ok. They do think of Carnegie Mellon students (at least if you’ve heard of Carnegie Mellon), so that works.

In honour of ECE (Electrical and Computer Engineering) day at CMU, I wrote the following song, to the tune of “Modern Major General” from Pirates of Penzance. (Actually I wrote it on a whim, but I like that other story better.)

Enjoy.

I am the very model of an engineer electrical
I shudder at imperial and work in units metrical
I conquer circuits with my use of methods analytical
And transfer functions with manipulation algebraical

I can solve equations second order and differential
I can relate electrostatic force to the potential
The steady state responses of my circuits I can estimate
With clever use of limits, nasty fractions I eliminate.

I revel in the mastery of complex vector calculus
The things I can accomplish with MATLAB seem so miraculous
And this is but a sample of my talents mathematical
For I’m the very model of an engineer electrical!

When making Bode plots I always keep my axes semilog
And I can synthesise ‘most any circuit using Verilog
When my oscilloscope shows my responses are off-kilter
I skilfully adjust the qual’ty factor of my filter

I know the properties of amplifiers operational
The circuits I design are full of logic combinational
My soldering iron and protoboard are indispensable to me
And never will I tire of ogling expensive gadgetry

For any project I can choose the fittest circuit elements
And mix them all in series or in parallel as relevant
When given half a chance, you see, I will wax pedagogical
For I’m the very model of an engineer electrical!

And matters computational are certainly within my ken
I compose code more beautif’ly than prose that flows from any pen
I’m versed in data structures, systems, graph theory and all that stuff
No IDE’s for me – you see, vi is far more than enough

Now, extensive debugging is a task from which I never shirk
I keep my programs modular and simple so they always work
My knowledge of computer architecture keeps them optimised
And mutexes ensure that my thread-safety’s never compromised

System control and feedback is a field I find enjoyable
My fervour for all things digital makes me most employable
Forget those engineers who are mechanical or chemical
My future seems much cooler as an engineer electrical!

-theCodeMaiden

Posted in Flights of Literary Fancy | Tagged: , , , , | Leave a Comment »