Skip to content

Instantly share code, notes, and snippets.

@gnp
Created December 28, 2011 23:18
Show Gist options
  • Save gnp/1530371 to your computer and use it in GitHub Desktop.
Save gnp/1530371 to your computer and use it in GitHub Desktop.
A Perl 1-liner for a 10x10 addition grid for my kids
perl -e 'printf "%2s | ", "+"; for my $i (1..10) { printf "%3d ", $i; }; printf "\n---+-"; for my $i (1..10) { print "----"; } print "\n"; for my $i (1..10) { printf "%2d | ", $i; for my $j (1..10) { printf "%3d ", $i + $j; }; print "\n" }'
+ | 1 2 3 4 5 6 7 8 9 10
---+-----------------------------------------
1 | 2 3 4 5 6 7 8 9 10 11
2 | 3 4 5 6 7 8 9 10 11 12
3 | 4 5 6 7 8 9 10 11 12 13
4 | 5 6 7 8 9 10 11 12 13 14
5 | 6 7 8 9 10 11 12 13 14 15
6 | 7 8 9 10 11 12 13 14 15 16
7 | 8 9 10 11 12 13 14 15 16 17
8 | 9 10 11 12 13 14 15 16 17 18
9 | 10 11 12 13 14 15 16 17 18 19
10 | 11 12 13 14 15 16 17 18 19 20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment