Antiferromagnetic ordering
APL, 18 12 bytes
⍉(2×⎕)3⍴'↑↓'
This constructs a 2n x 3 matrix, where n is the input (⎕
), filled with the characters ↑
and ↓
. The transpose (⍉
) of this matrix is then printed.
You can try it online.
Pyth, 15 bytes (11 chars)
V3.>*Q"↑↓"N
Try it online: Demonstration
Explanation:
implicit: Q = input number
V3 for N in [0, 1, 2]:
"↑↓" string "↑↓"
*Q repeat Q times
.> N rotate the string by N
Java, 313 296 bytes
Here's an example that displays arrows graphically:
import java.awt.*;void f(int n){new Frame(){public void paint(Graphics g){for(int k=0,l,m,o;k<n*6;o=k%6,l=o/2*10+32,m=k/6*20+(k++%2==0?19:29),g.fillPolygon(new int[]{m+4,m,m+4,m+4,m+6,m+6,m+10},o==1|o==2|o==5?new int[]{l+9,l+5,l+5,l,l,l+5,l+5}:new int[]{l,l+5,l+5,l+9,l+9,l+5,l+5},7));}}.show();}
In a more readable format:
import java.awt.*;
void f(int n) {
new Frame() {
public void paint(Graphics g) {
for (int k = 0, l, m, o; k < n*6;){
o = k % 6;
l = o / 2 * 10 + 32;
m = k / 6 * 20 + (k++ % 2 == 0 ? 19 : 29);
g.fillPolygon(new int[] {m+4,m,m+4,m+4,m+6,m+6,m+10},
o == 1 || o == 2 || o == 5 ?
new int[] {l+9,l+5,l+5,l,l,l+5,l+5} :
new int[] {l,l+5,l+5,l+9,l+9,l+5,l+5},
7);
}
}
}.show();
}
The display for 5 as input:
You'll have to resize the window that appears to see the arrows. I tried to make it so that none of them would appear "chopped off" by the window's inside border, but it may appear that way on certain platforms.