You are imprisoned in a stone tower. The cell you’re in is lit by a torch just outside the cell door within your reach. There is a guard stationed at the only entrance to the tower who is far out of earshot. You know that during the changing of the guard, the tower entrance will be unguarded for about 1 minute. The changing of the guard happens at a different time each day. The cell door can only be opened with the blast from a stick of dynamite, which will go unnoticed only in the 1 minute window of time during the changing of the guard.
Your friend, who has climbed up the side of the tower, is able to give you two things through the window. The first thing is a tip: the guard will change in exactly 50 minutes. The second thing is a bag with four items in it: a stick of dynamite and three fuses. One fuse takes exactly 5 minutes to burn from one end to the other; the other two each take exactly 1 hour to burn from one end to the other. While the time it takes to burn the entire fuse is very predictable, the fuses do not burn consistently throughout their length making it impossible to divide the fuse in parts and burn only the parts predictably.
You have no watch or any other means by which to measure the passage of time. You have no further contact with any other ally. How do you escape?
Friday, March 20, 2009
Monday, December 8, 2008
Arbitrary Precision
I think it'd be cool to implement arbitrary precision trigonometric functions using lazily evaluated Taylor series. (Is this how they're done?) Pretty bad performance, but at least you have a reliable algorithm.
I've also always wondered how TI calculators know that sin(pi) = 0. No floating-point calculation I've seen in a general-purpose programming language can figure it out.
I've also always wondered how TI calculators know that sin(pi) = 0. No floating-point calculation I've seen in a general-purpose programming language can figure it out.
Labels:
arbitrary precision,
Taylor series,
trigonometrics
Sunday, November 23, 2008
Stupid Type Erasure
I want to create a freaking generic array, dang it!
publicT[] makeArray(int size)
{
return new T[size]; // compiler error. why? because Java sucks
}
Labels:
angry,
generic array,
Java,
Java sucks,
programming,
Studip,
Type Erasure
Sunday, August 17, 2008
Yeah I know it's a stupid title.
And anyway, to be more true to the procedural paradigm it should be something like this:
Yeah it's VB.net. Yes I'm trying to say that I like programming.
Public Overrides Function ResultOf(ByVal a As Activities) as Moods
If a = Activities.Programming Then Return Moods.Happy Else Return Moods.Meh
End Function
Yeah it's VB.net. Yes I'm trying to say that I like programming.
Subscribe to:
Posts (Atom)
