Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $n = shift @ARGV;
- if ($n == 0) { $n = 6 };
- for ($i = 1; $i<$n+1; $i++) {
- # дополнительная оптимизация для скорости
- if (length $current > 0) { $current = $current . '-'; }
- $current = $current . $i;
- $output = "";
- $direction = (($i/2) == int ($i/2));
- if ($direction) {
- @chars = split //,$current;
- for ($k = $#chars ; $k > -1; $k--) {
- $output = $output . $chars[$k];
- }
- }
- if (not $direction) {
- $output = $current;
- }
- print "$output\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement