Here's my solution. Is this the kind of thing you had in mind?

#! /usr/bin/perl use strict; use warnings; my @left; my @right; for (my $i = 0; $i <= 11; $i++) { my $j = $i+1; $j = 0 if $j == 12; print "Weigh Balls $i and $j\n"; print "Enter a result for each ball as follows:\n"; print " b-b Both balls balance\n"; print " u-d Left side up, right side down\n"; print " d-u Left side down, right side up\n"; chomp( my $input = <STDIN>); my @results = split/-/, $input; $left[$i] = $results[0]; $right[$j] = $results[1]; } for (my $i = 0; $i <= 11; $i++) { if (( $left[$i] eq "b") || ( $right[$i] eq "b")) { print "Ball $i is normal\n\n"; } elsif (( $left[$i] eq "d" ) && ( $right[$i] eq "d")) { print "Ball $i is Heavy!\n\n" } elsif (( $left[$i] eq "u" ) && ( $right[$i] eq "u" )) { print "Ball $i is Light!\n\n"; } else { print "Something is FUBAR somewhere!\n"; } }
I haven't included any error checking for input errors, etc. It's just the bare logic.

Jack


In reply to Re: Odd Ball Challenge by jcoxen
in thread Odd Ball Challenge by Limbic~Region

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.