in reply to Re: Can you spot the problem? (golf)
in thread Can you spot the problem?

Me too. Question is, which way is neatest. Can it be done with one char? In fact, I'm fairly convinced it can't. I can come up with several two-char changes which make it work, but no one-chars.


Ok. given that there's spoilers on here already, and a post explaining why it's broken:

which of these did you think cleaner (my vote is for the first)

(0|$a|$b|$c|$d) < 256 ($a+0|$b|$c|$d) < 256

The key here is that | (a bitwise operator) will operate on pairs of chars if both of it's args are a string. In other words, for "abc" | "def" it does ("a"|"d").("b"|"e").("c"|"f"). However, if either arg has been used in a numeric expression, the evaluation will be done with both sides as a number.
  • Comment on Re: Re: Can you spot the problem? (golf)

Replies are listed 'Best First'.
Re: Can you spot the problem? (golf)
by jonadab (Parson) on Mar 05, 2004 at 21:23 UTC
    How'd we compare notes / or check the solution without doing a spoiler for everyone else?

    There is a way...

    Have you ever played any Interactive Fiction?

    Or read any game-related usenet groups?

    One hint left...


    ;$;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$;[-1]->();print