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";
}
}
| [reply] [d/l] |
|
Quite so, since all the loops have the same bounds. ++ed
| [reply] |
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
| [reply] |
|
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
| [reply] |
|
| [reply] |
|
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
| [reply] |
|
|
|
|
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.
| [reply] |
|
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
| [reply] |
|
|
|
|
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.
| [reply] [d/l] |
|
Assuming 24-bit color, there are 640 * 480 * 2**24 possible bit maps.
Wrong. There are 2 ** (24 * 640 * 480) possible bitmaps.
| [reply] |
|
Check out the story The Library of Babel for a fictional universe in which such an experiment has been carried out with text.
| [reply] |
|
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.
| [reply] [d/l] [select] |
|
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.
| [reply] |
|
|