19
A Chinese checkerboard looks like this (based on this question, but this time it has a fixed size):
G
. G
G G G
G G . G
B B B B . . Y G . Y . Y Y
B B B . . G . . . Y Y Y
B . B . . . . . Y . Y
B . . . . . . . . Y
. . . . . . . . .
. P . . . . . O O .
P P . . . . . . . O O
P P P . . . R . . O O .
P P P P . . R . . O O O O
R . R R
R R R
R .
R
Each non-space character in this example can be replaced by any non-space printable ASCII character in the input, while spaces are never changed. Note that it isn't guaranteed to be a valid arrangement in Chinese checker (such as it may not have exactly 7 different kind of characters).
Your task is to rotate it by a multiple of 60 degrees.
This is the above example rotated by 60 degrees clockwise:
B
B B
B B B
B . B B
P P P . . . B . . G G . G
P P P P . . . . . G G G
P P . . . . . G Y . G
P . . . . . . . G G
. . . . . . . . .
R . . . . . . . . Y
R . R R . . . . Y Y .
R R R . . . O . . . Y Y
R . R R . . . O . Y Y Y Y
O O O .
O O O
O .
O
The input is a non-negative integer and a Chinese checkerboard. Your program (or function) should rotate it by the integer * 60 degrees. You decide whether to rotate clockwise or counterclockwise, as long as it is consistent. Both the input and output shouldn't have extra leading or trailing spaces.
This is code-golf. Shortest code wins.
_,,Sf*\.+W%ze_
. – jimmy23013 – 2015-06-21T15:27:32.447@jimmy23013: Much better than my sorting approach. Thanks! – Dennis – 2015-06-21T15:42:54.267
liq{_N/eeSf.*W%:szsS-\{_' >{;(}&\}/;]}@*
, but I was thinking of rotating by 60 degrees, not 45 degrees when I was writing this challenge... – jimmy23013 – 2015-06-21T16:00:09.547@jimmy23013: Wow, thanks! I was try a different approach, but
qN/(i{_eeSf.*W%:szSf-{},.{' f+sW<\,' e[}}*N*
is even longer than what I had before... – Dennis – 2015-06-21T17:36:59.930