title: Easy brain stumper, a better algorithm
body: <p>This was at a community college.  I failed it, but want to know the answer. </p>
  
  <p>The problem is this: you have an 2D array of structs that represents an image.  Each struct has a red, green, blue, and alpha value.  There can be more info, but not required to solve the problem.</p>
  
  <p>Say the image is 4000x4000 or 16 Million elements.  Every element needs to be updated/checked on every turn.</p>
  
  <p>For each element you need to:</p>
  
  <ul>
  <li>Set the red byte to 50 if &lt; 50 or set to 205 > 205</li>
  <li>Set the green byte to a random value between 0 and 255 using rand()</li>
  <li>Modify blue in an "interesting" way.</li>
  </ul>
  
  <p>"You can't brute force this, think in a smarter way; you need a better algorithm"</p>
  
  <p>I basically did a loop.  I was the fastest but he said it was "about finding a better algorithm, not using using cute compiler and pointer tricks".</p>
  
  <p>Also needs to be in pure C.  No OpenMP/Threads or OpenGL shading, OpenCL, etc... just ANSI C with standard libraries (even GNU/POSIX libraries were forbidden).</p>
  
  <p>I asked about bitwise operations and he said that "those are very expensive in C [??] and it's about writing a fast and solid algorithm, not these cute tricks you keep coming up with".</p>
  
  <p>So any hints?  </p>