Roll a painted cubeRoll a painted cube code-golf
There is a 1x1x1 cube placed on a infinite grid of 1x1 squares. The cube is painted on every side, so it leaves a mark on the grid when it moves.
The sides of the cube are painted red, green, and blue, and on their opposite sides cyan, magenta, and yellow. The cube starts with blue on top and yellow at the bottom.
The cube can roll around the grid. Every step it rotates precisely 90 degrees around one edge that touches the ground. Then the side facing down will leave a mark in that spot.
Given the path of the cube, output the pattern it leaves on the grid.
Cube sides
- The side of the cube facing (1,0,0) initially has the color (1,0.5,0.5), red.
- The side of the cube facing (0,1,0) initially has the color (0.5,1,0.5), green.
- The side of the cube facing (0,0,1) initially has the color (0.5,0.5,1), blue.
- The side of the cube facing (-1,0,0) initially has the color (0,0.5,0.5), cyan
- The side of the cube facing (0,-1,0) initially has the color (0.5, 0, 0.5), pink.
- The side of the cube facing (0,0,-1) initially has the color (0.5, 0.5, 0), yellow.
Test Cases
Path: Pattern
EEE YMBG
ESE YM
RB
SEN YY
RM
NNNN Y
R
B
C
Y
IO
You may take the direction as a vector instead of compas coordinates. E=(1,0)
, W=(-1,0)
, N=(0,1)
, S=(0,-1)
. You may also choose to number them 1-3 or 0-2.
You may also output colors as a vector. R=(1,0,0)
, G=(0,1,0)
, B=(0,0,1)
, C=(0,1,1)
, M=(1,0,1)
, Y=(1,1,0)
. You may also choose to number them 1-6 or 0-5. Extra respect for those who output as a image though. Output coordinates can start anywhere, only the shape is important. The origin can be either the starting position of the cube but also for example the topleftmost space the cube visits.