Skip to content

Instantly share code, notes, and snippets.

@dom111
Created September 25, 2015 17:59
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 dom111/5b182dd8120905371982 to your computer and use it in GitHub Desktop.
Save dom111/5b182dd8120905371982 to your computer and use it in GitHub Desktop.
# Change settings here - colour assumes Bash-like ANSI supported terminal
$colour = 1;
$testing = 0;
$n=<>;
$n+=!($n%2);
@l=split//,'??EEEEEEEEEEEEAAAAAAAAAIIIIIIIIIOOOOOOOONNNNNNRRRRRRTTTTTTLLLLSSSSUUUUDDDDGGGBBCCMMPPFFHHVVWWYYKJXQZ';
if($testing){
map{$m=$_-1;$r[$m]=[map'.',1..$n]}1..$n;
}
else{
map{$m=$_-1;$r[$m]=[map$l[rand 100],1..$n]}1..$n;
}
$r[$n/2]->[$n/2]=$";
# bonus squares
$s=(($n/2)-1)%3+1;
for($i=$s;$i<$n-1;$i+=3){
for($j=$s;$j<$n-1;$j+=3){
if($testing){
$r[$i]->[$j]=$r[$i]->[$j]eq$"?$":'#';
}
else{
$r[$i]->[$j]=$r[$i]->[$j]eq'?'?'!':lc$r[$i]->[$j];
}
if($colour){
$r[$i]->[$j]=$r[$i]->[$j]eq$"?$":"\e[44;93m".$r[$i]->[$j]."\e[0m";
}
}
}
$"='';
print"@$_
"for@r
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment