Next | Program Repair Shop | 177 |
sub get_computer_choice { my $number = int(rand() * (@_ - 1)); return $_[$number]; }
This reveals an off-by-one error
sub get_computer_choice { my $number = int(rand(@_)); return $_[$number]; }
sub get_computer_choice { $_[int rand @_]; }
Now one wonders why this function is necessary at all
108 $computer_move = $available_choices[rand @available_choices];
Another 6 lines gone
Next | Copyright © 2002 M. J. Dominus |