Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^3: Very Large Hex Combinations

by ikegami (Patriarch)
on Aug 04, 2005 at 15:14 UTC ( [id://480860]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Very Large Hex Combinations
in thread Very Large Hex Combinations

How large? That produces all patterns from 000000000000 to FFFFFFFFFFFF. Add more loops to make it bigger, or increase $num_bytes in my second snippet.

Replies are listed 'Best First'.
Re^4: Very Large Hex Combinations
by Taulmarill (Deacon) on Aug 04, 2005 at 15:18 UTC
    i think one should use recursion here, something like this maybe
    use strict; use warnings; my @charset = ( 0..9, "A".."F" ); rec( 8 ); sub rec { my $deep = shift; my $string = shift || ''; if ( $deep-- ) { for my $char ( @charset ) { rec( $deep, $string . $char ); } } else { print "$string\n"; } }
      Quite so, since all the loops have the same bounds. ++ed
Re^4: Very Large Hex Combinations
by danambroseUK (Beadle) on Aug 04, 2005 at 15:41 UTC
    Its a crazy idea but what I am trying to do is create every combination possible of a 640x480 bitmap file.

    Yes this would take forever to do - but just imagine if every photo was created - we would have every photo of everything. Every photo ever taken and every photo to be taken- Effectivly a time machine!!

    Jokes aside, how would this be achieved?


    Thanks,
    Dan
      Its a crazy idea but what I am trying to do is create every combination possible of a 640x480 bitmap file.
      After that you could also generate all possible novels up to 500 pages, so I will finally get rid of the monkeys in my basement ;-)

      Seriously, the number of all possible images is *real* huge, and even if you managed to save them somewhere, indexing them would be as difficult as generating them. In order to retrieve a specific image, you would somehow be able to indicate "I want the image whose first pixel is 0xa, whose second pixel is 0x0 ..." and so on with all the pixels. It is more reasonable to just generate it on the fly (and it allows you to save a few gazillion bytes).

      Cheers

      Antonio



      The stupider the astronaut, the easier it is to win the trip to Vega - A. Tucket
      Eh, may I suggest starting with smaller sized pictures? Say, 8x8 bitmaps? Of which there are 18446744073709551616, each taking 8 bytes of storage. You only need 137438953472 disks of 1 Tb each to store them. Suppose you can install one such disk each second, and you never tire, you don't need sleep, you don't need to eat, and don't go to the bathroom. Furthermore, disk companies manage to supply you with enough disks. Then you only need 4355 years to install the disks to store your all your 8x8 bitmaps.

      After doing the 8x8 bitmaps, you might want to tackle the 12x12 bitmaps. If you can install 1Tb of storage each second, you only need 9 * 10^35 years to install your storage.

        8x8 bitmaps have file sizes of 246 bytes.
        8x8 bitmaps take 4096 bytes of disk space (under NTFS).
        Thus, all 8x8 bitmaps would take over 75,557,863,725,914 GB of disk space.

        I suppose you could invent your own archival format and image format where it would take the miminum 147,573,952,590 GB

      One of those photos would reveal that you killed JFK!!! Do you think that the world is prepared for this truth?

      Flavio
      perl -ple'$_=reverse' <<<ti.xittelop@oivalf

      Don't fool yourself.
        Yes I am aware that there is going to be *minor* storage issues - what I am after is proof of concept a script that could produce, well start producing every combination possible.

        How might this be coded?

        Just imagine this could a project like seti whereby using idle computer time do the calculations, they have logged years of computing time in this way.


        Dan

      Update: Minor brainfart there. The point of the post still holds, but you'll need to multiply all the numbers by 2**( 640 * 480 ):

      142427923839648881629184805134324652164093716404030097299710376120451 134154787190076398812090414510556300740006550934739747222066752231099 294344002591005120626800863471535551485395485528316242619445670424359 449935350841325881969413228910724065033772133523230370773849709948530 89450777507879083442634420291861180736024127002634265953304576

      Assuming 24-bit color, there are 640 * 480 * 2**24 possible bit maps. That's 5.15e12.

      To put that number in perspective, if you could generate 1/second, it would take you 163,319 years.

      Now let's say you secured the services of 163,319 computers for 1 year and generated them all. It would require ~5 million million million million GB of storage to hold. So, let's say that the disks/tapes were available.

      Now to find that perfect picture that you are going to take of your great Aunt 5 years from now, all you've got to do is wade through all the mostly black and mostly white and mostly blue and mostly grey, and all those where you chopped off her head.

      If you can reject 1 per second that's gonna take you...


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
      "Science is about questioning the status quo. Questioning authority".
      The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.
        Assuming 24-bit color, there are 640 * 480 * 2**24 possible bit maps.
        Wrong. There are 2 ** (24 * 640 * 480) possible bitmaps.
      Check out the story The Library of Babel for a fictional universe in which such an experiment has been carried out with text.

      There are 5,153,960,755,200 (640*480*(2^24)) true colour 640x480 images.

      The file size of each image would be 921,654 (54 + 640*480*3) bytes.

      The disk space used by each image (on NTFS) would be 925,696 (ceil(921,654/4,096)*4,096) bytes (plus space used by the directory).

      The disk space used by all images (on NTFS) would be 4,771,000,855,245,619,200 (925,696 * 5,153,960,755,200) bytes (slightly under 5 billion Gigabytes).

       

      What if you generated 128x128 images using 16 colours?

      Num images = 160,000 File size = 8,310 bytes Disk space per images = 12,288 bytes Total disk space = 1,966,080,000 bytes =~ 2GB

      That's attainable, but it's only thumbnail size.

        There are a whole lot more than 640*480*2^24 true colour images. There are 307200 pixels (640*480), each of which can take 2^24 different colours. That leads to 2^(24*640*480) different images, that is 2^7372800. That's a number that takes more than 2 million digits to write down.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2024-03-19 11:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found