Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^2: Canadian Cryptography Contest

by tadman (Prior)
on Jan 22, 2002 at 20:20 UTC ( [id://140679]=note: print w/replies, xml ) Need Help??


in reply to Re: Canadian Cryptography Contest
in thread Canadian Cryptography Contest

Then, of course, you would do the following:
for(1..1e6){$s+=$_ for/./g};print$s
Unfortunately, map seems to choke on 1e6 entries.

Replies are listed 'Best First'.
Re (tilly) 3: Canadian Cryptography Contest
by tilly (Archbishop) on Jan 22, 2002 at 21:40 UTC
    perl -e'map$\+=$_,/./g for 1..1e6;print'
    also works. OTOH before this is done running you should be able to reason out why the answer is 27,000,001. (Big hint. The 1 is the contribution from the 7'th digit.) As for map chocking, if you are on any Perl before 5.6.1, the many for one map shows quadratic performance, so it will indeed choke and remain choked for a good while on a million entries.
      map choked completely, by using massive amounts of memory.
      This is perl, v5.6.1 built for i686-linux
      Must be one of those things.
        Hrm.

        Possible. After all you are taking a list of a million, turning that into a list of about 6 million things, then allocating 6 million scalars. If each scalar takes 32 bytes, that is 192 MB just for the scalars, not even counting the space taken by the stack...

        With 5.6.0 and earlier you would have had the same potential problem, but would likely get bored before taking enough hours to get there.

Re^3: Canadian Cryptography Contest
by Aristotle (Chancellor) on Jan 23, 2002 at 18:48 UTC
    Ok, explain. Try as I might I can't figure out what you're trying to get at.

    Makeshifts last the longest.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-04-23 15:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found