Skip to content

Instantly share code, notes, and snippets.

@hiratara
Created January 10, 2009 13:24
Show Gist options
  • Save hiratara/45450 to your computer and use it in GitHub Desktop.
Save hiratara/45450 to your computer and use it in GitHub Desktop.
package main;
use strict;
use warnings;
my $board = Board->new(
table => [
[-1,-1, 0, 1, 1,-1,-1],
[ 0, 0, 0, 0, 1, 2,-1],
[ 0, 8, 0, 2, 2, 2, 0],
[ 8, 8, 0, 6, 0, 3, 3],
[ 8, 7, 0, 5, 0, 3, 4],
[-1, 7, 7, 5, 5, 4, 4],
[-1,-1, 0, 5, 0,-1,-1],
],
);
sub goal{
my $table = shift;
foreach my $x(1 .. 5){
foreach my $y(1 .. 5){
return 0 if Table::get($table, $x, $y) <= 0;
}
}
return 1;
}
# my $board = Board->new(
# table => [
# [14, 1, 7, 8],
# [ 4, 0, 6, 9],
# [15, 5, 2,12],
# [ 3,11,13,10],
# ]
# );
# sub goal{
# my $table = shift;
# foreach my $x(0 .. 3){
# foreach my $y(0 .. 3){
# return 0 unless $table->get($x, $y) == $x * 4 + $y;
# }
# }
# return 1;
# }
my $file = 'result' . time . '.txt';
open my $out, '>', $file;
foreach(@ans){
print $out "$_\n";
print $out "#################\n";
}
close($out);
__END__
print $board, "\n";
print $board->id, "\n";
print $board->width, "\n";
print $board->height, "\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment