February 2006
Intermediate to advanced
304 pages
6h 16m
English
This is one of the simpler computer games. The program generates a random number in the interval 1 to 1,000 and asks you to guess it.
Guess right and you win. Guess wrong and the system adjusts the interval based on your guess and let's you try again.
This is a good game for first graders. It teaches them the basics of computer usage and how to follow instructions and even gives them an idea of how to create a binary search.
1 use strict; 2 use warnings; 3 4 my $low = 1; # Current low limit 5 my $high = 1000; # Current high limit 6 7 # The number the user needs to guess 8 my $goal = int(rand($high))+1; 9 10 while (1) { 11 print "Enter a number between $low and $high: "; 12 13 # The answer from the user 14 my $answer ...Read now
Unlock full access