the trick is to use points
{s} produces: {{0,0},{1,0}}
{r,s} produces: {{0,0},{0,1}}
an array is good but use a dynamic points array.
Code:
POINT points[] = {
{0,0}, // start
{2,0}, // s,s
// r
{2,2}, // s,s
// r
{0,2}, // s,s
// r
{0,0}, // s,s
}
The main focus is on the 'r' which makes it turn.
So first find all double r's and substract s's from it, but this all depends on the whole string of commands.
Quote:
1) You are given the command string {s,s,r,r,s,s}.
The minimum command is {s,s}
|
what if the command is {s,s,r,r,s,s,s,s}?
There's no way you can shorten it because it results in the points.
{0,0},{2,0},{-2,0}