|Keep It Simple, Stupid|
Golf: Indici to all sectors of an xD spaceby jeroenes (Priest)
|on Oct 10, 2001 at 21:28 UTC||Need Help??|
I hope you like this one, as it is my ever-first attempt at a golf.
The challenge is to create a 2D-array that contains indici of all sectors in a multi-dimensional space. The indici are given as unitary vectors in that space.
Eg., in a flat plane (2D), there are four sectors, so we have 4 vectors:
that point each to a quadrant:
This of course comes handy when you want mirror some image or curve.
The constraints are: (i) strict compliant, (ii) return a reference to an 2D-array and (iii) only the code inside the sub is counted (believe the last is standard, isn't it?). Furthermore: the vectors must be unitary vectors in the inner dimension. The function takes as input a scalar holding the number of dimensions disired.
Here is a starting point at 79 chars: