Two interview questions I enjoyed
Apr. 25th, 2013 05:07 pm![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
There's a longer, friends-locked post before this one talking about the interviews I had this week, but it occurs to me that the more general public might get a kick out of the two interview questions that most amused me:
My new favourite interview question:
Given this code...
What do you need to insert in place of X in order to get this code to print "helloworld" ?
And the second one:
If you're in a room with a light bulb that's on, how can you make it be off?
(This was asked shortly after they told me they were asking to see if I had the security mindset, which is a pretty huge clue as to the types of answers they were hoping to hear. I had a lot of fun with this.)
I am leaving my answers out of this post so that you can think about the possibilities yourselves, but of course feel free to discuss in the comments.
My new favourite interview question:
Given this code...
if ( X )
print("hello")
else
print("world")
What do you need to insert in place of X in order to get this code to print "helloworld" ?
And the second one:
If you're in a room with a light bulb that's on, how can you make it be off?
(This was asked shortly after they told me they were asking to see if I had the security mindset, which is a pretty huge clue as to the types of answers they were hoping to hear. I had a lot of fun with this.)
I am leaving my answers out of this post so that you can think about the possibilities yourselves, but of course feel free to discuss in the comments.
no subject
Date: April 26th, 2013 01:17 am (UTC)no subject
Date: April 28th, 2013 06:01 pm (UTC)no subject
Date: April 26th, 2013 05:50 am (UTC)no subject
Date: April 28th, 2013 06:01 pm (UTC)no subject
Date: April 26th, 2013 06:32 am (UTC)no subject
Date: April 26th, 2013 06:23 pm (UTC)Vibrate the bulb (to break the filament but not the glass), subject the bulb to extreme heat (with a cigarette lighter or brulee torch) or cold (find a fire extinguisher, maybe even a glass of ice water). With a CF bulb and cold and some care, it will be possible to turn the bulb back on by letting it get warm again.
Unscrew the bulb and put some coins in the socket. If this causes the power supply to protect itself by changing state (i.e. a fuse blows or similar thermal overload protection device trips), you can even get your coins back and the bulb will still be off. If you have a handful of metal filings or mercury handy those work too. Water and table salt can do the job if you get the mixture right and you can work out a delivery system that doesn't kill you first. If there are fuses, turn on every switch and put a hairpin or a paperclip in every wall socket you can find until you find one on the same circuit as the bulb. Go to an adjacent room with more accessible bulb sockets and use this or the coin attack on those.
Think outside the room: attack the local power grid.
If the bulb is resting on an object, move the bulb to rest inside or suspend it underneath some other object (the bulb is on, you say? On what?). If there is no single obvious acceleration vector acting on the room and its contents (e.g. the room is in orbit), argue with the interviewer about the locally accepted definitions of words like "down" on which concepts like "on" and "off" may rely.
Dip the bulb in opaque reflective paint. Depending on the bulb technology, this either leaves the bulb still on but its light invisible, rendering the bulb functionally ineffective; or it causes the bulb to overheat and fail. This approach has some risks: the bulb might win, and shine through cracks or burns in the paint, or the bulb may put out enough heat that the paint itself starts radiating visible light.
Put your own light source in the room to raise the ambient light level in the room to 100 times greater than the brightest light level emitted at the surface of the first bulb. The light will be on, but to human eyes (or an image sensor with an equivalent contrast ratio) the first bulb will appear no brighter when it is on than it does when it is off.
Use an electric coil to induce a current inside the bulb high enough to make it fail (or if it's CF or LED, disrupt the electronics of its power supply). If the bulb is already wirelessly powered by induction, put a sheet of metal in the way, or move the bulb away from its power source, or generate your own induction current with equal magnitude and opposite phase. Detonate a nuclear warhead in the atmosphere above the room and use the EMP to disable the light bulb or its power supply. Trigger an unusually large solar flare and direct it toward the Earth, disrupting the global power grid.
If the bulb is one of those remotely programmable WiFi or ZigBee LED devices, send it the 'off' or '(r,g,b) = (0,0,0)' command.
If the room is in a submarine at sufficient depth, opening all the doors between the light bulb room and the outside should get the light being off, especially in salt water.
If the bulb uses a combustion-based power supply (e.g. it's a Coleman lantern and the "bulb" is really a thorium dioxide mantle), seal the room and remove all the oxygen (or pump in lots of carbon dioxide).
If the bulb contains its own power supply (e.g. batteries or a luminescent chemical reaction), you could just wait until that power supply runs out. If possible, increase the bulb's brightness to make this happen faster. If the bulb is based on LEDs or electroluminescence then this might take a while. If the bulb is based on a radiological power supply (e.g. radium and zinc sulfide painted on the inside of the bulb glass) this might take a very long while.
For radiologically powered light bulbs, use acid to dissolve the zinc sulfide (or similar chemistry for other materials) to make it stop fluorescing. Hydrofluoric acid will dissolve bulbs made of glass and probably destroy critical materials in all the other kinds of bulb. There might be a nuclear reaction you can use to stop radiological power sources (possibly emitting a large amount of light between the initial state and the "off" state), but I have no idea how to even Google for that.
no subject
Date: April 30th, 2013 04:11 am (UTC)