sub step { my ($dir, $r, $c) = @_; if ($dir == N) {return (--$r, $c)} elsif ($dir == NE) {return (--$r, ++$c)} elsif ($dir == E) {return ($r, ++$c)} elsif ($dir == SE) {return (++$r, ++$c)} elsif ($dir == S) {return (++$r, $c)} elsif ($dir == SW) {return (++$r, --$c)} elsif ($dir == W) {return ($r, --$c)} elsif ($dir == NW) {return (--$r, --$c)} else { die "Inside 'step': invalid param\n" } }