Skip to content

Instantly share code, notes, and snippets.

@tadzik
Created January 29, 2012 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tadzik/1699126 to your computer and use it in GitHub Desktop.
Save tadzik/1699126 to your computer and use it in GitHub Desktop.
┌─[tadzik@yavin4]─[~]
└─[%]─> cat dupa.pl
# we declare 8 arrays, named a to h, representing each column bottom to top i.e. @a[1] refers to the square a1 and @a[8] refers to a8.
# also, we are *not* using the zero-indexed position.
# the first 33 elements of each column need to " " initially
my @a = " " xx 33;
my @b = " " xx 33;
my @c = " " xx 33;
my @d = " " xx 33;
my @e = " " xx 33;
my @f = " " xx 33;
my @g = " " xx 33;
my @h = " " xx 33;
#the drawing function. we draw from top row to bottom row. (while in chess the lowest row is called '1'!)
# expected output:
# a b c d e f g h
# +---+---+---+---+---+---+---+---+
# 8 | | | | | | | | | 8
# +---+---+---+---+---+---+---+---+
# 7 | | | | | | | | | 7
# +---+---+---+---+---+---+---+---+
# 6 | | | | | | | | | 6
# +---+---+---+---+---+---+---+---+
# 5 | | | | | | | | | 5
# +---+---+---+---+---+---+---+---+
# 4 | | | | | | | | | 4
# +---+---+---+---+---+---+---+---+
# 3 | | | | | | | | | 3
# +---+---+---+---+---+---+---+---+
# 2 | | | | | | | | | 2
# +---+---+---+---+---+---+---+---+
# 1 | | | | | | | | | 1
# +---+---+---+---+---+---+---+---+
# a b c d e f g h
say " a b c d e f g h ";
for (1..8) {
say " +---+---+---+---+---+---+---+---+";
say "{9-$_} | @a[9-$_] | @b[9-$_] | @c[9-$_] | @d[9-$_] | @e[9-$_] | @f[9-$_] | @g[9-$_] | @h[9-$_] | {9-$_}";
}
say " +---+---+---+---+---+---+---+---+";
say " a b c d e f g h ";
┌─[tadzik@yavin4]─[~]
└─[%]─> perl6 dupa.pl
a b c d e f g h
+---+---+---+---+---+---+---+---+
8 | | | | | | | | | 8
+---+---+---+---+---+---+---+---+
7 | | | | | | | | | 7
+---+---+---+---+---+---+---+---+
6 | | | | | | | | | 6
+---+---+---+---+---+---+---+---+
5 | | | | | | | | | 5
+---+---+---+---+---+---+---+---+
4 | | | | | | | | | 4
+---+---+---+---+---+---+---+---+
3 | | | | | | | | | 3
+---+---+---+---+---+---+---+---+
2 | | | | | | | | | 2
+---+---+---+---+---+---+---+---+
1 | | | | | | | | | 1
+---+---+---+---+---+---+---+---+
a b c d e f g h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment