[Question]
  [
The English language and most programming languages are written and read from left-to-right, top-to-bottom, but that [needn't be the case](http://en.wikipedia.org/wiki/Writing_system#Directionality).
In fact for the block of text
```
ABC
DEF
```
I can think of eight related ways it might be read:
1. Left-to-right, top-to-bottom (LTR-TTB): `ABCDEF`
2. Top-to-bottom, left-to-right (TTB-LTR): `ADBECF`
3. Left-to-right, bottom-to-top (LTR-BTT): `DEFABC`
4. Bottom-to-top, left-to-right (BTT-LTR): `DAEBFC`
5. Right-to-left, top-to-bottom (RTL-TTB): `CBAFED`
6. Top-to-bottom, right-to-left (TTB-RTL): `CFBEAD`
7. Right-to-left, bottom-to-top (RTL-BTT): `FEDCBA`
8. Bottom-to-top, right-to-left (BTT-RTL): `FCEBDA`
# Challenge
Write a rectangular block of text that can be read in each of the eight ways above as eight **single line** programs in your language of choice. Each of these programs should output a different integer from one to eight.
It doesn't matter which reading direction outputs which number, they do not have to match the numbers above. For example, if your text block were still
```
ABC
DEF
```
then the program `ABCDEF` might output `5` and `FEDCBA` might output `2`, and the other six programs would output `1`, `3`, `4`, `6`, `7`, and `8` in some order.
**The text block may contain any characters except [line terminators](http://en.wikipedia.org/wiki/Newline#Unicode).**
Output should go to stdout or a similar alternative if your language doesn't have a proper stdout. There is no input. You may assume the programs are run in a REPL environment.
[Pietu1998](https://codegolf.stackexchange.com/users/30164/pietu1998) charitably wrote a [JSFiddle](http://jsfiddle.net/7s35c6yn/4/) that gives the 8 different single line programs when given a block of text. I've made it into a stack snippet:
```
<script>function f(n){n=n.split("\n");var e=n.map(function(n){return n.length}).sort()[n.length-1];n=n.map(function(n){return(n+Array(e+1).join(" ")).substring(0,e)});var t=n[0].split("").map(function(e,t){return n.map(function(n){return n[t]}).join("")});n=[n.join(""),n.reverse().join(""),t.join(""),t.reverse().join("")],n=n.concat(n.map(function(n){return n.split("").reverse().join("")})),document.getElementById("a").innerHTML=n.map(function(n,e){return document.getElementById("b").checked?n+"   "+"LLTTRRBB"[e]+"T"+"RRBBLLTT"[e]+"-"+"TBLRBTRL"[e]+"T"+"BTRLTBLR"[e]:n}).join("\n")}</script><textarea onkeyup="f(this.value)" id="c" placeholder="Code"></textarea><br/><input type="checkbox" id="b" onchange="f(document.getElementById('c').value)" checked/>&nbsp;<label for="b">Show directions</label><br/><pre id="a"></pre>
```
You can still find [Martin's](https://codegolf.stackexchange.com/users/8478/martin-b%C3%BCttner) CJam version [here](http://cjam.aditsu.net/#code=qN%2F%3AL%0ALz%0ALW%25z%0ALW%25%0ALW%25Wf%25%0ALW%25Wf%25z%0ALWf%25z%0ALWf%25%0A%5D%0A%7BM%2AN%2Bo%7D%2F).
# Scoring
Your score is the area of your block of text (the width times the height). The submission with the lowest score wins. (Essentially the smallest code wins, hence the [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") tag.) Tiebreaker goes to the earlier posted submission.
The example is 2 by 3 so its score is 6. A score less than 4 (2 by 2) is impossible because then some of the 8 programs would be identical and couldn't output two different values.
  
[Answer]
# J, 3 \* 3 = 9
```
1[2
+2+
2+2
```
Executing all directions:
```
       ". '1[2+2+2+2','2+2+2+1[2','1+2[2+2+2','2+2[2+1+2','2+2+2+2[1','2[1+2+2+2','2+2+2[2+1',:'2+1+2[2+2'
1 7 3 4 8 2 6 5
```
Explanation:
* In J execution goes from right to left and there is no operator precedence.
* The `[` (`left`) takes the left side of its two operand so it essentially cancels the whole right side of our expression e.g. `1+2[2+2+2` becomes `1+2[6` and then `1+2`.
* The left expressions are additions with a total of 1, 2, 3 and 4 operands. There are two of each `n`-operand expressions one with the number `1` and one with only `2`s. The additions with `1` generate the odd numbers and the others generate the even ones.
[Answer]
# [Befunge-98](http://esolangs.org/wiki/Befunge), ~~5x5 = 25~~ 5x3 = 15
```
1+4+2
$.@.$
3+4+4
```
I wrote a little script that found the correct numbers for me. It took a while, but hey, I just beat GolfScript! :D
The scripts I used are [here](http://jsfiddle.net/k49twwz2/5/) and [here](http://jsfiddle.net/631z2d06/1/), but I don't suggest looking at them since the code style is extremely carcinogenic.
## Subprograms
```
1+4+2$.@.$3+4+4   LTR-TTB   5
3+4+4$.@.$1+4+2   LTR-BTT   7
1$3+.+4@4+.+2$4   TTB-LTR   3
2$4+.+4@4+.+1$3   TTB-RTL   4
4+4+3$.@.$2+4+1   RTL-BTT   8
2+4+1$.@.$4+4+3   RTL-TTB   6
4$2+.+4@4+.+3$1   BTT-RTL   2
3$1+.+4@4+.+4$2   BTT-LTR   1
```
## Old version
```
 1.6
3 @ 4
.@ @.
8 @ 7
 2.5
```
### Subprograms
Output the numbers 1-8 respectively.
```
 1.6 3 @ 4.@ @.8 @ 7 2.5    LTR-TTB
 2.5 8 @ 7.@ @.3 @ 4 1.6    LTR-BTT
 3.8 1 @ 2.@ @.6 @ 5 4.7    TTB-LTR
 4.7 6 @ 5.@ @.1 @ 2 3.8    TTB-RTL
 5.2 7 @ 8.@ @.4 @ 3 6.1    RTL-BTT
 6.1 4 @ 3.@ @.7 @ 8 5.2    RTL-TTB
 7.4 5 @ 6.@ @.2 @ 1 8.3    BTT-RTL
 8.3 2 @ 1.@ @.5 @ 6 7.4    BTT-LTR
```
[Answer]
# [Brainfuck$](http://esolangs.org/wiki/Brainfuck$), 4x3 = 12
Brainfuck$ is very similar to [Brainfuck](http://esolangs.org/wiki/Brainfuck), but has some more commands, including a command to output the current cell value as numeric output, which was very useful for this challenge.
```
++:+
  ++
++++
```
One-line commands:
```
++:+  ++++++   LTR-TTB, outputs 2
++++  ++++:+   LTR-BTT, outputs 8
+ ++ +:+++++   TTB-LTR, outputs 4
+++:+++ ++ +   TTB-RTL, outputs 3
++++++  +:++   RTL-BTT, outputs 7
+:++++  ++++   RTL-TTB, outputs 1
+++++:+ ++ +   BTT-RTL, outputs 5
+ ++ +++:+++   BTT-LTR, outputs 6
```
[Answer]
# TECO, 3\*5 = 15
```
 +4 5
+2=4 
 +1 \
```
`=` prints the value of the last numerical expression. `\` is used to read or write numbers from strings, but I use it only as a discard here.
* `+4 5+2=4 +1 \` 7
* `+ +2+4=1 4 5 \` 6
* `+ +2+1=4 4 \ 5` 3
* `+1 \+2=4 +4 5` 2
* `\ 1+ 4=2+5 4+`  5
* `\ 5 4 1=4+2+ +`  1
* `5 \ 4 4=1+2+ +`  4
* `5 4+ 4=2+\ 1+`  8
[Answer]
# piet - 12x12 = 144
![enter image description here](https://i.stack.imgur.com/hNrtG.png)
Since a one line program can never terminate, assume it terminates after first output.
8 subprograms in a single image:
![enter image description here](https://i.stack.imgur.com/t0xuN.png)
[Answer]
# GolfScript, 4x4 = 16
```
1})7
)  }
}  )
3)}5
```
Makes use of the good old "super comment": an unmatched `}` ignores the rest of the code (in fact, in this case a normal comment `#` would have worked just as well, since all the code is run as a single line). So from each corner there's either only a single number, or (in the other direction) that number incremented by 1, because execution terminates and the stack contents are printed. The 8 programs are
```
1})7)  }}  )3)}5  # LTR-TTB
1)}3}  ))  }7})5  # TTB-LTR
3})1)  }}  )5)}7  # BTT-LTR
3)}5}  ))  }1})7  # LTR-BTT
5})3)  }}  )7)}1  # RTL-BTT
5)}7}  ))  }3})1  # BTT-RTL
7})5)  }}  )1)}3  # TTB-RTL
7)}1}  ))  }5})3  # RTL-BTT
```
[Answer]
# Haskell, 26x26 = 676
Uses comments (`--`) to hide the backwards and sideways bits. This makes it terribly long
```
main=print 1--2 tnirp=niam
a                        a
i                        i
n                        n
=                        =
p                        p
r                        r
i                        i
n                        n
t                        t
3                        4
-                        -
-                        -
5                        6
t                        t
n                        n
i                        i
r                        r
p                        p
=                        =
n                        n
i                        i
a                        a
main=print 7--8 tnirp=niam
```
[Answer]
# [Prelude](http://esolangs.org/wiki/Prelude), 5x3 = 15
```
12 34
  !  
56 78
```
This assumes the [Python interpreter](http://web.archive.org/web/20060504072747/http://z3.ca/~lament/prelude.py), which prints values as numbers instead of character codes.
This doesn't beat Befunge$, but it does beat my GolfScript submission, and I like its simplicity. Note also that it uses only 9 non-space characters, ~~which is less than any other submission so far~~ (J strikes again :)). In Prelude, each digit is pushed onto the stack individually, and depending on the path, there's a different digit right before the `!`, which just prints the top stack element. The 8 programs are:
```
12 34  !  56 78   LTR-TTB   4
56 78  !  12 34   LTR-BTT   8
1 52 6 ! 3 74 8   TTB-LTR   6
4 83 7 ! 2 61 5   TTB-RTL   7
87 65  !  43 21   RTL-BTT   5
43 21  !  87 65   RTL-TTB   1
8 47 3 ! 6 25 1   BTT-RTL   3
5 16 2 ! 7 38 4   BTT-LTR   2
```
Alternatively, there's also
```
 1 3 
1+!+1
 5 7 
```
Which pushes the odd numbers on the vertical paths, and increments them by `1` on the horizontal paths:
```
 1 3 1+!+1 5 7    LTR-TTB   4
 5 7 1+!+1 1 3    LTR-BTT   8
 1 1+5 ! 3+7 1    TTB-LTR   5
 1 3+7 ! 1+5 1    TTB-RTL   7
 7 5 1+!+1 3 1    RTL-BTT   6
 3 1 1+!+1 7 5    RTL-TTB   2
 1 7+3 ! 5+1 1    BTT-RTL   3
 1 5+1 ! 7+3 1    BTT-LTR   1
```
[Answer]
# CJam - 7×7
Not impressive, but there was no CJam answer and I like the way it looks :)
```
 8;];1 
7     2
;  0  ;
] 0 0 ]
;  0  ;
6     3
 5;];4 
```
It mainly uses the fact that `];` clears the stack.
[Try it online](http://cjam.aditsu.net/#code=qN%2F%3AL%0ALz%0ALW%25z%0ALW%25%0ALW%25Wf%25%0ALW%25Wf%25z%0ALWf%25z%0ALWf%25%0A%5D%0A%7BM*_p~N%5Do%7D%2F&input=%208%3B%5D%3B1%20%0A7%20%20%20%20%202%0A%3B%20%200%20%20%3B%0A%5D%200%200%20%5D%0A%3B%20%200%20%20%3B%0A6%20%20%20%20%203%0A%205%3B%5D%3B4%20)
[Answer]
# R, 9x9
No white space, no comments.
```
75%%99299
99%%99699
%%299%%41
%%699%%06
995999997
11%%999%%
99%%799%%
39719%%99
59519%%16
```
I guess this could be expanded to whatever size you want. I thought the modulo operator was most the most flexible of available operators, since it prevents values from being too large regardless of data size, and there's no effect from having really large numbers in between.
```
75%%9929999%%99699%%299%%41%%699%%0699599999711%%999%%99%%799%%39719%%9959519%%16   LTR-TTB  2
59519%%1639719%%9999%%799%%11%%999%%995999997%%699%%06%%299%%4199%%9969975%%99299   LTR-BTT  3
79%%9193559%%91999%%265%%75%%999%%1199999979999%%999%%26%%999%%99409%%9199167%%96   TTB-LTR  4
99167%%9699409%%9126%%999%%99%%999%%999999799%%999%%11%%265%%7559%%9199979%%91935   TTB-RTL  1
61%%9159599%%91793%%997%%99%%999%%1179999959960%%996%%14%%992%%99699%%9999299%%57   RTL-BTT  5
99299%%5799699%%9914%%992%%60%%996%%799999599%%999%%11%%997%%9999%%9179361%%91595   RTL-TTB  6
69%%7619919%%90499%%999%%62%%999%%9999799999911%%999%%57%%562%%99919%%9553919%%97   BTT-RTL  7
53919%%9799919%%9557%%562%%11%%999%%997999999%%999%%99%%999%%6219%%9049969%%76199   BTT-LTR  8
```
[Answer]
# Ruby - 7x7
Not impressive either, same tactic as the Haskell answer.
```
p 1#2 p
3     7
#     #
4     8
p 5#6 p
```
[Answer]
# [This](https://www.khanacademy.org/computer-programming/two-dimensional-programming-language/6252487852687360) Programming Language, 5 \* 9 = 45
```
1i;i2
2   2
+   +
i   i
;   ;
i   i
+   +
2   2
5i;i6
```
Which translates into this:
```
1i;i22   2+   +i   i;   ;i   i+   +2   25i;i6
5i;i62   2+   +i   i;   ;i   i+   +2   21i;i2
12+i;i+25i       i;       ;i       i22+i;i+26
22+i;i+26i       i;       ;i       i12+i;i+25
6i;i52   2+   +i   i;   ;i   i+   +2   22i;i1
2i;i12   2+   +i   i;   ;i   i+   +2   26i;i5
62+i;i+22i       i;       ;i       i52+i;i+21
52+i;i+21i       i;       ;i       i62+i;i+22
```
Since `;` terminates the program, the above translates into this:
```
1i;   - outputs 1
5i;   - outputs 5
12+i; - outputs 3
22+i; - outputs 4
6i;   - outputs 6
2i;   - outputs 2
62+i; - outputs 8
52+i; - outputs 7
```
**Explanation:** any number from `0` to `9` pushes the corresponding digit onto the stack. `+` pops the top two values `x` and `y` off the stack and pushes `x + y` onto the stack. `i` outputs the stack as an integer.
]