Skip to content

Instantly share code, notes, and snippets.

@evdb
Created January 17, 2016 15:05
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 evdb/cf85bc05f45d17503047 to your computer and use it in GitHub Desktop.
Save evdb/cf85bc05f45d17503047 to your computer and use it in GitHub Desktop.
$a = 8;
$G{ int( ++$a / 9 ) . $a % 9 + 1 } = $_ for split //, <>;
@A = 1 .. 9;
sub c {
int( ( $_[0] - 1 ) / 3 ) * 3;
}
sub G {
for $y (@A) {
for $x (@A) {
$p = $t = $G{ my $c = $y . $x } && next;
$t .= $G{ $_ . $x } . $G{ $y . $_ } for @A;
for $f ( 1 .. 3 ) { $t .= $G{ c($y) + $f . c($x) + $_ } for 1 .. 3 }
G( $G{$c} = $_ ) && return for grep $t !~ m/$_/, @A;
return $G{$c} = 0;
}
}
die map { $G{$_} } 9 .. 99;
}
G
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment