Created
December 23, 2011 09:25
-
-
Save ryhmrt/1513708 to your computer and use it in GitHub Desktop.
Solves FF13-2 Time Labyrinth Clock Quiz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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