6
Your program will receive an ascii shape consisting of only underscores _
, pipes |
, spaces and newlines
\n
, which, together, represent a horizontally-aligned, right-angled shape. Together with this shape, on a new line, you will also receive either a positive or a negative integer, whose absolute value will be either one of 45
, 135
, 225
or 315
— signifying the degree that the original image should rotate. For instance:
_
| |_
|___|
-45
Your program's job is to rotate this shape the provided amount of degrees. Following are the example outputs, for all possible degrees, given the above provided example shape:
for 45° or -315°:
/\ / / \ \ \/
for 135° or -225°:
/\ / \ \/\/
for 225° or -135°:
/\ \ \ / / \/
for 315° or -45°:
/\/\ \ / \/
Remember though: the original shape above is just an example. Your program should be able to handle any shape constructed with said characters (within reason, of course — let's say: with a maximum of 100 x 100 characters).
The output of your program should be the rotated image, constructed with forward slashes /
, backward slashes \
, spaces and newlines.
Shortest code, after one week, wins.
Note: although this challenge offers many similarities with these [1] [2] two challenges, I think this one offers just enough variation (because the original image is not supposed to be rotated at 90° angles) for it to generate interesting new results.
This question is ill-defined. How should we rotate this shape?
__
| |
|__|
(sp _ _ sp, | sp sp |, | _ _ |) This is a 1.5 by 2 box, judging by your example above. – Tobia – 2014-02-24T19:04:34.747