Next | Program Repair Shop | 185 |
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[int rand @available_choices];
Another 6 lines gone
Next | Copyright © 2001 M. J. Dominus |