hi all, I have a working solution in perl 5.14

use v5.10; %ball=map{$_ =>1}1..12; Modify_Ball( %ball ); say Find_Odd_Ball( %ball ); sub Find_Odd_Ball (%ball) { my $result_1 = ((eval join '+', @ball{1..4}) <=> (eval join '+', @ball +{5..8})); given ($result_1) { when (-1) { my $result_2 = ((eval join '+', @ball{1,2,5}) <=> (eval jo +in '+', @ball{3,6,10})); given ($result_2) { when (-1) { my $result_3 = $ball{1} <=> $ball{2}; given ($result_3) { when (-1) { return (1, $result_1) } when (0) { return (6, $result_1 * -1) } when (1) { return (2, $result_1 ) } } } when (0) { my $result_3 = $ball{7} <=> $ball{8}; given ($result_3) { when (-1) { return (8, $result_1 * -1) } when (0) { return (4, $result_1) } when (1) { return (7, $result_1 * -1) } } } when (1) { return $ball{3} == $ball{10} ? (5, $result_ +1*-1 ) : (3, $result_1) } } } when (0) { my $result_2 = ((eval join '+', @ball{9,10}) <=> (eval + join '+', @ball{1,11})); given ($result_2) { when (0) { return (12, $ball{12} <=> $ball{1}) } default { my $result_3 = $ball{9} <=> $ball{10}; given ($result_3) { when (-1) { return ($result_2 == $result_3 ? 9 + : 10, $result_2 == $result_3 ? -1 : 1) } when (0){ return (11, $result_2 * -1) } when (1) { return ($result_2 == $result_3 ? 9 +: 10, $result_2 == $result_3 ? 1 : -1) } } } } } when (1) { my $result_2 = ((eval join '+', @ball{1,5,6}) <=> (eval jo +in '+', @ball{2,7,10})); given ($result_2) { when (-1) { my $result_3 = $ball{5} <=> $ball{6}; given ($result_3) { when (-1) { return (5, $result_1*-1) } when (0) { return (2, $result_1 ) } when (1) { return (6, $result_1 * -1) } } } when (0) { my $result_3 = $ball{3} <=> $ball{4}; given ($result_3) { when (-1) { return (4, $result_1 ) } when (0) { return (8, $result_1*-1) } when (1) { return (3, $result_1 ) } } } when (1) { return $ball{7} == $ball{10} ? (1, $result_ +1 ) : (7, $result_1*-1); } } } } } sub Modify_Ball( %ball ) { my $num = int( rand 12 ) + 1; my $adj = .1 * (int( rand 2 ) ? 1 : -1); $ball{$num} += $adj; say $num; say $ball{$num}; }

In reply to Re: Odd Ball Challenge by ej8000
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.