Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

How about Perl:

  #!/usr/bin/perl
  $n = 100;

  open(FH, '>touch') and print FH '' and close FH;
  push @ARGV, "Fizz$_" for (1..$n/3);	#push some fizz's
  push @ARGV, "Buzz$_" for (1..$n/5);	#push some buzz's
  push @ARGV, $_ for (1..$n);		#we'll sort it all out later

  1 while ($_ = shift and @ARGV and !fork);  #let the games begin

  if (/Fizz(\d+)/) {
     sleep $1 * 9;
     open (FH, '>>touch') and print FH "Fizz" and close (FH); 
     }

  elsif (/Buzz(\d+)/) {
     sleep $1 * 15 + 1;
     open (FH, '>>touch') and print FH "Buzz" and close (FH); 
     }

  else {
     sleep $_ * 3 + 2;
     open(FH, 'touch') and @lines = <FH> and close (FH);
     open(FH, '>touch') and print FH '' and close FH;
     print @lines ? @lines : $_, "\n";
     }

What do you think? I didn't bother cleaning up the file access. Nefarious though isn't it.


Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: