News for hackers. Stuff that matters.
Re:Illegal prime by fizx on Monday January 11, 2010 @03:18PM (#1045898)
Think about Gödel numbering or Cantor diagonalization.

Let's assume discrete, rectangular representations of images (width, height in pixels and colorspace of #000000-#FFFFFF). Here's an injective mapping from natural numbers (the indices of the vector of images) to actual images:

    # In a C-like language where ** is 
    # the exponentiation operator, and 
    # ints are unbounded.
    int colors = 0xFFFFFF + 1;
    int i = 0;
    vector images = new vector();
    while(i++) {
      for(int width = 1; width < i; width++) {
        int height = i - width;
        int area = width * height;
        int pixels[area];
        int combinations = colors ** area;
        for(int c = 0; c < combinations; c++) {
          for(int p = 0; p < area; p++) {
            pixels[p] = c % (colors ** (p + 1));
          }
          images.append(new image(width, height, pixels));
        }
      }
    }

There are no comments on this comment yet.