in reply to John Guttag's book - 2nd exercise. My attempt in Perl.

Point to note is, it should only use if/else/elsif loops and / or comparison operators.

So no modulo operator, no division operator, no arithmetic operators, no bitwise foo... how would you determine oddness only with comparison? You would need an array which holds all odd values of |N. My computer can't.

perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

Replies are listed 'Best First'.
Re^2: John Guttag's book - 2nd exercise. My attempt in Perl.
by Laurent_R (Canon) on May 20, 2017 at 21:29 UTC
    I guess the OP meant to say that you should not use things like sort, map, grep or List::Util. The code in the OP is using the modulo operator, so we should assume this is allowed.
        I agree with you (and upvoted your posts), but, still, the OP is providing some of the information needed in the suggested code. We can use this information.
Re^2: John Guttag's book - 2nd exercise. My attempt in Perl.
by pritesh_ugrankar (Monk) on May 21, 2017 at 10:58 UTC

    Hi,

    Modulo Operator can be used as I've used in my code. Sorry I should've stated that earlier.

    Thinkpad T430 with Ubuntu 16.04.2 running perl 5.24.1 thanks to plenv!!