24
1
Task
You're in charge of making a compass, of sorts.
Imagine your source code as the compass "needle" where running at different orientations produces distinct output.
Supported source code orientations are North, East, South, and West.
Example
Let's say you have source code:
ABCD
J K
WXYZ
We'll consider this the North orientation, rotating 90 degrees clockwise points us to the East:
W A
XJB
Y C
ZKD
rotating again points South:
ZYXW
K J
DCBA
and finally, the last rotation to the West:
DKZ
C Y
BJX
A W
When ran, each of the above code examples should output a single, distinct printable ASCII character of your choosing.
Notes
Your code shall take no input.
Empty spaces or new lines do not collapse/disappear when rotating.
Leading/trailing new lines are okay in output.
Answers may be whole programs or functions, thus output to STDOUT or return the function result.
Standard code-golf rules apply; shortest answer in bytes wins!
May we output more than 1 character? – Mr. Xcoder – 2017-08-04T16:52:55.627
Does a newline count as a printable character? (I don't think so, just asking for clarification.) – ETHproductions – 2017-08-04T16:55:40.373
1
Do we have to pad the code with spaces so it's a perfect rectangle (and count those spaces in our score)? For example, would code shaped like this be valid, given the first one is the submission?
– Business Cat – 2017-08-04T16:58:27.0432
Apart from the output spec, I think this is a duplicate
– Digital Trauma – 2017-08-04T16:58:56.977@Mr.Xcoder Output should be a single character. I originally wanted only
N
,E
,S
,W
, as output but thought perhaps that was too difficult or unnecessarily constraining. – CzarMatt – 2017-08-04T16:59:06.4571@BusinessCat You do not have to pad your code to make a rectangle - that example you provided would be valid. – CzarMatt – 2017-08-04T17:02:38.700
@ETHproductions New lines aren't printable ASCII to my knowledge. – CzarMatt – 2017-08-04T17:05:21.520
@CzarMatt What if our source is 0 or 1 byte(s) long? Is a program like Z acceptable? – Mr. Xcoder – 2017-08-04T17:08:39.320
4@Mr.Xcoder Um, how could 4 identical programs print 4 different ASCII chars? – ETHproductions – 2017-08-04T17:09:19.810
@DigitalTrauma Darn, and here I was searching for examples with "compass" in the q/a. :) Also, I was hoping putting this in the sandbox would surface any potential dupes. – CzarMatt – 2017-08-04T17:11:15.100
@DigitalTrauma The comment rules make a big difference in the two. – Post Rock Garf Hunter – 2017-08-04T17:58:58.093
What about trailing whitespace in output, is that ok? Specifically I'm wondering about a single trailing space. – algmyr – 2017-08-04T22:22:17.480
@CzarMatt Would the score of your example be 13 or 14 bytes if the space on South can be omitted? (i.e. do we count the smallest or the largest rotation?) – Martin Ender – 2017-08-21T13:51:23.783