Getting hit in the knee with arrows seems to be the injury of choice right now. As such, I propose the following golf challenge.
You have an adventurer that looks like this:
O /|\ / | \ | | / \ / \
Given a text file that contains one bow (drawn as a
} symbol), a set of walls (drawn as
# symbols) and one adventurer, write the smallest code that calculates the angle and initial velocity at which you should fire an arrow in order to hit him in the knee.
Assume the following:
- Each character in the file is 0.5 x 0.5 meters.
- The arrow is fired from the center of the
}, i.e. an offset of
- Gravity is
- Arrow weighs
- Arrow is a point, i.e. collisions only occur when the arrow's coordinate enters one of the blocks.
- Maximum initial velocity is
- Angle may be between 0 (straight up) and 180 (straight down)
- Hitting any part of the adventurer's leg is considered a hit to the knee.
- A wall (
#character) takes up one entire 0.5m x 0.5m block.
- The arrow can travel over the "top" of the file, but there's nothing to stop the input from starting with a ceiling of
- You can't penetrate walls with arrows.
- Hitting any other part of the adventurer is not allowed!
- You should display an error if hitting him in the knee is impossible.
# } O # /|\ / | \ # | # | / \ / \
Feel free to ask questions if you need to :)