Intro
Let's play some mini-golf! The golf ball is represented by a .
and the hole by a O
.
You want to get a hole in one on every hole, but you are not good at putting. In fact, you refuse to attempt putting diagonally! Only up, down, and to either side.
You plan to cheat by placing extra bumpers \
and /
so you can put the ball in with one shot. The ball bounces off of the bumpers at right angles, as shown in this picture.
Remember to call your shot! Tell us what direction you're putting.
Holes
1: The first hole is easy, a straight shot! No bumpers needed to place here.
Input:
. O
Output:
right
. O
2: Another basic one, a short turn. The ball is hit off the bumper into the hole.
Input:
.
O
Output:
left
/ .
O
or
down
.
O /
3: Some holes have bumpers already!
Input:
. \O
Output:
right
. \O
\/
or
right
/ \
. /\O
4: Some holes are overly complex!
Input:
/ \ \ /
/ . \ \ /
/ /\/ /\ \ /
/ / / \ \/
/ / /\ \ / \ /
\ \ / \ \/ \/
\ / /
/\ \//\ \ /
/ \ / \ \ \/
\ /\ \ / \ \
\/ \ \/ \ O/ \
/ \/
Output: (one possible solution, more exists)
down
/ \ \ /
/ . \ \ /
/ /\/ /\ \ /
/ / / \ \/
/ / /\ \ / \ /
\ \ / \ \/ \/
/ \ / /
/\ \//\ \ /
\/ \ / \ \ \/
\ /\ \ / \ / \
\/ \ \/ \ O/ \
/ \ \/
\ /
Rules
- The input is the mini-golf hole on
STDIN
. - The output is the direction you hit the ball and the mini-golf hole with newly placed bumpers on
STDOUT
. - Existing bumpers cannot be moved.
- You can add any number of bumpers to solve a hole.
- Assume there are valid locations for the bumpers to be placed that will allow the course to be solved in one putt.
- The outputted hole may be bigger than the input.
- The input may be padded with trailing white space, but please specify in your answer if you do this.
- The output must look correct, but can have leading or trailing white space.
- Your program should work for any valid hole. Feel free to post your test cases too!
Scoring
This is code-golf. Your score is the number of characters in your program. Lowest score wins!
right
, #3 example 1 should bedown
, and #3 example 2 should beup
. Interesting challenge, though! \$\endgroup\$.
is the ball you're hitting andO
is the hole. I messed up on #2 example 1 but they should be good now. \$\endgroup\$