Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Newbie question

by jwkrahn (Abbot)
on Aug 23, 2022 at 21:45 UTC ( [id://11146343]=note: print w/replies, xml ) Need Help??


in reply to Newbie question

My 2 cents CDN, for what it's worth. (We don't have pennies anymore, so 0.)

$ perl -e' my @input = ( -222, -221, -21, 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 +, 144 ); sub oddDigitSum { my @ans; for ( @_ ) { my $sum; $sum += $_ for /\d/g; $sum % 2 && push @ans, $_; } return @ans; } print "@{[ oddDigitSum @input ]}\n"; '

Replies are listed 'Best First'.
Re^2: Newbie question
by oldB51 (Sexton) on Aug 24, 2022 at 07:07 UTC

    Thanks for this jwkrahn. I had already amended my code to use /\d/g. There are so many different ways of attacking a problem.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11146343]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2024-03-28 15:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found