Quickly Solving the “Instagram Engineering Challenge: The Unshredder”

Today I have read about the Instagram Engineering Challenge: The Unshredder, and decided to give it a try. The task is simple to explain: Create a program that can unshred this image (do not try the challenge on this image, try the original PNG source instead!):


I have postet here that I think I can solve it in 2 hours, and got some downvotes for that; so I have decided to really give it a try. Long story short, it took me about 2 hours and 35 minutes.

Before I started developing, I made some quick assumptions to simplify things:

  • I want to code it in Ruby, this is the language where I am most productive.
  • I can assume the size of the stripes is well known, and I have hardcoded this size.
  • The image can be converted to RAW with an external tool, and written into RAW.
While coding I timed myself, and created a little timeline of my trials and errors. Since I wanted to finish as quickly as possible, the code is very ugly: no tests, some hardcoded constants, etc.

Continue reading “Quickly Solving the “Instagram Engineering Challenge: The Unshredder””