in reply to Re: Odd Ball Challenge
in thread Odd Ball Challenge

djohnston,
The code won't even run at all currently under Pugs. If it is consistently giving the wrong answers then it is probably just a mapping issue. In order to verify, you would need to remove the randomness and force each ball to be heavy and then light in succession. The solution itself isn't the challenge though. The challenge is to write code that generates a solution.

Cheers - L~R

Replies are listed 'Best First'.
Re^3: Odd Ball Challenge
by kaif (Friar) on Jun 25, 2005 at 22:27 UTC

    I'm having trouble understanding how it even compiles. Isn't

    when -1 { return (9, $result_2 == $result_3 ? +? -1 :: 1 }

    a syntax error (mismatched parentheses)? If so, there are a few lines like that. Also, one line refers to

    when 0 { return (12, %ball{12} <=> %ball{0}) }

    where 0 should probably be 1. Finally, I confirm all of djohnston's results by translation to Perl 5 (for example, just imagine ball 1 is heavier and run through the code mentally --- it indeed says something about either ball 3 or 5). Pardon the ugly code; the Perl 6 is certainly prettier. But as Limbic~Region says, solving the riddle isn't the challenge, right?

      kaif,
      I'm having trouble understanding how it even compiles.

      As I stated - it doesn't compile or run. The typo you pointed out isn't the problem though. There are several bugs I uncovered in testing this code that won't even let a very minimal implementation run.

      Thanks for the code - I will investigate further when I get a chance.

      Cheers - L~R