Advertisement
zloyrusskiy

Bad code

Apr 5th, 2011
2,527
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.50 KB | None | 0 0
  1. $n = shift @ARGV;
  2. if ($n == 0) { $n = 6 };
  3.  
  4. for ($i = 1; $i<$n+1; $i++) {
  5.     # дополнительная оптимизация для скорости
  6.     if (length $current > 0) { $current = $current . '-'; }
  7.     $current = $current . $i;
  8.     $output = "";
  9.     $direction = (($i/2) == int ($i/2));
  10.     if ($direction) {
  11.         @chars = split //,$current;
  12.         for ($k = $#chars ; $k > -1; $k--) {
  13.             $output = $output . $chars[$k];
  14. }
  15.     }
  16.     if (not $direction) {
  17.         $output = $current;
  18.     }
  19.     print "$output\n";
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement