Skip to content

Instantly share code, notes, and snippets.

@ryhmrt
Created December 23, 2011 09:25
Show Gist options
  • Save ryhmrt/1513708 to your computer and use it in GitHub Desktop.
Save ryhmrt/1513708 to your computer and use it in GitHub Desktop.
Solves FF13-2 Time Labyrinth Clock Quiz
use strict;
my @t = map { {'v' => $_} } split //, "114152264215";
for my $i (0..$#t) {
$t[$i]{'i'} = $i;
my $ni = $i + $t[$i]{'v'};
$ni -= @t if ($ni >= @t);
my $pi = $i - $t[$i]{'v'};
$ni += @t if ($ni < 0);
$t[$i]{'n'} = $t[$ni];
$t[$i]{'p'} = $t[$pi];
}
for my $t (@t) {
&step($t)
}
sub step {
my $self = shift;
my @steps = @_;
return if (grep {$_ == $self->{'i'}} @steps);
push @steps, $self->{'i'};
if ($#steps == $#t) {
for my $i (@steps) {
print $i, ':', $t[$i]->{'v'}, "\n";
}
exit;
}
&step($self->{'n'}, @steps);
&step($self->{'p'}, @steps);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment