Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Just for kicks, here's my corrolary, where the computer guesses. It turned out a lot simpler. I'm trying harder to make it pretty, too.
#The computer will try to guess your number. #Watch out! It knows if you're cheating. use strict; use warnings; sub game{ my $min=0; my $max=200; my $guess; my $response="h"; print "Think of a number between $min and $max, and I will guess wha +t it is. Type h if your number is higher than my guess, and type l i +f it is lower. Type = if I have guessed your number.\n"; while ($response ne "="){ if ((($max-$min)/2)<1){ print "You're not playing fair! I quit.\n"; return; } else{ $guess=int($max-(($max-$min)/2)); print "My guess is ",$guess,".\n"; $response = <STDIN>; chomp($response); if ($response eq "h"){ $min=$guess; } elsif ($response eq "l"){ $max=$guess; } } } } my $again = 'y'; while ($again eq 'y'){ game(); print "That was fun--no really, it was. Play again? (y/n) \n"; $again = <STDIN>; chomp ($again); } print "Goodbye!\n";

In reply to Re^2: Number Guess by cryptoquip
in thread Number Guess by cryptoquip

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-24 19:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found