Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Breaking down whole number into digits

by aaron_baugher (Deacon)
on Nov 29, 2012 at 21:49 UTC ( #1006365=note: print w/ replies, xml ) Need Help??


in reply to Breaking down whole number into digits

Since you want "Nov" to be translated into "1 1", I'm guessing that you want to average the lowercase ordinal values of the first and third letters, find the difference between that and the ordinal value of the second letter, express that in binary, and then split that into digits. Here you go; hope it helps:

#!/usr/bin/env perl use Modern::Perl; my @n = split '', lc('Nov'); my @arr = split '', sprintf "%0b", (abs((ord($n[0])+ord($n[2]))/2 - ord($n[1]))); say join ' ', @arr;

Aaron B.
Available for small or large Perl jobs; see my home node.


Comment on Re: Breaking down whole number into digits
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2014-08-30 12:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (293 votes), past polls